What is the encoding used when exporting images as MOV with "VideoEncoding" -> "MPEG-4 Video"?

I have a few rasterised images generated in Mathematica, and I want to output them in a video file, ideally using H.264 encoding. I found the following command.

Export["example_animation.mov", imSet, "VideoEncoding" -> "MPEG-4 Video"]


My question is, what is the actual encoding of the output MOV file? I know I'm telling it to use "MPEG-4 Video", but that could mean a number of things. For example, is it MPEG-4 Part 2 or MPEG-4 Part 10? I'm generally quite confused about the relationship between MPEG4 and H.264 anyway. My impression is that MPEG4 Part 10 is actually a container for H.264, so could it be that the above Mathematica command is actually outputting an H.264 video in a MOV container? Or is it using an MPEG-4 codec that is different from H.264?

• I'm using linux, not MacOS, so I can't answer fully. But on my system exporting as an "AVI" file, using the setting "VideoEncoding" -> "MPEG-4 Video" has absolutely no effect on the resulting file. The file seems to use no codec at all - just raw RGB. With or without that setting, the filesize is exactly the same. Feb 29 '16 at 14:32

This is a very empirical answer, so I hope that someone more authoritative will chime in, but here's what I found. I am on Mathematica 10.3.1 on Win7-64bit.

I generated a silly animation:

a = ExampleData[{"ColorTexture", "GiraffeFur"}];
b = ExampleData[{"ColorTexture", "CatFur"}] // ImageCrop[#, ImageDimensions[%]] &;
frames = Table[Blend[{a, b}, x], {x, 0, 1, 0.05}];


I then exported it to a MOV file using different options for "VideoEncoding" for comparison:

Export["movie noopt.mov", frames]
Export["movie MPEG4.mov", frames, "VideoEncoding" -> "MPEG-4 Video"]
Export["movie H263.mov", frames, "VideoEncoding" -> "H.263"]


I opened each file in VLC to read the codec information it provides, and I obtained the following:

Export with no options --> VLC reports codec: Cinepak Video (cvid)
Export as MPEG-4       --> VLC reports codec: MPEG4 Video   (mp4v)
Export as H.263        --> VLC reports codec: H263Video     (h263)


Clearly the "VideoEncoding" option is working, but I still don't know what kind of MP4 encoding this is, which was the OP's original question.

Wikipedia taught me that H.264 and MPEG-4 Part 10 are the same thing, so I decided to take the Cinepak- and MPEG4-encoded files from Mathematica and use Handbrake, a free video transcoder to convert them to H.264 / MPEG-4 Part 10. I generated both MKV and M4v container files from Handbrake, then played them back with VLC to read off their codec.

VLC reported that the Handbrake-converted files used the "H264 - MPEG-4 AVC (part 10) (avc1)" codec, thus differentiating them from the MPEG-4 files originally generated from Mathematica.

My conclusion is, therefore, that Mathematica does NOT generate H.264 - MPEG-4 Part 10 video files when asked for MPEG4 encoding.

By the way, this is the list of encodings available on my system (MMA 10.3.1, Win7-64bit):

Internal\$VideoEncodings


{"Animation", "BMP", "Cinepak", "Component Video", "DVCPRO - PAL", "DV/DVCPRO - NTSC", "DV - PAL", "Graphics", "H.261", "H.263", "JPEG 2000", "Motion JPEG A", "Motion JPEG B", "MPEG-4 Video", "Photo - JPEG", "Planar RGB", "PNG", "Sorenson Video", "TGA", "TIFF", "Uncompressed", "Video"}`

Unfortunately, H.264 is not one of the options, as far as I understand them. This may be because H.264 is covered by patents and commercial use requires the payment of royalties, which Wolfram may not wish to do. However, Mathematica's output files can be converted to H.264 through free tools (e.g. Handbrake mentioned above) for non-commercial use.

• Wow I can't believe you went through all that trouble for me. Thank you!
– Ray
Feb 29 '16 at 20:17
• @Ray You are very welcome! Feb 29 '16 at 23:58