VideoFormat (.3gp, .h264, .h265, .mpeg, .wmv, ...)

Background & Context

    • MIME types: video/3gpp, video/H264, video/x-ms-asf,
    • Multimedia container formats.
    • Supports a variety of video and audio codecs.

Import

  • Import["file.ext"] imports a video file and returns a Video object.
  • Import["file.ext",elem] imports the specified element from a video file.
  • The import format can be specified with Import["file","VideoFormat"] or Import["file",{"VideoFormat",elem,}].
  • See the reference pages for full general information on Import.
  • ImportString supports VideoFormat.

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties and settings
  • Video representation elements:
  • "ImageList"frames represented as a list of images
    "Video"video file represented as a Video object
    "VideoData"array of raw bitmap data for each frame
    "VideoStream"a handle to the video file as a VideoStream object
  • Import by default uses the "Video" element.
  • A video file may contain multiple video, audio or subtitle tracks. Elements that return the number of tracks:
  • "AudioTrackCount"number of audio tracks
    "SubtitleTrackCount"number of subtitle tracks
    "VideoTrackCount"number of video tracks
  • Video metadata elements:
  • "BitDepth"bits used to represent each color channel in the file
    "ColorSpace"color encoding used in the file
    "FrameCount"number of frames in the file
    "FrameDurations"list of display durations given for each frame
    "FrameRate"number of frames to be displayed per second
    "RasterSize"raster dimensions
    "VideoEncoding"video codec used in the file
  • Audio related elements:
  • "Audio"in-core Audio object
    "AudioChannels"number of audio channels
    "AudioData"array of audio samples
    "AudioEncoding"audio codec used in the file
    "AudioFile"out-of-core Audio object
    "BitRate"number of bits per second
    "SampleRate"number of audio samples per second
  • Subtitles related elements:
  • "RawASSSubtitles"subtitle data imported as a raw string
    "SubtitleEncoding"subtitle codec used in the file
  • Additional metadata elements:
  • "ExactDurations"an association of exact durations for all video, audio and subtitle tracks
    "Duration"approximate duration of the video given in seconds
    "MetaInformation"metadata interpreted as quantities, locations, dates, numbers, etc.
    "RawMetaInformation"uninterpreted metadata as strings and numbers
  • $VideoDecoders and $AudioDecoders give a list of decoders available on your computer system.

Options

Examples

open allclose all

Basic Examples  (2)

Import a file as a Video object:

Import a summary of a video file:

Scope  (2)

Import a list of video frames:

Import the first 10 seconds of audio data:

Import Elements  (29)

Download a TS file  (1)

Download a TS file:

Available Elements  (1)

List of available elements:

Video Elements  (3)

"Video"  (1)

Import as a Video object:

This is the default import element:

"VideoData"  (1)

Import video data corresponding to specified frames:

Convert video data stored in a NumericArray object to an image:

"VideoStream"  (1)

Import as a VideoStream object:

Play the video stream:

Get the current frame from the stream:

Number of Tracks  (3)

"AudioTrackCount"  (1)

Import the number of audio tracks:

"SubtitleTrackCount"  (1)

Import the number of subtitle tracks:

"VideoTrackCount"  (1)

Import the number of video tracks:

Metadata Elements  (7)

"Duration"  (2)

Import approximate duration of the video:

To import exact track durations, use the "ExactDurations" element:

"ExactDurations"  (2)

Import exact track durations:

Import approximate duration of the video:

Computing an approximate duration is typically much faster than exact durations:

"MetaInformation"  (1)

Import metadata from a video file:

"RawMetaInformation"  (1)

Import unprocessed metadata from a video file:

"Summary"  (1)

Import a summary of a video file:

Video Tracks  (6)

"BitDepth"  (1)

Import the bit depth:

"ColorSpace"  (1)

Import the color space:

"FrameCount"  (1)

Import the number of video frames:

"FrameDurations"  (1)

Import the duration of selected video frames:

QuantityArray is returned when durations of all video frames are requested:

"FrameRate"  (1)

Import video frame rate:

"RasterSize"  (1)

Import raster size of video frames:

Audio Tracks  (6)

"Audio"  (1)

Import Audio from a video file:

"AudioChannels"  (1)

Import the number of audio channels:

"AudioData"  (1)

Import audio data from a video file as a NumericArray:

Convert audio data stored to an Audio object:

"AudioFile"  (1)

Import the out-of-core Audio object:

Note that out-of-core Audio does not hold data in memory. Compare with in-core Audio:

"BitRate"  (1)

Get the bit rate of an audio track:

"SampleRate"  (1)

Get the sample rate of an audio track:

Subtitle Tracks  (2)

"RawASSSubtitles"  (1)

Get raw subtitles from a video file:

None is returned if subtitles are not present.

"SubtitleEncoding"  (1)

Import subtitle encoding:

None is returned if subtitles are not present.

Available subtitle encodings can be extracted using $SubtitleDecoders:

Import Options  (8)

Download a TS file  (1)

Download a TS file:

"AudioChannels"  (1)

By default, all audio channels are imported:

Import the second channel only:

AudioTracks  (1)

By default, Import extracts data only from the first audio track:

Use the AudioTracks option to extract data from specified audio tracks:

"ImageTopOrientation"  (1)

By default, video frames are imported with the native orientation stored in the file:

Specify the side that is supposed to be on the top:

RasterSize  (1)

By default, video frames are imported in their native size:

Specify the raster size of each video frame:

SampleRate  (1)

By default, video frames are imported in their native size:

Specify the sample rate of the imported sound:

SubtitleTracks  (1)

By default, Import extracts data only from the first subtitle track:

Use the SubtitleTracks option to extract data from specified subtitle tracks:

VideoTracks  (1)

By default, Import extracts data only from the first video track:

Use the VideoTracks option to extract data from specified video tracks:

Introduced in 2020
 (12.1)