Importing & Exporting Video
The Wolfram Language supports importing from and exporting to a large number of multimedia containers and codecs. Together with the complete stacks for image and audio processing, this opens up video processing from simple processing to highly sophisticated analysis.
A video file can be imported into the Wolfram Language as a Video object for further processing and analysis. Different parts of the data or metadata stored in video files are directly accessible via import elements.
Import["file"] | import video files as a Video object |
Import["file",elem] |
import video frames, audio, etc. from a video file
|
Import["http://…"] | import a remote video as a Video object |
Import a video file as a Video object:
In[1]:=1

✖
https://wolfram.com/xid/0scsh33ts987z896-r31c9q
Out[1]=1

In[62]:=62

✖
https://wolfram.com/xid/0scsh33ts987z896-1tbf3m
Out[62]=62

In[14]:=14

✖
https://wolfram.com/xid/0scsh33ts987z896-m0qiim
Out[14]=14

In[63]:=63

✖
https://wolfram.com/xid/0scsh33ts987z896-k0ewrw
Out[63]=63

Supported video formats include "AVI", "Matroska", "MP4", "Ogg" and "QuickTime". Import also tries to import other video files using the catch-all format "VideoFormat".
Each media container can store data using several different encodings. Codec support varies from one platform to another.
$VideoDecoders | supported video decoders |
$AudioDecoders | supported audio decoders |
$SubtitleDecoders | supported subtitle decoders |
In[69]:=69

✖
https://wolfram.com/xid/0scsh33ts987z896-3vpwm0
Out[69]=69

Video objects, animations or lists of image frames can be exported to video files with or without audio data.
Export["file.ext",video] | export a Video object to a video file |
Export["file.ext",images] | export a list of images to a video file |
Export["file.ext",rules,"Rules"] | export video with audio to a video file |
In[97]:=97

✖
https://wolfram.com/xid/0scsh33ts987z896-fpu3wf
Out[97]=97

In[98]:=98

✖
https://wolfram.com/xid/0scsh33ts987z896-3xx5vm
Out[98]=98

In[37]:=37

✖
https://wolfram.com/xid/0scsh33ts987z896-63dcxf
Out[37]=37

In[38]:=38

✖
https://wolfram.com/xid/0scsh33ts987z896-f0xt06
Out[38]=38

In[39]:=39

✖
https://wolfram.com/xid/0scsh33ts987z896-vkcymb
Out[39]=39

Animations and lists of frames can be combined with Audio objects when exported to a video file.
In[40]:=40

✖
https://wolfram.com/xid/0scsh33ts987z896-r1hc4i
In[41]:=41

✖
https://wolfram.com/xid/0scsh33ts987z896-1utib6
Out[41]=41

In[43]:=43

✖
https://wolfram.com/xid/0scsh33ts987z896-6b8dja
Out[43]=43

Supported video formats are "AVI", "Matroska", "MP4", "Ogg" and "QuickTime". Each media container can store data using several different encodings. The support for codecs varies from one platform to another.
Supported video containers in Export:
In[107]:=107

✖
https://wolfram.com/xid/0scsh33ts987z896-5szd3r
Out[107]=107

$VideoEncoders | supported video encoders |
$AudioEncoders | supported audio encoders |
$SubtitleEncoders | supported subtitle encoders |
In[44]:=44

✖
https://wolfram.com/xid/0scsh33ts987z896-lgh80a
Out[44]=44

The Wolfram Language by default uses the operating system as well as a limited version of FFmpeg for decoding and encoding video files.
Install FFmpeg Version 4.0.0 or higher to get a more complete codec support. See the following for platform-specific instructions.
In[1]:=1

✖
https://wolfram.com/xid/0scsh33ts987z896-y2i3zh
Out[1]=1

In[3]:=3

✖
https://wolfram.com/xid/0scsh33ts987z896-jcex7r
Out[3]=3


✖
https://wolfram.com/xid/0scsh33ts987z896-756knn
In[2]:=2

✖
https://wolfram.com/xid/0scsh33ts987z896-8ycsh1
Out[2]=2

In[3]:=3

✖
https://wolfram.com/xid/0scsh33ts987z896-3j6993
Out[3]=3

In[6]:=6

✖
https://wolfram.com/xid/0scsh33ts987z896-tgroq1
Out[6]=6

In[1]:=1

✖
https://wolfram.com/xid/0scsh33ts987z896-zcgc8
Out[1]=1

In[8]:=8

✖
https://wolfram.com/xid/0scsh33ts987z896-1g5m5g
Out[8]=8

In[9]:=9

✖
https://wolfram.com/xid/0scsh33ts987z896-l9ueah
Out[9]=9

Installing FFmpeg
Only 64-bit shared (not static) builds of FFmpeg 4.0.0 or later are supported on Windows, macOS and Linux.
On Windows, download shared binaries from http://ffmpeg.org, install, and add the directory containing ffmpeg.exe and the dynamic libraries (such as av*.dll files) to the PATH environment variable.
On macOS, install using Homebrew or MacPorts in either of the following locations: /usr/local/lib, /opt/homebrew/lib or /opt/local/lib.
Alternatively, download FFmpeg sources from http://ffmpeg.org and build with shared linking; enable GPL parts and all necessary codecs.