[These notes will eventually become part of a tech talk on video encoding. List of all articles in this series.]
You may think of video files as “AVI files” or “MP4 files.” In reality, “AVI” and “MP4″ are just container formats. Just like a ZIP file can contain any sort of file within it, video container formats only define how to store things within them, not what kinds of data are stored. (It’s a little more complicated than that, because not all video streams are compatible with all container formats, but never mind that for now.) A video file usually contains multiple tracks — a video track (without audio), one or more audio tracks (without video), one or more subtitle/caption tracks, and so forth. Tracks are usually interrelated; an audio track contains markers within it to help synchronize the audio with the video, and a subtitle track contains time codes marking when each phrase should be displayed. Individual tracks can have metadata, such as the aspect ratio of a video track, or the language of an audio or subtitle track. Containers can also have metadata, such as the title of the video itself, cover art for the video, episode numbers (for television shows), and so on.
There are lots of video container formats. Some of the most popular include
.mp4 extension. The MPEG 4 container is based on Apple’s older QuickTime container (.mov). Movie trailers on Apple’s website still use the older QuickTime container, but movies that you rent from iTunes are delivered in an MPEG 4 container, although Apple likes to use the .m4v file extension instead of .mp4..asf or .wmv extension. ASF was invented by and is primarily used by Microsoft in their Windows Media Player and their handheld Zune media device..flv extension. Flash Video is, unsurprisingly, used by Adobe Flash. Prior to Flash 9.0.60.184 (a.k.a. Flash Player 9 Update 3), this was the only container format that Flash supported. More recent versions of Flash also support the MPEG 4 container..mkv extension. Matroska is an open standard, unencumbered by any known patents, and there are open source reference implementations for doing everything you might want to do with MKV files. It is primarily used by Free Software-loving hippies and, oddly enough, pirates who rip high-definition movies and television shows and release them in The Scene..ogv extension. Like Matroska, Ogg is an open standard, open-source-friendly, and unencumbered by any known patents. Like Matroska, it is used primarily by Free Software-loving hippies, but that may begin to change once Mozilla ships their Firefox 3.1 browser. Firefox 3.1 will support — natively, without platform-specific plugins — the Ogg container format, the Ogg video codec (Theora), and the Ogg audio codec (Vorbis). On the desktop, Ogg is supported out-of-the-box by all major Linux distributions, and you can use it on Mac and Windows by installing the QuickTime components or DirectShow filters, respectively..avi extension. Also known as “the crappy, obsolete format that just won’t die.” The AVI container format was invented by Microsoft in a simpler time when the fact that computers could play video at all was considered pretty amazing. It does not officially support many of the features of more recent container formats; it does not officially support any sort of video metadata; it does not even officially support most of the modern video and audio codecs in use today. Over time, various companies have tried to extend it in generally incompatible ways to support this or that, and it is still the default container format for popular encoders such as MEncoder.This is the briefest of overviews; there are literally dozens of other container formats in use today. DV, NUT, 3GP… the list goes on and on. And there are many others littering the landscape of failed or obsolete technologies, from companies that tried to corner the nascent digital video market by defining their own formats. Wikipedia has a good roundup of video container formats.
Tomorrow: video codecs!
§
Good article, thank you.
Mentioning OGM, a fork of Ogg, among the “failed or obsolete”, and mentioning Ogg itself, borders on FUD, Mark.
“…and *not* mentioning Ogg itself…”, for FSM’s sake. :-/
Ah, the joys of monkeying with container formats. I still (faintly) remember working with Nandub, and waiting something like a day and a half to encode a movie with two-pass DivX 3.11a. Nowadays all these newfangled formats allow multiple audio tracks, multiple video tracks, all kinds of embedded subtitles…
I’m a bit confused, though, about the status of the OGG container format. I know that OGM is a hack of OGG which allows it to contain non-Xiph.org codecs. But why bother developing OGG in the first place, then, if it has such limited utility? Why didn’t Xiph co-opt Matroska, or NUT? What’s the purpose of the OGG container?
Nicola Larosa: Mentioning OGM, a fork of Ogg, among the “failed or obsolete”, and mentioning Ogg itself, borders on FUD, Mark.
To be fair, I read that as an example of the “literally dozens of other container formats in use today”, rather than of the “failed or obsolete” set.
And besides, OGG is a Xiph-only container. It’s useful for what it is, but it’s not really a general-purpose container format. Attempts to stretch it into one seem a little like the endless series of hacks and enhancements piled atop the AVI format.
I’d also add that Matroska is especially popular with anime groups, who are likely to be putting together releases which have multiple audio tracks and plenty of complex subtitles. (On the other hand, I’ve seen plenty of releases where the subtitles were “baked into” the video, presumably to keep people from changing the credits. Ugh.)
@Nicola: wow, that was totally not what I meant. Sorry. I’ll rephrase the paragraph.
— Mark ![]()
Rephrased, replaced “OGM” with “OGG”, and expanded the “failed and obsolete” sentence to “And there are many others littering the landscape of failed or obsolete technologies, from companies that tried to corner the nascent digital video market by defining their own formats.” Which is what I was trying to say in the first place.
— Mark ![]()
Flash introduced H.264 support in Flash 9.0.60.184, also known as Flash Player 9 Update 3. Not sure how that relates to “9v2″ you mention above.
The new container related to the Flash Platform is f4v.
“The F4V format is based on the format specified by ISO/IEC 14496-12: ISO base media file format. Starting with SWF files published for Flash Player 9 Update 3 (9,0,115,0), Flash Player has been able to play F4V files.”
- http://www.adobe.com/devnet/flv/
— enefekt ![]()
Oh, fantastic! I’ve been reading about some of these recently (and subsequently getting confused). Looking forward to the follow up! Will you be covering ways to say convert one to another, like say Matroska to MPEG 4 (I’ve been looking into this, but not thuroughly)? Also, why did Apple go with *.m4v? DRM related?
Lots of MPEG-4 parts are patent encumbered, but are you sure that the file format is one of them? The MPEG licensing association (admittedly not the last word in patent encumbrances) doesn’t seem include the file format in its licensing offerings. (And how, exactly, can one claim that any file format is unencumbered by patents? That requires proving a negative of a very difficult sort, given the way patents work: just because the creator of the format doesn’t claim any patents on it doesn’t mean no one else can.)
Thank you! I await further instalments. “GIVE” is an interesting acronym, too. :P
There’s probably an editing error in this sentence: “MPEG 4 is a patent-encumbered The MPEG 4 container is based on….”
— svat ![]()
Joe Pallas: And how, exactly, can one claim that any file format is unencumbered by patents? That requires proving a negative of a very difficult sort, given the way patents work: just because the creator of the format doesn’t claim any patents on it doesn’t mean no one else can.
Well, prompts to defend that claim generally come up when an open standard endangers someone’s business model. It’s a logically impossible demand; all you can do is your due diligence and hope nobody has a submarine patent. It’s just a way of hiking up the bar to keep open standards out of the market.
Hi Mark,
Nice write-up, but this sentence is a little wonky: “MPEG 4 is a patent-encumbered The MPEG 4 container is…”. Maybe you meant something like, “The MPEG 4 container is patent-encumbered, and is…”?
‘Ogg, usually with an .ogv extension. Ogg is an open standard, unencumbered by patents, and there are open source reference implementations for doing everything you might want to do with Ogg files. It is primarily used by Free Software-loving hippies and, oddly enough, Mozilla and Opera who want to support the Open Web*.’
Funnily enough this entry is just like Matroska, except Matroska doesn’t seem to have much of an appearance outside of The Scene. Just look to Planet [Gnome, Ubuntu, Fedora, Mozilla] and you’ll find Ogg, not Matroska.
*ew, awful term, but you understand the meaning.
It’s ‘Ogg’, not ‘OGG’. It’s not an acronym, but a name based on a Terry Pratchett character (as is the Vorbis audio format). As for .mp4, I’ve read that the container itself is royalty-free. Do you have information suggeting otherwise? Finally, what you say about RIFF/AVI is mostly FUD. For one, it most certainly does support metadata. Moreover, it even works with most modern formats quite well (with the notable exception of Vorbis). See “Myths about AVI”. You may also want to mention .wav, which is practically identical to .avi.
David: It’s ‘Ogg’, not ‘OGG’. It’s not an acronym, but a name based on a Terry Pratchett character (as is the Vorbis audio format).
Nope. It’s a bit of old “Netrek” jargon. The “Discworld” naming theme doesn’t cover Tarkin or Theora, in any case.
The partial sentence about the MPEG 4 container format being patent-encumbered is actually a mistake — I was looking for confirmation and couldn’t find it, but I never corrected the sentence.
As for AVI, I stand by my statement: it does not OFFICIALLY support any of those things. All attempts to make it support modern codecs, metadata, etc. are third-party extensions and are not part of the Microsoft standard. If you can find a citation on MSDN that proves otherwise, I’ll revise my opinion and my article.
— Mark ![]()
I’ve changed “patents” to “any known patents” to acknowledge the depressing reality of the patent system.
— Mark ![]()
@Niall: thanks, I’ve corrected the sentence about Flash versioning.
— Mark ![]()
Added a section about Ogg and its upcoming support in Firefox 3.1.
— Mark ![]()
“F4V” is just a subset of MPEG-4 (both container and codecs), and what enefekt and Niall were referring to. Flash Player has supported FLV (not related to MPEG-4) since version 6 (embedded in the SWF) or 7 (separate download).
grendelkhan: Woops! Thanks for the correction.
Mark: MSDN’s information on RIFF is pretty scarce. According to this document, however, metadata (in the form of the INFO list chunk) is a standard part of OpenDML (AVI version 2).
Well, not “just” a subset; I think there’s some proprietary extensions as well, mostly related to metadata.
I know you’re not dissing AVI really, just telling the truth about it’s unsupported nature. Still, if you’re doing professional encoding on PC’s you will have to use it all day, every day. Nothing beats a YUY2/PCM AVI for processing after capture.
Thanks for this, and looking forward to upcoming installments. Hopefully this will help me finally wade into how I can transform my mini-DV recordings into standard DVD-player format and into free/open compressed files.
Great article. Perhaps not worth mentioning, but Microsofts “invention” of AVI essentially consisted renaming their other “invention” RIFF, which was an endian-swap of EA’s IFF format (which I remember dearly growing up with Deluxe Paint III and IV. Unfortunately I can’t find my Amiga floppies anywhere). Also perhaps not worth mentioning, and already implied, but some people still aren’t aware that file extension and type are totally separate.
— Jon ![]()
This section is only talking about containers, yes? Is it really feasible that anyone could hold a patent on the container that’s going to a) apply only to one container, since they all do pretty much the same thing (as per your first paragraph), and b) stand up in court. I mean patents are all kinds of messed up, but there’s a limit surely?
Peng: Is it really feasible that anyone could hold a patent on the container that’s going to a) apply only to one container, since they all do pretty much the same thing (as per your first paragraph),
A patent isn’t on an end result, but on a way of producing that result. That’s why the claims in patents tend to read “a method for doing x“–it’s the method that’s patentable.
And indeed, ASF is patented (or was eight years ago); legal threats from Microsoft forced Avery Lee to remove ASF support from VirtualDub. That thread also makes the claim that the QuickTime container is patented. I don’t know if these patents are still in existence, or how ASF and QuickTime are supported in ffmpeg and mplayer if there are patent issues.
ASF is US Patent 6041345; the QuickTime container is US Patent 5751281, and possibly some others as well. (Though the Advogato article says that Apple hadn’t been enforcing the patent, which is why decoding support is widespread.)
I still don’t understand how ffmpeg, which isn’t distributed in multiverse (Ubuntu) or non-free (Debian), but rather universe and main, respectively, can knowingly include patent-infringing code, even if those patents aren’t being enforced.
and b) stand up in court.
Speaking pragmatically, it’s expensive and difficult to strike down a patent, and they produce a very, very effective chilling effect in the meantime. (See: Vorbis and Theora being stricken from the HTML 5 spec.) The EFF has been working to strike down bad patents in court, focusing on the most egregious examples, but it takes literally years to strike down a single one. It’s like the right to fair use–in principle, it’s lovely, but in practice, it tends to boil down to the right to sue.
“(It’s a little more complicated than that, because container formats do limit what codecs you can store in them, but never mind.)”
Do you really store codecs in containers? You store streams, right? And use codecs to encode-decode those streams.
Thank you Mark for educating us about video formats. I use my Canon point and shoot camera to make short videos of my son and I did struggle to get small sized good quality videos out of the large file the camera generates. I have since settled on using Windows port of MEncoder to encode the videos to DivX .AVI files.
Looking forward to more information about video encoding from you. Hopefully, you will cover what we should look for in a Video Camera if we are to make small reasonably good quality files for sharing.
@Birger: you’re right, of course; I’ve rephrased the sentence.
— Mark ![]()
Great article. Here is a useful wiki and a cool list of multimedia container formats:
http://wiki.multimedia.cx/index.php?title=Category:Container_Formats
— Marc ![]()
I am no longer accepting public comments on this post, but you can use this form to contact me privately. (Your message will not be published.)
§
© 2001–9 Mark Pilgrim