4

In my attempts to encode a video to MPEG-2 in an MOV (which seems to be a valid combination, at least according to Wikipedia), using ffmpeg (-vcodec mpeg2video) and other tools, I have become extremely confused about the FourCCs as well as seemingly related limitations on container formats. I have found:

  • m2v1: This is the default FourCC used by ffmpeg when encoding MPEG-2, but it is unplayable in all media players I have tried (VLC, Windows Media Player, mplayer, and QuickTime Player). It also does not seem to exist in any FourCC databases I have found. Forum posts are rare and are related to old Mac software and compatibility problems regarding this code.
  • mp2v: I can force this code with ffmpeg. It is then playable in all common media players. However, MPEG-2 videos encoded with other encoders (such as Handbrake or Prism), to AVIs, do not use this code, they use mpgv, which makes me suspicious.
  • mpgv: I can force this code with ffmpeg as well, but only when outputting to an AVI (and Handbrake uses it too but only outputs Matroska and MP4). Ffmpeg fails when I attempt to output MOV. Forum posts also indicate trouble with the mpgv + QuickTime container combination.

I'm very confused. Why are there different FourCC's for this, what is the correct one to use, how is it related to the container and, at the end of the day, if I want an MPEG-2 in an MOV what do I do?

I guess by "correct" in the title I mean compatible with the most common players; least likely to cause problems for normal people with stock software.

As a sub-question, VLC describes mpgv and mp2v as "MPEG-1/2 Video". So, if I see a video with FourCC mpgv, is it MPEG-1, or is it MPEG-2? I suspect my lack of understanding of how all the MPEG versions are related to each other is coming into play here.

2 Answers 2

3

Strictly speaking, fourcc is the codec ID used by Microsoft. It has been adapted for use with many other formats, thus making it seem like a standardized ID format, but it's not.

ffmpeg, in particular, seems to only consider XDCAM standard MPEG2 for inclusion in MOV.

From the source code:

else if (track->enc->codec_id == AV_CODEC_ID_MPEG2VIDEO)
    tag = mov_get_mpeg2_xdcam_codec_tag(s, track);

where if the xdcam tag function doesn't find a matching XDCAM stream, it runs

if (!tag)
    tag = MKTAG('m', '2', 'v', '1'); //fallback tag

which ffmpeg, interestingly, thinks is tha tag that should be used for recording MPEG-2 in a MOV by a camera.

{ AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', '2', 'v', '1') }, /* Apple MPEG-2 Camcorder */ 

and mp2v is signalled as required for (an old version of) Final Cut Pro.

{ AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', '2', 'v') }, /* FCP5 */

mpgv is not on that (ISO media) list that the MOV muxer can be forced to work with, but it is on the RIFF list (for AVIs) where it's only declared for MPEG-2, not MPEG-1

{ AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', 'g', 'v') }

All the tag variants exist because each vendor or program decides to mark their streams a certain way and there's no single body policing their use. Stick with mp2v since that works for you.

Update: I just realized that any stream can be tagged with any tag if -strict -1 or -2 is applied. I was able to tag an AVC stream in a MOV with mpgv :)

4
  • Thanks. Now, if I were to file an ffmpeg bug report claiming that mp2v should be the default output for mpeg2video+MOV instead of m2v1, would that be reasonable or does it seem like m2v1 is still the more "correct" tag? I'm not particularly familiar with the Apple side of things. There's a discussion about this on the ffmpeg-user mailing list right now; I'll post a link as soon as it's archived.
    – Jason C
    Jan 28, 2016 at 14:30
  • Also, btw, is there general non-Microsoft terminology for FourCC's and their non-Microsoft spin-offs? "Tag"? "Object type"? "Codec ID"?
    – Jason C
    Jan 28, 2016 at 14:32
  • 1
    Codec id sounds the most vendor and format agnostic term to me. Considering that other people in that list can't play m2v1 files either, mp2v does sound a better fallback. Of course, also allowing custom tags via -vtag seems the most flexible way forward.
    – Gyan
    Jan 28, 2016 at 14:51
  • ffmpeg-users.933282.n4.nabble.com/… if it's interesting.
    – Jason C
    Jan 28, 2016 at 17:52
0

Try "MPG2". My stream was properly detected as MPEG-2 by MPC, MPC-HC and WMP. Source of info here: https://git.ffmpeg.org/gitweb/nut.git/blob_plain/HEAD:/docs/nut4cc.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.