Video Basics

The Wolfram Language supports video objects as first-class citizens, enabling programmatic access, processing and analysis of a large number of multimedia containers and codecs. Together with complete stacks for image and audio processing, this opens up video processing from simple processing to highly sophisticated analysis.
Video Creation and Representation
A video object can be created by importing or referencing a video file on the disk.
a video object representing a video in file
a video object representing a video in url
a video generated from a Manipulate object
import a specific element from a video file
Video creation functions.
The video object is a reference to a local or remote file, with interactive video rendering capabilities. The actual data of the video file remains out-of-core, but parts of it such as image frames or audio chunks can be imported into the memory.
This creates an out-of-core video object taken from the Wolfram Language documentation "ExampleData" directory:
Use Import to create the Video object:
Create a Video object referencing a URL:
Generate a Video from a Manipulate:
Generate a Video from a list of images via Export and Import:
You can use Import to obtain specific data or metadata elements from a video file, such as duration, list of frames or audio data.
Available import elements for a video file are:
Import two video frames as images:
Retrieve the video duration:
Import the audio content of the video as an Audio object or raw data:
Video Properties
The Video object has more than one purpose. It is a video file reference, a video data importer and a viewer. With respect to these functionalities, the Video object exhibits different sets of properties.
Video properties related to the video file and its content can be obtained by the following functions.
give the duration of video
return property prop of video
import a summary of the properties of file
Video data properties.
Get the total duration of a video object:
The Information function provides a video summary:
Use Information to extract a single property from the video object:
The "Summary" element of Import is also a convenient way to retrieve relevant properties of a video file.
Import summary of a video file:
The Video object can take options that control access and extraction of video data. These options will not change the content of the file, but instead determine the properties of extracted data for processing and display.
gives the raster size of extracted video frames
Video access properties.
Reduce the video resolution by specifying a small RasterSize:
The extracted frame size from the Video object matches the specified RasterSize:
Compare with the size of frames in the file:
A video object can take more options that control the video and audio playback.
the overall appearance of the video player
the image size of the displayed video
audio output device to use for video playback
sound volume of the video player
Video playback properties.
Create a "Minimal" GUI with a width of 200 pixels:
Set the volume to 50%:
Video Trimming & Frame Extraction
It is a common operation to trim a part of a video or extract frames from a video file.
returns a video object consisting of the time interval t1 to t2
returns a list of n video frames
extracts video frames at times t1,t2,
Video extraction functions.
Obtain a video scene by trimming a video to a given time interval.
Trim a time interval out of a video:
Check the resulting video duration:
Generate a video summary by extracting frames.
Extract four frames from a video:
Extract frames from a video at specific time instances:
Assemble extracted frames into a thumbnail collage:
Basic Processing and Analysis
Video processing or filtering is a video-in, video-out operation. Functions may operate on individual frames or a sequence of video frames to create new frames for the output video. Video analysis is the process of understanding the content of video by computing statistics or extracting features from single frame or a sequence of video frames.
applies f to each frame in video returning a new video
applies f to each frame in video returning a time series
Video processing and analysis functions.
VideoFrameMap applies image functions to individual frames or a sequence of video frames, resulting in a new video object.
Negate frames in a video scene:
Create motion blur on a video by blending five consecutive frames:
VideoTimeSeries can be used for analyzing and detecting video content by applying functions to video frames that return an arbitrary result, returned as a TimeSeries.
Determine the entropy of each frame:
Measure the difference between consecutive image frames:
The VideoStream expression can be used to programmatically manipulate the video playback.
creates a new VideoStream object from video
starts playing a VideoStream object vstream
pauses the playback of vstream
stops the playback vstream
returns all existing video streams
deletes the VideoStream object vstream
Video streaming functions.
Create a VideoStream object from a Video object:
Get a list of available properties of a video stream:
Get a specific stream property:
Programmatically start, pause and stop a video stream:
Display the current frame of a video stream:
Check all available video streams:
Remove all video streams: