Containers and Codecs When we talk about video on the Web, we talk in terms of containers

7.2 Containers and Codecs When we talk about video on the Web, we talk in terms of containers

and codecs. You might think of a video you get off your digital camera as an AVI or an MPEG file, but that’s actually an oversimplification. Con- tainers are like an envelope that contains audio streams, video streams, and sometimes additional metadata such as subtitles. These audio and video streams need to be encoded, and that’s where codecs come in. Video and audio can be encoded in hundreds of different ways, but when it comes to HTML5 video, only a few matter.

Video Codecs When you watch a video, your video player has to decode it. Unfortu-

nately, the player you’re using might not be able to decode the video you want to watch. Some players use software to decode video, which can

be slower or more CPU intensive. Other players use hardware decoders and are thus limited to what they can play. Right now, there are three video formats that you need to know about if you want to start using the HTML5 video tag in your work today: H.264, Theora, and VP8.

C ONTAINERS AND C ODECS 130

Codec and Supported Browsers

H.264 [IE9, S4, C3, IOS]

Theora [F3.5, C4, O10]

VP8 [IE9 (if codec installed), F4, C5, O10.7]

H.264 H.264 is a high-quality codec that was standardized in 2003 and cre-

ated by the MPEG group. To support low-end devices such as mobile phones, while at the same time handling video for high-definition de- vices, the H.264 specification is split into various profiles. These profiles share a set of common features, but higher-end profiles offer additional options that improve quality. For example, the iPhone and Flash Player can both play videos encoded with H.264, but the iPhone only sup- ports the lower-quality “baseline” profile, while Flash Player supports higher-quality streams. It’s possible to encode a video one time and embed multiple profiles so that it looks nice on various platforms.

H.264 is a de facto standard because of support from Microsoft and Apple, which are licensees. On top of that, Google’s YouTube converted its videos to the H.264 codec so it could play on the iPhone, and Adobe’s Flash Player supports it as well. However, it’s not an open technology. It is patented, and its use is subject to licensing terms. Content producers must pay a royalty to encode videos using H.264, but these royalties do not apply to content that is made freely available to end users. 2

Proponents of free software are concerned that eventually, the rights holders may begin demanding high royalties from content producers. That concern has led to the creation and promotion of alternative codecs.

Theora Theora is a royalty-free codec developed by the Xiph.Org Foundation.

Although content producers can create videos of similar quality with Theora, device manufacturers have been slow to adopt it. Firefox,

2. http://www.reelseo.com/mpeg-la-announces-avc-h264-free-license-lifetime/

C ONTAINERS AND C ODECS 131

Chrome, and Opera can play videos encoded with Theora on any plat- form without additional software, but Internet Explorer, Safari, and the iOS devices will not. Apple and Microsoft are wary of “submarine patents,” a term used to describe patents in which the patent appli- cation purposely delays the publication and issuance of the patent in order to lay low while others implement the technology. When the time is right, the patent applicant “emerges” and begins demanding royalties on an unsuspecting market.

VP8 Google’s VP8 is a completely open, royalty-free codec with quality sim-

ilar to H.264. It is supported by Mozilla, Google Chrome, and Opera, and Microsoft’s Internet Explorer 9 promises to support VP8 as long as the user has installed a codec already. It’s also supported in Adobe’s Flash Player, making it an interesting alternative. It is not supported in Safari or the iOS devices, which means that although this codec is free to use, content producers wanting to deliver video content to iPhones or iPads still need to use the H.264 codec.