MP4 (.mp4)
Background & Context

-
- MIME types: video/mp4
- MPEG-4 Part 14 video format.
- Multimedia container format.
- Can contain multiple video, audio and subtitle tracks.
- Extended from QuickTime file format and MPEG-4 Part 12.
- Follows the ISO/IEC 14496-14 standard.
- Commonly referred to as MPEG-4 file format, version 2.
- Commonly used for archiving and exchanging video content.
- Stores audio and video in a format suitable for synchronous playback.
- Binary format.
- Supports a variety of video and audio codecs.
- Developed by ISO in 2001.
Import & Export

- Import["file.mp4"] imports an MP4 file and returns a Video object.
- Import["file.mp4",elem] imports the specified elements.
- The import format can be specified with Import["file","MP4"] or Import["file",{"MP4",elem,…}].
- Export["file.mp4",expr] exports a Video object, list of graphics or images, or a Manipulate expression to the MP4 format.
- Export["file.mp4",{expr1,expr2,…}] exports a list of arbitrary expressions to MP4.
- When exporting a list {expr1,expr2,…}, the video is composed from still pictures corresponding to rasterized images of the expri.
- The duration of the MP4 video is determined from the number of frames and the specified frame rate.
- The exported MP4 video will play at the same speed and will have the same size as the Manipulate object.
- If bookmarks are set in the Manipulate object, Export will create an MP4 file by interpolating between the bookmarks while preserving the speed and duration of the Manipulate.
- Export["file.mp4",{elem1expr1,elem2expr2,…},"Rules"] uses rules to specify the elements to be exported.
- See the reference pages for full general information on Import and Export.
- ImportString and ExportString support the MP4 format.
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 - Audio representation elements:
-
"Audio" in-core Audio object "AudioData" array of audio samples "AudioFile" out-of-core Audio object - Import by default uses the "Video" element if the file has a video track and otherwise uses the "Audio" 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 metadata elements:
-
"AudioChannels" number of audio channels "AudioBitDepth" bits used to represent each audio sample "AudioEncoding" audio codec used in the file "AudioLength" number of audio samples "BitRate" number of bits per second "SampleRate" number of audio samples per second - Subtitle-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 "Summary" summary of the file - $VideoDecoders and $AudioDecoders give a list of decoders available on your computer system.
Options



- General Import options:
-
AudioTrackSelection 1 audio tracks of interest "ImageTopOrientation" Automatic orientation of the video as stored in the file RasterSize Automatic raster dimensions SubtitleTrackSelection 1 subtitle tracks of interest VideoTrackSelection 1 video tracks of interest - Import options for the "Audio" element:
-
"AudioChannels" Automatic number of audio channels SampleRate Automatic samples per second for each channel - General Export options:
-
AudioEncoding Automatic audio encoding for file Background Automatic background color CompressionLevel Automatic compression level to use FrameRate Automatic number of frames shown per second RasterSize Automatic pixel dimensions SampleRate Automatic audio samples per second for each channel SubtitleEncoding Automatic subtitle encoding for file VideoEncoding Automatic video encoding for file - Export options for the "Video" and "VideoStream" elements:
-
AudioTrackSelection All audio tracks of interest SubtitleTrackSelection All subtitle tracks of interest VideoTrackSelection All video tracks of interest "Streamable" Automatic make a video suitable for streaming - Export options when exporting Manipulate expressions:
-
"AnimationDuration" Automatic total animation duration "ControlAppearance" "Generic" how Manipulate control elements are rendered in the exported file - The following settings can be given for "ControlAppearance":
-
Automatic captures user controls exactly as seen in the notebook interface, using the style elements of the local computer system "Generic" renders graphical controls in a generic style None excludes control elements when exporting an animation - $VideoEncoders and $AudioEncoders give a list of encoders available on your computer system.
Examples
open allclose allBasic Examples (4)
Import an MP4 file as a Video object:
Import a video property such as duration:
Import a summary of a video file:
Import an audio-only MP4 file:
Scope (3)
Import a list of video frames:
Import the first 10 seconds of audio data:
Export a Manipulate to MP4:
Import Elements (30)
Video Elements (3)
"Video" (1)
Import as a Video object:
This is the default import element when at least one video track is available:
"VideoData" (1)
Import video data corresponding to specified frames:
Convert video data stored in a NumericArray object to an image:
"VideoStream" (1)
Number of Tracks (3)
Metadata Elements (7)
"Duration" (2)
"ExactDurations" (2)
Video Tracks (7)
"VideoEncoding" (1)
Audio Tracks (7)
Subtitle Tracks (2)
"RawASSSubtitles" (1)
"SubtitleEncoding" (1)
Import Options (8)
AudioTrackSelection (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)
RasterSize (1)
SampleRate (1)
SubtitleTrackSelection (1)
By default, Import extracts data only from the first subtitle track:
Use the SubtitleTracks option to extract data from specified subtitle tracks:
VideoTrackSelection (1)
By default, Import extracts data only from the first video track:
Use the VideoTracks option to extract data from specified video tracks:
Export Options (13)
"AnimationDuration" (1)
Specify the duration of exported Manipulate expressions:
AudioTrackSelection (1)
Background (1)
CompresionLevel (1)
Use the CompressionLevel option to control the file size and the quality of generated video:
"ControlAppearance" (1)
An animation exported with the default setting "ControlAppearance""Generic" will look the same regardless of the computer system on which it was created:
With "ControlAppearance"None, no user controls are included in the exported video:
FrameRate (1)
By default, the frame rate is preserved when exporting Video or VideoStream objects:
RasterSize (1)
By default, the raster size is preserved when exporting Video or VideoStream objects:
SampleRate (1)
By default, the sample rate is preserved when exporting Video, VideoStream or Audio objects: