---
title: "MP4"
language: "en"
type: "Format"
summary: "MIME types: video/mp4"
keywords: 
- MPEG-4
- MPEG-4 Part 14
- multimedia
- video
- animation
- codec
- H.263
- H.264
- Cinepak
- video format
- multimedia format
- mp4
- m4a
- m4p
- m4b
- m4r
- m4v
- DIRAC
- H264
- H264-AVF
- H264-VIDEOTOOLBOX
- HEVC
- HEVC-AVF
- HEVC-VIDEOTOOLBOX
- JPEG2000
- JPEG-AVF
- LIBX264
- LIBX264RGB
- LIBXVID
- MJPEG
- MPEG1VIDEO
- MPEG2VIDEO
- MPEG4
- MPEGVIDEO
- PNG
- TSCC2
- VC1
- VC2
- VP9
canonical_url: "https://reference.wolfram.com/language/ref/format/MP4.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Video Processing"
    link: "https://reference.wolfram.com/language/guide/VideoProcessing.en.md"
  - 
    title: "Importing & Exporting"
    link: "https://reference.wolfram.com/language/guide/ImportingAndExporting.en.md"
  - 
    title: "Listing of All Formats"
    link: "https://reference.wolfram.com/language/guide/ListingOfAllFormats.en.md"
  - 
    title: "Multimedia Formats"
    link: "https://reference.wolfram.com/language/guide/MultimediaFormats.en.md"
  - 
    title: "Web Formats"
    link: "https://reference.wolfram.com/language/guide/WebFormats.en.md"
related_tutorials: 
  - 
    title: "Importing and Exporting Video"
    link: "https://reference.wolfram.com/language/tutorial/ImportingAndExportingVideo.en.md"
---
# MP4 (.mp4, .m4a, ...) 	[image]

``Import`` and ``Export`` fully support the MP4 format.

Common list of MP4 extensions includes: .mp4, .m4a, .m4p, .m4b, .m4r and .m4v.

## 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, …}]``.

Supported video decoders are listed in ``\$VideoDecoders``.

---

``Export["file.mp4", expr]`` exports ``expr`` to the MP4 format.

The following expressions can be exported to an MP4:

|                   |                                                        |
| ----------------- | ------------------------------------------------------ |
| video             | an arbitrary Video object                              |
| AnimatedImage[…]  | frames of an AnimatedImage object                      |
| Manipulate[…]     | frames generated from a Manipulate expression          |
| {expr1, expr2, …} | a list of images or graphics or rasterized expressions |

When exporting a list of arbitrary expressions, each expression is rasterized and has the same raster size as its displayed form.

The duration of the MP4 video is determined from the number of frames and the specified frame rate.

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", {elem1 -> expr1, elem2 -> expr2, …}, "Rules"]`` uses rules to specify the elements to be exported.

Supported video encoders are listed in ``\$VideoEncoders``.

---

See the following reference pages for full general information:

|                                  |                                         |
| -------------------------------- | --------------------------------------- |
| Import, Export                   | import from or export to a file         |
| CloudImport, CloudExport         | import from or export to a cloud object |
| ImportString, ExportString       | import from or export to a string       |
| ImportByteArray, ExportByteArray | import from or export to a byte array   |

## Import Elements

General ``Import`` elements:

|             |                                                     |
| ----------- | --------------------------------------------------- |
| "Elements"  | list of elements and options available in this file |
| "Summary"   | summary of the file                                 |
| "Rules"     | list of rules for all available elements            |

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"   | \[AliasDelimiter]\[AliasDelimiter]number of audio samples                |
| "BitRate"       | number of bits per second                |
| "SampleRate"    | number of audio samples per second       |

Subtitle-related elements:

|                       |                                                                                     |
| --------------------- | ----------------------------------------------------------------------------------- |
| "RawSubtitle"         | subtitle data imported as a raw string                                              |
| "SubtitleRules"       | returned as a list of styled text in the form of {int1 -> text1, int2 -> text2, …}    |
| "SubtitleString"      | returned as a single string of concatenated subtitle texts                          |
| "SubtitleStringRules" | returned as a list of plaintext in the form of {int1 -> string1, int2 -> string2, …}  |
| "SubtitleEncoding"    | subtitle codec used in the file                                                     |

Additional metadata elements:

|                       |                                                                                      |
| --------------------- | ------------------------------------------------------------------------------------ |
| "ExactDurations"      | an association of exact durations for all video, audio and subtitle tracks           |
| "ExactTimeBoundaries" | an association of exact start and end times 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                                                                  |
| "TrackStartTimes"     | an association of start times for each track                                         |

``\$VideoDecoders`` and ``\$AudioDecoders`` give a list of decoders available on your computer system.

Export Elements

``Export["file.mp4", {elem1 -> expr1, …}, "Rules"]`` uses rules to specify the elements to be exported.

Available ``Export`` elements:

|          |                                                                       |
| -------- | --------------------------------------------------------------------- |
| "Audio"  | an audio track                                                        |
| "Frames" | video frames provided as a list, a Manipulate or AnimatedImage object |

## 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 |

``Import`` and ``Export`` option:

[`IncludeMetaInformation`](https://reference.wolfram.com/language/ref/IncludeMetaInformation.en.md)	[`All`](https://reference.wolfram.com/language/ref/All.en.md)	metadata types to import and export

Supported ``IncludeMetaInformation`` settings are: ``"M4A"``, ``"RawM4A"``, ``All`` and ``None``.

General ``Export`` options:

|                   |           |                                            |
| ----------------- | --------- | ------------------------------------------ |
| AudioEncoding     | Automatic | audio encoding for file                    |
| Background        | Automatic | background color                           |
| BitRate           | Automatic | approximate bit rate to use                |
| CompressionLevel  | Automatic | compression level to use                   |
| FrameRate         | Automatic | number of frames shown per second          |
| MetaInformation   | Automatic | metadata to export                         |
| 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                    |
| VideoTransparency | False     | whether to export the transparency channel |

``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" | Automatic | 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 |
| None | excludes control elements when exporting an animation |
| "Generic" | renders graphical controls in a generic style  |

``\$VideoEncoders`` and ``\$AudioEncoders`` give a list of encoders available on your computer system.

---

## Examples (77)

### Basic Examples (4)

Import an MP4 file as a ``Video`` object:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4"]

Out[1]= \!\(\*VideoBox[...]\)
```

Import a video property such as duration:

```wl
In[2]:= Import["ExampleData/Caminandes.mp4", "Duration"]

Out[2]= Quantity[MixedMagnitude[{1, 30.023}], MixedUnit[{"Minutes", "Seconds"}]]
```

---

Import a summary of a video file:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "Elements"]

Out[1]=
Dataset[Association["Format" -> "MP4", "SampleFrame" -> 
   Image[CompressedData["«38445»"], 
    "Byte", ColorSpace -> "RGB", Interleaving -> True], 
  "Duration" -> Quantity[MixedMagnitude[{1, 30.022999999999996}], 
    MixedUnit[{"Minutes", "Sec ... , "RasterSize" -> {852, 480}, 
  "FrameRate" -> Quantity[24, "Frames"/"Seconds"], "AudioEncoding" -> "AAC", 
  "SampleRate" -> Quantity[44100, "Samples"/"Seconds"], "FileName" -> "Caminandes.mp4", 
  "FileSize" -> Quantity[6.524641, "Megabytes"]]]
```

---

Import an audio-only MP4 file:

```wl
In[1]:= Import["ExampleData/dialing.m4a"]

Out[1]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-kbwev)"]\)
```

---

Export a ``Video`` object to an MP4:

```wl
In[1]:= Export["file.mp4", Video["ExampleData/bullfinch.mkv"]]

Out[1]= "file.mp4"
```

### Scope (6)

#### Import (2)

Import a list of video frames:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", {"ImageList", {100, 200}}]

Out[1]= [image]
```

---

Import the first 10 seconds of audio data:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", {"Audio", Quantity[0, "Seconds"] ;; Quantity[10, "Seconds"]}]

Out[1]= [image]
```

#### Export (4)

Export a list of images to MP4:

```wl
In[1]:= t = Table[ImageTransformation[[image], n Floor[# / n] + 1&, DataRange -> Full], {n, 1, 30}];

In[2]:= Export["mosaic.mp4", t, FrameRate -> 15]

Out[2]= "mosaic.mp4"
```

Get three frames from the video:

```wl
In[3]:= VideoFrameList[Video["mosaic.mp4"], 3]

Out[3]= {[image], [image], [image]}
```

---

Export a ``Manipulate`` to MP4:

```wl
In[1]:= m = Manipulate[Graphics[{Red, Disk[{0, 0}, r]}, PlotRange -> {{-1, 1}, {-1, 1}}, Background -> Black, ImageSize -> 100], {r, 1, 0}];

In[2]:= Export["file.mp4", m]

Out[2]= "file.mp4"
```

Summary of the exported file:

```wl
In[3]:= Import["file.mp4", "Summary"]

Out[3]=
Dataset[Association["Format" -> "MP4", "SampleFrame" -> 
   Image[CompressedData["«4879»"], "Byte", ColorSpace -> "RGB", 
    Interleaving -> True], "Duration" -> Quantity[4., "Seconds"], "VideoEncoding" -> "H264", 
  "RasterSize" -> {482, 382}, "FrameRate" -> Quantity[15, "Frames"/"Seconds"], 
  "FileName" -> "file.mp4", "FileSize" -> Quantity[15.58, "Kilobytes"]]]
```

---

Export an ``AnimatedImage`` object:

```wl
In[1]:= Export["file.mp4", AnimatedImage["ExampleData/pearls.png"]]

Out[1]= "file.mp4"

In[2]:= Import["file.mp4", "Summary"]

Out[2]=
Dataset[Association["SampleFrame" -> Image[CompressedData["«42507»"], "Byte", ColorSpace -> "RGB", 
    Interleaving -> True], "Format" -> "MP4", "Duration" -> Quantity[1.883, "Seconds"], 
  "VideoEncoding" -> "H264", "RasterSize" -> {150, 150}, 
  "FrameRate" -> Quantity[17, "Frames"/"Seconds"], "FileName" -> "file.mp4", 
  "FileSize" -> Quantity[33.012, "Kilobytes"]]]
```

---

Export a ``Manipulate`` with audio:

```wl
In[1]:= m = Manipulate[Graphics[{Red, Disk[{0, 0}, r]}, PlotRange -> {{-1, 1}, {-1, 1}}, Background -> Black, ImageSize -> 100], {r, 1, 0}];

In[2]:= a = ExampleData[{"Audio", "Drums"}];

In[3]:= Export["file.mp4", {"Frames" -> m, "Audio" -> a}, "Rules", {...}]

Out[3]= "file.mp4"
```

Summary of the exported file:

```wl
In[4]:= Import["file.mp4", "Summary"]

Out[4]=
Dataset[Association["SampleFrame" -> Image[CompressedData["«7231»"], "Byte", ColorSpace -> "RGB", Interleaving -> True], "Format" -> "MP4", 
  "Duration" -> Quantity[4.749, "Seconds"], "VideoEncoding" -> "H264", "RasterSize" -> {240, 246}, 
  "FrameRate" -> Quantity[15, "Frames"/"Seconds"], "AudioEncoding" -> "AAC", 
  "SampleRate" -> Quantity[44100, "Samples"/"Seconds"], "FileName" -> "file.mp4", 
  "FileSize" -> Quantity[92.033, "Kilobytes"]]]
```

### Import Elements (33)

#### Available Elements (1)

List of available elements:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "Elements"]

Out[1]= {"Audio", "AudioChannels", "AudioData", "AudioEncoding", "AudioFile", "AudioTrackCount", "BitDepth", "BitRate", "ColorSpace", "Duration", "ExactDurations", "FrameCount", "FrameDurations", "FrameRate", "ImageList", "MetaInformation", "RasterSize", "RawASSSubtitles", "RawMetaInformation", "SampleRate", "SubtitleEncoding", "SubtitleTrackCount", "Summary", "Video", "VideoData", "VideoEncoding", "VideoStream", "VideoTrackCount"}
```

#### Video Elements (3)

##### "Video" (1)

---

Import as a ``Video`` object:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "Video"]

Out[1]= [image]
```

This is the default import element when at least one video track is available:

```wl
In[2]:= Import["ExampleData/Caminandes.mp4"]

Out[2]= [image]
```

##### "VideoData" (1)

---

Import video data corresponding to specified frames:

```wl
In[1]:= data = Import["ExampleData/Caminandes.mp4", {"VideoData", {100, 200}}]

Out[1]= {NumericArray[<480,852,3>, UnsignedInteger8], NumericArray[<480,852,3>, UnsignedInteger8]}
```

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

```wl
In[2]:= Image /@ data

Out[2]= [image]
```

##### "VideoStream" (1)

---

Import as a ``VideoStream`` object:

```wl
In[1]:= str = Import["ExampleData/Caminandes.mp4", "VideoStream"]

Out[1]= [image]
```

Play the video stream:

```wl
In[2]:= VideoPlay[str]

Out[2]= [image]
```

Get the current frame from the stream:

```wl
In[3]:= str["CurrentFrame"]

Out[3]= [image]
```

#### Number of Tracks (3)

##### "AudioTrackCount" (1)

---

Import the number of audio tracks:

```wl
In[1]:= Import["http://exampledata.wolfram.com/agent327.mp4", "AudioTrackCount"]

Out[1]= 1
```

##### "SubtitleTrackCount" (1)

---

Import the number of subtitle tracks:

```wl
In[1]:= Import["http://exampledata.wolfram.com/agent327.mp4", "SubtitleTrackCount"]

Out[1]= 2
```

##### "VideoTrackCount" (1)

---

Import the number of video tracks:

```wl
In[1]:= Import["http://exampledata.wolfram.com/agent327.mp4", "VideoTrackCount"]

Out[1]= 1
```

#### Metadata Elements (7)

##### "Duration" (2)

---

Import approximate duration of the video:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "Duration"]

Out[1]= Quantity[MixedMagnitude[{1, 30.023}], MixedUnit[{"Minutes", "Seconds"}]]
```

---

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

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "ExactDurations"]

Out[1]= <|"Video" -> Quantity[MixedMagnitude[{1, 30.}], MixedUnit[{"Minutes", "Seconds"}]], "Audio" -> Quantity[MixedMagnitude[{1, 30.0252}], MixedUnit[{"Minutes", "Seconds"}]]|>
```

##### "ExactDurations" (2)

---

Import exact track durations:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "ExactDurations"]

Out[1]= <|"Video" -> Quantity[MixedMagnitude[{1, 30.}], MixedUnit[{"Minutes", "Seconds"}]], "Audio" -> Quantity[MixedMagnitude[{1, 30.0934}], MixedUnit[{"Minutes", "Seconds"}]]|>
```

---

Import approximate duration of the video:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "Duration"]

Out[1]= Quantity[MixedMagnitude[{1, 30.023}], MixedUnit[{"Minutes", "Seconds"}]]
```

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

```wl
In[2]:= RepeatedTiming[Import["ExampleData/Caminandes.mp4", #]][[1]]& /@ {"Duration", "ExactDurations"}

Out[2]= {0.0177871, 0.987467}
```

##### "MetaInformation" (1)

---

Import metadata from a video file:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "MetaInformation"]//Dataset

Out[1]=
Dataset[Association["MajorBrand" -> "mp42", "MinorVersion" -> "1", 
  "CompatibleBrands" -> "isommp41mp42", "CreationTime" -> DateObject[{2020, 3, 30, 20, 39, 51.}, 
    "Instant", "Gregorian", "UTC"], "ApproximateFrameCount" -> 2161, 
  "ResourceP ...        DateObject[{2020, 3, 30, 20, 39, 51.}, "Instant", "Gregorian", "UTC"], "AudioChannels" -> 2, 
      "SampleRate" -> Quantity[44100, "Samples"/"Seconds"], "AudioEncoding" -> "AAC", 
      "SampleFormat" -> "Real32", "AudioBitDepth" -> 32]]]]
```

##### "RawMetaInformation" (1)

---

Import unprocessed metadata from a video file:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "RawMetaInformation"]//Dataset

Out[1]=
Dataset[Association["MajorBrand" -> "mp42", "MinorVersion" -> "1", 
  "CompatibleBrands" -> "isommp41mp42", "CreationTime" -> "2020-03-30T20:39:51.000000Z", 
  "ApproximateFrameCount" -> 2161, "ResourcePath" -> "C:\\Program Files\\Wolfram \
Researc ... ciation[1 -> Association["CreationTime" -> "2020-03-30T20:39:51.000000Z", 
      "AudioChannels" -> 2, "SampleRate" -> 44100, "AudioEncoding" -> "aac", 
      "SampleFormat" -> "Real32", "AudioBitDepth" -> 32]], "SubtitleTracks" -> Association[]]]
```

##### "Summary" (1)

---

Import a summary of a video file:

```wl
In[1]:= Import["http://exampledata.wolfram.com/agent327.mp4", "Summary"]

Out[1]=
Dataset[Association["Format" -> "MP4", "SampleFrame" -> 
   Image[CompressedData["«33927»"], "Byte", ColorSpace -> "RGB", Interleaving -> True], 
  "Duration" -> Quantity[MixedMagnitude[{3, 51.504999999999995}], 
    MixedUnit[{"Minutes", "Seconds" ... y[24, "Frames"/"Seconds"], 
  "AudioEncoding" -> "MP3FLOAT", "SampleRate" -> Quantity[44100, "Samples"/"Seconds"], 
  "SubtitleEncoding" -> {"MOV-TEXT", "MOV-TEXT"}, "FileName" -> "agent327.mp4", 
  "FileSize" -> Quantity[12.898981, "Megabytes"]]]
```

#### Video Tracks (7)

##### "BitDepth" (1)

---

Import the bit depth:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "BitDepth"]

Out[1]= 8
```

##### "ColorSpace" (1)

---

Import the color space:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "ColorSpace"]

Out[1]= "RGB"
```

##### "FrameCount" (1)

---

Import the number of video frames:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "FrameCount"]

Out[1]= 2160
```

##### "FrameDurations" (1)

---

Import the duration of selected video frames:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", {"FrameDurations", {1, 10, 100}}]

Out[1]=
QuantityArray[StructuredArray`StructuredData[{3}, 
  {{Rational[1, 24], Rational[1, 24], Rational[1, 24]}, "Seconds", {{1}}}]]

In[2]:= Normal[%]

Out[2]= {Quantity[1/24, "Seconds"], Quantity[1/24, "Seconds"], Quantity[1/24, "Seconds"]}
```

##### "FrameRate" (1)

---

Import video frame rate:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "FrameRate"]

Out[1]= Quantity[24, "Frames"/"Seconds"]
```

##### "RasterSize" (1)

---

Import raster size of video frames:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "RasterSize"]

Out[1]= {852, 480}
```

##### "VideoEncoding" (1)

---

Import video codec:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "VideoEncoding"]

Out[1]= "H264"
```

Supported decoders on each platform can be extracted using ``\$VideoDecoders`` :

```wl
In[2]:= $VideoDecoders["MP4"][[All, 1]]

Out[2]= {"DIRAC", "H264", "H264-AVF", "H264-VIDEOTOOLBOX", "HEVC", "HEVC-AVF", "HEVC-VIDEOTOOLBOX", "JPEG2000", "JPEG-AVF", "LIBAOM-AV1", "LIBOPENJPEG", "LIBVPX-VP9", "MJPEG", "MPEG1VIDEO", "MPEG2VIDEO", "MPEG4", "MPEGVIDEO", "PNG", "TSCC2", "VC1", "VP9"}
```

#### Audio Tracks (7)

##### "Audio" (1)

---

Import ``Audio`` from an MP4 file:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "Audio"]

Out[1]= [image]
```

##### "AudioChannels" (1)

---

Import the number of audio channels:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "AudioChannels"]

Out[1]= 2
```

##### "AudioData" (1)

---

Import audio data from an MP4 file as a ``NumericArray`` :

```wl
In[1]:= data = Import["ExampleData/Caminandes.mp4", "AudioData"]

Out[1]= NumericArray[<2,3973120>, Integer16]
```

Convert audio data stored to an ``Audio`` object:

```wl
In[2]:= Audio[data]

Out[2]= [image]
```

##### "AudioEncoding" (1)

---

Import audio encoding:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "AudioEncoding"]

Out[1]= "AAC-MF"
```

Available audio decoders can be extracted from ``\$AudioDecoders`` :

```wl
In[2]:= $AudioDecoders["MP4"][[All, 1]]

Out[2]= {"AAC", "AAC-AT", "AAC-AVF", "AAC-FIXED", "AC3", "AC3-AT", "AC3-FIXED", "ALS", "DCA", "EAC3", "EAC3-AT", "EVRC", "FLAC", "LIBOPUS", "LIBVORBIS", "MP2", "MP2-AT", "MP2FLOAT", "MP3", "MP3-AT", "MP3FLOAT", "OPUS", "QCELP", "VORBIS"}
```

##### "AudioFile" (1)

---

Import the out-of-core ``Audio`` object:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "AudioFile"]

Out[1]= [image]
```

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

```wl
In[2]:= ByteCount[Import["ExampleData/Caminandes.mp4", #]]& /@ {"Audio", "AudioFile"}

Out[2]= {31763016, 1344}
```

##### "BitRate" (1)

---

Get the bit rate of an audio track:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "BitRate"]

Out[1]= Quantity[579814, "Bits"/"Seconds"]
```

##### "SampleRate" (1)

---

Get the sample rate of an audio track:

```wl
In[1]:= Import["ExampleData/Caminandes.mp4", "SampleRate"]

Out[1]= Quantity[44100, "Samples"/"Seconds"]
```

#### Subtitle Tracks (5)

##### "RawSubtitle" (1)

---

Get raw subtitles from an MP4 file:

```wl
In[1]:= Import["http://exampledata.wolfram.com/agent327.mp4", "RawSubtitle"]//Dataset

Out[1]=
Dataset[Association["HeaderData" -> "[Script Info]\n\n; Script generated by \
FFmpeg/Lavc61.3.100\n\nScriptType: v4.00+\n\nPlayResX: 384\n\nPlayResY: \
288\n\nScaledBorderAndShadow: yes\n\nYCbCr Matrix: None\n\n\n\n[V4+ Styles]\n\nFormat: Name, \
F ... r", "Type" -> "ASS", 
     "Timestamp" -> Rational[4496, 25], "Duration" -> Rational[5, 2]], 
    Association["Text" -> "15,0,Default,,0,0,0,,Agent 327!", "Type" -> "ASS", 
     "Timestamp" -> Rational[4571, 25], "Duration" -> Rational[62, 25]]}]]
```

``None`` is returned if subtitles are not present:

```wl
In[2]:= Import["ExampleData/Caminandes.mp4", "RawSubtitle"]

Out[2]= None
```

##### "SubtitleEncoding" (1)

---

Import subtitle encoding:

```wl
In[1]:= Import["http://exampledata.wolfram.com/agent327.mp4", "SubtitleEncoding"]

Out[1]= "MOV-TEXT"
```

Available subtitle encodings can be extracted using ``\$SubtitleDecoders`` :

```wl
In[2]:= $SubtitleDecoders["MP4"][[All, 1]]

Out[2]= {"MOV-TEXT"}
```

##### "SubtitleRules" (1)

---

Get subtitles as a list of styled text:

```wl
In[1]:= Import["http://exampledata.wolfram.com/agent327.mp4", "SubtitleRules"]//Short

Out[1]//Short= {Quantity[Interval[{12.719999999999999, 15.120000000000001}], "Seconds"] -> Text["This is 327, I'm going in", {Center, 10}, {0, -1}, {1, 0}], Quantity[Interval[{15.299999999999999, 16.080000000000002}], "Seconds"] -> «1», «12», Quantity[Interval[{179.83999999999997, 182.34000000000003}], "Seconds"] -> «1», Quantity[Interval[{182.83999999999997, 185.32000000000002}], "Seconds"] -> Text[«1»]}
```

``None`` is returned if subtitles are not present:

```wl
In[2]:= Import["ExampleData/Caminandes.mp4", "SubtitleRules"]

Out[2]= None
```

##### "SubtitleString" (1)

---

Get subtitles as a single string:

```wl
In[1]:= Import["http://exampledata.wolfram.com/agent327.mp4", "SubtitleString"]//Short

Out[1]//Short=
"This is 327, I'm going in

Good luck, Age"…"dure

We have to make room for

Agent 327!"
```

``None`` is returned if subtitles are not present:

```wl
In[2]:= Import["ExampleData/Caminandes.mp4", "SubtitleString"]

Out[2]= None
```

##### "SubtitleStringRules" (1)

---

Get subtitles as a list of plaintext:

```wl
In[1]:= Import["http://exampledata.wolfram.com/agent327.mp4", "SubtitleStringRules"]//Short

Out[1]//Short= {Quantity[Interval[{12.719999999999999, 15.120000000000001}], "Seconds"] -> "This is 327, I'm going in", Quantity[Interval[{15.299999999999999, 16.080000000000002}], "Seconds"] -> "Good luck, Agent", «13», Quantity[Interval[{182.83999999999997, 185.32000000000002}], "Seconds"] -> "Agent 327!"}
```

``None`` is returned if subtitles are not present:

```wl
In[2]:= Import["ExampleData/Caminandes.mp4", "SubtitleStringRules"]

Out[2]= None
```

### Import Options (11)

#### Generate a Multitrack MP4 (1)

Generate a multitrack MP4 file:

```wl
In[1]:= FileConvert["ExampleData/bullfinch.mkv" -> "bullfinch.mp4"]

Out[1]= File["bullfinch.mp4"]

In[2]:= Import["bullfinch.mp4", "Summary"]

Out[2]=
Dataset[Association["Format" -> "MP4", "SampleFrame" -> 
   Image[CompressedData["«48127»"], "Byte", 
    ColorSpace -> "RGB", Interleaving -> True], "Duration" -> Quantity[15.021, "Seconds"], 
  "VideoEncoding" -> "H264", "RasterSize" -> {640, 360 ... 00, "Samples"/"Seconds"], Quantity[44100, "Samples"/"Seconds"], 
    Quantity[44100, "Samples"/"Seconds"]}, "SubtitleEncoding" -> {"MOV-TEXT", "MOV-TEXT"}, 
  "FileName" -> "bullfinch.mp4", "FileSize" -> Quantity[1.4223999999999999, "Megabytes"]]]
```

#### "AudioChannels" (1)

By default, all audio channels are imported:

```wl
In[1]:= AudioChannels[Import["bullfinch.mp4", "Audio"]]

Out[1]= 2
```

Import the second channel only:

```wl
In[2]:= AudioChannels[Import["bullfinch.mp4", "Audio", "AudioChannels" -> {2}]]

Out[2]= 1
```

#### AudioTrackSelection (1)

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

```wl
In[1]:= Import["bullfinch.mp4", {{"SampleRate", "AudioChannels"}}]

Out[1]= {Quantity[48000, "Samples"/"Seconds"], 2}
```

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

```wl
In[2]:= Import["bullfinch.mp4", {{"SampleRate", "AudioChannels"}}, AudioTrackSelection -> {1, 2}]

Out[2]= {<|1 -> Quantity[48000, "Samples"/"Seconds"], 2 -> Quantity[44100, "Samples"/"Seconds"]|>, <|1 -> 2, 2 -> 1|>}
```

#### "ImageTopOrientation" (1)

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

```wl
In[1]:= Import["bullfinch.mp4", {"ImageList", {100, 300}}]

Out[1]= [image]
```

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

```wl
In[2]:= Import["bullfinch.mp4", {"ImageList", {100, 300}}, "ImageTopOrientation" -> Right]

Out[2]= {[image], [image]}
```

#### IncludeMetaInformation (3)

By default, all available metadata is imported:

```wl
In[1]:= Options[Import["ExampleData/dialing.m4a", "Audio"], MetaInformation]

Out[1]= {MetaInformation -> <|"M4A" -> <|"PartOfCompilation" -> False, "CreationDate" -> {DateObject[{2008}, "Year", "Gregorian", 2.]}, "Title" -> {"TestTitle"}|>|>}
```

---

Avoid importing any metadata:

```wl
In[1]:= Options[Import["ExampleData/dialing.m4a", "Audio", IncludeMetaInformation -> None], MetaInformation]

Out[1]= {MetaInformation -> <||>}
```

---

Import only specified classes of metadata:

```wl
In[1]:= Options[Import["ExampleData/dialing.m4a", "Audio", IncludeMetaInformation -> {"RawM4A"}], MetaInformation]

Out[1]= {MetaInformation -> <|"M4A" -> <|"cpil" -> False, "©day" -> {"2008"}, "©nam" -> {"TestTitle"}|>|>}
```

#### RasterSize (1)

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

```wl
In[1]:= Import["bullfinch.mp4", {"ImageList", 100}][[1]]//ImageDimensions

Out[1]= {640, 360}
```

Specify the raster size of each video frame:

```wl
In[2]:= Import["bullfinch.mp4", {"ImageList", 100}, RasterSize -> 50][[1]]//ImageDimensions

Out[2]= {50, 28}
```

#### SampleRate (1)

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

```wl
In[1]:= Options[Import["bullfinch.mp4", "Audio"], SampleRate]

Out[1]= {SampleRate -> 48000}
```

Specify the sample rate of the imported sound:

```wl
In[2]:= Options[Import["bullfinch.mp4", "Audio", SampleRate -> 22050], SampleRate]

Out[2]= {SampleRate -> 22050}
```

#### SubtitleTrackSelection (1)

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

```wl
In[1]:= Import["bullfinch.mp4", "RawSubtitle"]//Dataset

Out[1]=
Dataset[Association["HeaderData" -> "[Script Info]\n\n; Script generated by \
FFmpeg/Lavc60.3.100\n\nScriptType: v4.00+\n\nPlayResX: 384\n\nPlayResY: \
288\n\nScaledBorderAndShadow: yes\n\nYCbCr Matrix: None\n\n\n\n[V4+ Styles]\n\nFormat: Name, \
F ... ational[1016, 125], "Duration" -> Rational[279, 100]], 
    Association["Text" -> "3,0,Default,,0,0,0,,but females and young birds have grey underparts.", 
     "Type" -> "ASS", "Timestamp" -> Rational[5459, 500], "Duration" -> Rational[27, 8]]}]]
```

Use the ``SubtitleTrackSelection`` option to extract data from specified subtitle tracks:

```wl
In[2]:= Import["bullfinch.mp4", "RawSubtitle", SubtitleTrackSelection -> {1, 2}]//Dataset

Out[2]=
Dataset[Association[1 -> Association["HeaderData" -> "[Script Info]\n\n; Script generated by \
FFmpeg/Lavc60.3.100\n\nScriptType: v4.00+\n\nPlayResX: 384\n\nPlayResY: \
288\n\nScaledBorderAndShadow: yes\n\nYCbCr Matrix: None\n\n\n\n[V4+ Styles]\n\n ... ]], 
      Association["Text" -> "2,0,Default,,0,0,0,,Das erwachsene Männchen hat eine rote, das \
Weibchen und der Jungvogel eine graue Unterseite.", "Type" -> "ASS", 
       "Timestamp" -> Rational[9503, 1000], "Duration" -> Rational[11, 2]]}]]]
```

#### VideoTrackSelection (1)

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

```wl
In[1]:= Import["bullfinch.mp4", {{"FrameRate", "RasterSize"}}]

Out[1]= {Quantity[30, "Frames"/"Seconds"], {640, 360}}
```

Use the ``VideoTrackSelection`` option to extract data from specified video tracks:

```wl
In[2]:= Import["bullfinch.mp4", {{"FrameRate", "RasterSize"}}, VideoTrackSelection -> {1}]

Out[2]= {<|1 -> Quantity[30, "Frames"/"Seconds"]|>, <|1 -> {640, 360}|>}
```

### Export Options (23)

#### "AnimationDuration" (1)

Specify the duration of exported ``Manipulate`` expressions:

```wl
In[1]:= animation = Manipulate[Plot3D[Sin[x y + a], {x, 0, 3}, {y, 0, 3}, Mesh -> False, Boxed -> False, Axes -> None, ColorFunction -> "IslandColors"], {a, 0, 2 Pi}];

In[2]:= Export["test.mp4", animation, "AnimationDuration" -> 7]

Out[2]= "test.mp4"

In[3]:= Import[%, "ExactDurations"]

Out[3]= <|"Video" -> Quantity[7., "Seconds"]|>
```

#### AudioEncoding (1)

Specify the encoding of exported audio:

```wl
In[1]:= Export["test.mp4", Video["ExampleData/bullfinch.mkv"], AudioEncoding -> "LIBMP3LAME"]

Out[1]= "test.mp4"

In[2]:= Import[%, "AudioEncoding"]

Out[2]= "MP3FLOAT"
```

#### AudioTrackSelection (1)

By default, all audio tracks are exported:

```wl
In[1]:= Export["test.mp4", Video["ExampleData/bullfinch.mkv"]]

Out[1]= "test.mp4"

In[2]:= Import[%, "AudioTrackCount"]

Out[2]= 3
```

Specify the audio tracks to export:

```wl
In[3]:= Export["test.mp4", Video["ExampleData/bullfinch.mkv"], AudioTrackSelection -> {1, 2}]

Out[3]= "test.mp4"

In[4]:= Import[%, "AudioTrackCount"]

Out[4]= 2
```

Export no audio track:

```wl
In[5]:= Export["test.mp4", Video["ExampleData/bullfinch.mkv"], AudioTrackSelection -> None]

Out[5]= "test.mp4"

In[6]:= Import[%, "AudioTrackCount"]

Out[6]= 0
```

#### Background (1)

By default, a white background is used for transparent graphics and images and also when images of different sizes are padded before export:

```wl
In[1]:= list = {[image], [image], [image]};

In[2]:= Export["test.mp4", list]

Out[2]= "test.mp4"

In[3]:= Import[%, "ImageList"]

Out[3]= {[image], [image], [image]}
```

Specify a different padding:

```wl
In[4]:= Export["test.mp4", list, Background -> Blue]

Out[4]= "test.mp4"

In[5]:= Import[%, "ImageList"]

Out[5]= {[image], [image], [image]}
```

#### BitRate (4)

By default, automatic bit rate is used when exporting to video files:

```wl
In[1]:= Export["test.mp4", Video["ExampleData/bullfinch.mkv"]];
```

Check an overall approximate bit rate:

```wl
In[2]:= Import["test.mp4", "BitRate"]

Out[2]= Quantity[920244, "Bits"/"Seconds"]
```

---

Suggest an approximate bit rate:

```wl
In[1]:= Export["test.mp4", Video["ExampleData/bullfinch.mkv"], BitRate -> Quantity[500, "Kilobits"/"Seconds"]];
```

Check the approximate bit rate that might slightly differ from the suggested one:

```wl
In[2]:= Import["test.mp4", "BitRate"]

Out[2]= Quantity[756703, "Bits"/"Seconds"]
```

---

Separately specify the approximate video and audio bit rates:

```wl
In[1]:=
vrate = Quantity[500, "Kilobits"/"Seconds"];
arate = Quantity[50, "Kilobits"/"Seconds"];
Export["test.mp4", Video["ExampleData/bullfinch.mkv"], BitRate -> {vrate, arate}];
```

Check an overall approximate bit rate:

```wl
In[2]:= Import["test.mp4", "BitRate"]

Out[2]= Quantity[642990, "Bits"/"Seconds"]
```

---

Smaller bit rate results in smaller file size but also lowers the quality of the generated video:

```wl
In[1]:= FileSize[Export["test.mp4", Video["ExampleData/bullfinch.mkv"], BitRate -> #]]& /@ {Quantity[500, "Kilobits"/"Seconds"], Quantity[300, "Kilobits"/"Seconds"], Quantity[100, "Kilobits"/"Seconds"]}

Out[1]= {Quantity[1.420839, "Megabytes"], Quantity[1.058501, "Megabytes"], Quantity[0.702696, "Megabytes"]}
```

#### CompresionLevel (2)

Use the ``CompressionLevel`` option to control the file size and the quality of generated video:

```wl
In[1]:= FileSize[Export["test.mp4", Video["ExampleData/bullfinch.mkv"], CompressionLevel -> #]]& /@ {0.2, 0.5, 0.8}

Out[1]= {Quantity[2.901885, "Megabytes"], Quantity[0.83648, "Megabytes"], Quantity[0.6286229999999999, "Megabytes"]}
```

---

When ``BitRate`` for both video and audio is specified, the value of ``CompressionLevel`` is ignored:

```wl
In[1]:= FileSize[Export["test.mp4", Video["ExampleData/bullfinch.mkv"], BitRate -> {500000, 50000}, CompressionLevel -> 1]]

Out[1]= Quantity[1.207455, "Megabytes"]

In[2]:= FileSize[Export["test.mp4", Video["ExampleData/bullfinch.mkv"], BitRate -> {500000, 50000}, CompressionLevel -> 0]]

Out[2]= Quantity[1.207455, "Megabytes"]
```

#### "ControlAppearance" (1)

An animation exported with the default setting ``"ControlAppearance" -> Automatic`` will look different depending on the computer system on which it was created:

```wl
In[1]:= animation = Manipulate[Plot3D[Sin[x y + a], {x, 0, 3}, {y, 0, 3}, Mesh -> False, Boxed -> False, Axes -> None, ColorFunction -> "IslandColors"], {a, 0, 2 Pi}];

In[2]:= Export["test.mp4", animation]

Out[2]= "test.mp4"

In[3]:= Import[%, {"ImageList", {1, 2}}]

Out[3]= [image]
```

With ``"ControlAppearance" -> None``, no user controls are included in the exported video:

```wl
In[4]:= Export["test.mp4", animation, "ControlAppearance" -> None]

Out[4]= "test.mp4"

In[5]:= Import[%, {"ImageList", {1, 2}}]

Out[5]= [image]
```

#### FrameRate (1)

By default, the frame rate is preserved when exporting ``Video`` or ``VideoStream`` objects:

```wl
In[1]:= video  = Video["ExampleData/caminandes.mp4"];

In[2]:= Export["test.mp4", video]

Out[2]= "test.mp4"

In[3]:= {Information[video]["VideoTracks"][1]["FrameRate"], Import[%, "FrameRate"]}

Out[3]= {Quantity[24, "Frames"/"Seconds"], Quantity[24, "Frames"/"Seconds"]}
```

Specify a different frame rate:

```wl
In[4]:= Export["test.mp4", video, FrameRate -> 25]

Out[4]= "test.mp4"

In[5]:= Import[%, "FrameRate"]

Out[5]= Quantity[25, "Frames"/"Seconds"]
```

#### IncludeMetaInformation (3)

By default, all existing metainformation from an ``Audio`` object is exported:

```wl
In[1]:= a = \!\(\*AudioBox["![Embedded Audio Player](audio://content-sugkr)"]\);

In[2]:= Options[a, MetaInformation]

Out[2]= {MetaInformation -> <|"M4A" -> <|"PartOfCompilation" -> False, "CreationDate" -> {DateObject[{2008}, "Year", "Gregorian", 1.]}, "Title" -> {"TestTitle"}|>|>}

In[3]:= Export["test.mp4", a]

Out[3]= "test.mp4"

In[4]:= Options[Import[%], MetaInformation]

Out[4]= {MetaInformation -> <|"M4A" -> <|"PartOfCompilation" -> False, "CreationDate" -> {DateObject[{2008}, "Year", "Gregorian", 2.]}, "Title" -> {"TestTitle"}|>|>}
```

---

Specify the metadata to include:

```wl
In[1]:= Export["test.mp4", \!\(\*AudioBox["![Embedded Audio Player](audio://content-sugkr)"]\), IncludeMetaInformation -> None]

Out[1]= "test.mp4"

In[2]:= Options[Import[%], MetaInformation]

Out[2]= {MetaInformation -> <|"M4A" -> <|"Comment" -> {"Created with the Wolfram Language : www.wolfram.com"}, "EncodedBy" -> {"Lavf58.76.100"}|>|>}
```

---

Import metadata:

```wl
In[1]:= v = Video["ExampleData/bullfinch.mkv"];

In[2]:= Import[Information[v, "ResourcePath"], "MetaInformation"]

Out[2]= <|"Comments" -> "Created with the Wolfram Language : www.wolfram.com", "ApproximateFrameCount" -> 451, "BitRate" -> Quantity[1258241, "Bits"/"Seconds"], "Container" -> "MATROSKA", "Duration" -> Quantity[15.022, "Seconds"], "ResourcePath" -> File["C ... ", "Duration" -> Quantity[14.293, "Seconds"], "SubtitleEncoding" -> "SSA"|>, 2 -> <|"Language" -> Entity["Language", "German::8jz29"], "Title" -> "Der Eurasische Gimpel", "Duration" -> Quantity[15.003, "Seconds"], "SubtitleEncoding" -> "SSA"|>|>|>
```

Do not export metadata such as ``"Language"`` or ``"Title"`` :

```wl
In[3]:= Import[Export["test.mp4", v, IncludeMetaInformation -> None], "MetaInformation"]

Out[3]= <|"MajorBrand" -> "isom", "MinorVersion" -> "512", "CompatibleBrands" -> "isomiso2avc1mp41", "Comments" -> "Created with the Wolfram Language : www.wolfram.com", "ApproximateFrameCount" -> 451, "BitRate" -> Quantity[921546, "Bits"/"Seconds"], "Cont ... ], "AudioChannels" -> 1, "AudioEncoding" -> "AAC", "SampleFormat" -> "Real32", "SampleRate" -> Quantity[44100, "Samples"/"Seconds"]|>|>, "SubtitleTracks" -> <|1 -> <|"SubtitleEncoding" -> "MOV-TEXT"|>, 2 -> <|"SubtitleEncoding" -> "MOV-TEXT"|>|>|>
```

#### MetaInformation (1)

By default, all supported metadata from the input video file is exported:

```wl
In[1]:= v = Video["ExampleData/bullfinch.mkv"];

In[2]:= Import[Export["test.mp4", v], "MetaInformation"]

Out[2]= <|"MajorBrand" -> "isom", "MinorVersion" -> "512", "CompatibleBrands" -> "isomiso2avc1mp41", "Comments" -> "Created with the Wolfram Language : www.wolfram.com", "ApproximateFrameCount" -> 451, "BitRate" -> Quantity[921639, "Bits"/"Seconds"], "Cont ... [44100, "Samples"/"Seconds"]|>|>, "SubtitleTracks" -> <|1 -> <|"Language" -> Entity["Language", "English::385w8"], "SubtitleEncoding" -> "MOV-TEXT"|>, 2 -> <|"Language" -> Entity["Language", "German::8jz29"], "SubtitleEncoding" -> "MOV-TEXT"|>|>|>
```

Compare with the metadata from the original file:

```wl
In[3]:= Import[Information[v, "ResourcePath"], "MetaInformation"]

Out[3]= <|"Comments" -> "Created with the Wolfram Language : www.wolfram.com", "ApproximateFrameCount" -> 451, "BitRate" -> Quantity[1258241, "Bits"/"Seconds"], "Container" -> "MATROSKA", "Duration" -> Quantity[15.022, "Seconds"], "ResourcePath" -> File["C ... ", "Duration" -> Quantity[14.293, "Seconds"], "SubtitleEncoding" -> "SSA"|>, 2 -> <|"Language" -> Entity["Language", "German::8jz29"], "Title" -> "Der Eurasische Gimpel", "Duration" -> Quantity[15.003, "Seconds"], "SubtitleEncoding" -> "SSA"|>|>|>
```

Export specified metadata; only selected tags are supported for ``"MP4"`` :

```wl
In[4]:= metadata = <|"Comments" -> "my comments", "Title" -> "my title", "VideoTracks" -> <|1 -> <|"Language" -> "eng"|>|>|>;

In[5]:= Lookup[Import[Export["test.mp4", v, MetaInformation -> metadata], "MetaInformation"], {"Comments", "Title", "VideoTracks"}]

Out[5]= {"my comments", "my title", <|1 -> <|"Language" -> "eng", "BitDepth" -> 8, "ColorSpace" -> "RGB", "FrameRate" -> Quantity[30, "Frames"/"Seconds"], "PixelAspectRatio" -> 1, "PixelFormat" -> "yuv420p", "RasterSize" -> {640, 360}, "Transparency" -> False, "VideoBitRate" -> Quantity[664650, "Bits"/"Seconds"], "VideoEncoding" -> "H264"|>|>}
```

#### RasterSize (1)

By default, the raster size is preserved when exporting ``Video`` or ``VideoStream`` objects:

```wl
In[1]:= video  = Video["ExampleData/bullfinch.mkv"];

In[2]:= Export["test.mp4", video]

Out[2]= "test.mp4"

In[3]:= {Information[video]["VideoTracks"][1]["OriginalRasterSize"]//Normal, Import[%, "RasterSize"]}

Out[3]= {{640, 360}, {640, 360}}
```

Specify a different raster size:

```wl
In[4]:= Export["test.mp4", video, RasterSize -> 320]

Out[4]= "test.mp4"

In[5]:= Import[%, "RasterSize"]

Out[5]= {320, 180}
```

#### SampleRate (1)

By default, the sample rate is preserved when exporting ``Video``, ``VideoStream`` or ``Audio`` objects:

```wl
In[1]:= video  = Video["ExampleData/bullfinch.mkv"];

In[2]:= Export["test.mp4", video]

Out[2]= "test.mp4"

In[3]:= {Information[video]["AudioTracks"][1]["SampleRate"], Import[%, "SampleRate"]}

Out[3]= {Quantity[48000, "Samples"/"Seconds"], Quantity[48000, "Samples"/"Seconds"]}
```

Specify a different sample rate:

```wl
In[4]:= Export["test.mp4", video, SampleRate -> 44100]

Out[4]= "test.mp4"

In[5]:= Import[%, "SampleRate"]

Out[5]= Quantity[44100, "Samples"/"Seconds"]
```

#### SubtitleEncoding (1)

Specify the encoding of exported subtitles:

```wl
In[1]:= Export["test.mp4", Video["ExampleData/bullfinch.mkv"], SubtitleEncoding -> "MOV-TEXT"]

Out[1]= "test.mp4"

In[2]:= Import[%, "SubtitleEncoding"]

Out[2]= "MOV-TEXT"
```

#### SubtitleTrackSelection (1)

By default, all subtitle tracks are exported:

```wl
In[1]:= Export["test.mp4", Video["ExampleData/bullfinch.mkv"]]

Out[1]= "test.mp4"

In[2]:= Import[%, "SubtitleTrackCount"]

Out[2]= 2
```

Use the subtitle tracks to export:

```wl
In[3]:= Export["test.mp4", Video["ExampleData/bullfinch.mkv"], SubtitleTrackSelection -> 1]

Out[3]= "test.mp4"

In[4]:= Import[%, "SubtitleTrackCount"]

Out[4]= 1
```

Export no subtitle tracks:

```wl
In[5]:= Export["test.mp4", Video["ExampleData/bullfinch.mkv"], SubtitleTrackSelection -> None]

Out[5]= "test.mp4"

In[6]:= Import[%, "SubtitleTrackCount"]

Out[6]= 0
```

#### VideoEncoding (1)

Specify the encoding of exported video:

```wl
In[1]:= Export["test.mp4", Video["ExampleData/bullfinch.mkv"], VideoEncoding -> "MPEG2VIDEO"]

Out[1]= "test.mp4"

In[2]:= Import[%, "VideoEncoding"]

Out[2]= "MPEG2VIDEO"
```

#### VideoTrackSelection (1)

By default, all video tracks are exported:

```wl
In[1]:= Export["test.mp4", Video["ExampleData/bullfinch.mkv"]]

Out[1]= "test.mp4"

In[2]:= Import[%, "VideoTrackCount"]

Out[2]= 1
```

Specify the video tracks to export:

```wl
In[3]:= Export["test.mp4", Video["ExampleData/bullfinch.mkv"], VideoTrackSelection -> 1]

Out[3]= "test.mp4"

In[4]:= Import[%, "VideoTrackCount"]

Out[4]= 1
```

Export no video tracks:

```wl
In[5]:= Export["test.mp4", Video["ExampleData/bullfinch.mkv"], VideoTrackSelection -> None]

Out[5]= "test.mp4"

In[6]:= Import[%, {"MP4", "VideoTrackCount"}]

Out[6]= 0
```

#### VideoTransparency (1)

Generate a video with an alpha channel:

```wl
In[1]:= v = SlideShowVideo[[image], VideoTransparency -> True];

In[2]:= Information[v, "Transparency"]

Out[2]= <|1 -> True|>
```

By default ``Export`` removes the transparency:

```wl
In[3]:= Export["test.mp4", v]

Out[3]= "test.mp4"

In[4]:= Information[Import["test.mp4"], "Transparency"]

Out[4]= <|1 -> False|>
```

Export a video with an alpha channel:

```wl
In[5]:= Export["test.mp4", v, VideoTransparency -> True]

Out[5]= "test.mp4"

In[6]:= Information[Import["test.mp4"], "Transparency"]

Out[6]= <|1 -> True|>
```

## See Also

* [`Import`](https://reference.wolfram.com/language/ref/Import.en.md)
* [`Export`](https://reference.wolfram.com/language/ref/Export.en.md)
* [`CloudExport`](https://reference.wolfram.com/language/ref/CloudExport.en.md)
* [`CloudImport`](https://reference.wolfram.com/language/ref/CloudImport.en.md)
* [`QuickTime`](https://reference.wolfram.com/language/ref/format/QuickTime.en.md)
* [`AVI`](https://reference.wolfram.com/language/ref/format/AVI.en.md)
* [`Matroska`](https://reference.wolfram.com/language/ref/format/Matroska.en.md)
* [`Ogg`](https://reference.wolfram.com/language/ref/format/Ogg.en.md)
* [`MP3`](https://reference.wolfram.com/language/ref/format/MP3.en.md)

## Tech Notes

* [Importing and Exporting Video](https://reference.wolfram.com/language/tutorial/ImportingAndExportingVideo.en.md)

## Related Guides

* [Video Processing](https://reference.wolfram.com/language/guide/VideoProcessing.en.md)
* [Importing & Exporting](https://reference.wolfram.com/language/guide/ImportingAndExporting.en.md)
* [Listing of All Formats](https://reference.wolfram.com/language/guide/ListingOfAllFormats.en.md)
* [Multimedia Formats](https://reference.wolfram.com/language/guide/MultimediaFormats.en.md)
* [Web Formats](https://reference.wolfram.com/language/guide/WebFormats.en.md)

## History

* [Introduced in 2020 (12.1)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn121.en.md) \| [Updated in 2020 (12.2)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn122.en.md) ▪ [2021 (12.3)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn123.en.md) ▪ [2021 (13.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn130.en.md) ▪ [2022 (13.1)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn131.en.md) ▪ [2024 (14.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn140.en.md) ▪ [2024 (14.1)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn141.en.md)