Cracking the H.264 Codec
Know Your Target
If all players in a group (such as iPods) conformed to the same profile and all relevant players were very well-defined, then a compressionist’s job would be much simpler; you’d just choose a template and start encoding. However, in many instances, such as general-purpose playback on a computer, you have to consider the range of viewing platforms when making your configuration decisions. Let’s start with the simplest case—the iPod—and work toward more general configurations.
If you’re encoding for one or two known iPods, then you’re in good shape; check the specs for those models and encode away. If you’re encoding for general distribution to a variety of different iPods, then the problem is more challenging. If you want to produce one H.264 file suitable for both computer and iPod playback, it’s possible but even more complicated.
That’s because the iPod has gotten more powerful over the years and can play back increasingly high-resolution and H.264 content with higher data rates. For general distribution to a range of iPods old and new, you need to encode for the lowest common denominator, which in this case would be the iPod Touch’s 480x320 screen. Note that the original iPod can play video encoded using the older MPEG-4 codec at 480x480 resolution, which is another option if you’d like to create one file that can play on all iPods yet has a resolution large enough for most computer desktops.
Apple’s iPhone shares the same 480x320 screen size as the iPod touch. Obviously, when producing video for playback across both types of devices, you need to choose the lowest common demominator, or the specs for the least powerful device that you’d like to support.
Had I written this article 8 months ago, I would next venture into producing for progressive download or streaming or for general desktop playback. But in the interim, of course, Adobe announced that both the Flash Media Server and Flash Player would support H.264, changing the landscape entirely.
H.264 for Flash
Sometimes timing is unfortunate, and that’s the case here as it relates to producing H.264 video for Adobe Flash. Specifically, Adobe was in the process of creating a white paper defining how to encode H.264 video for Flash while I was writing this article, but details weren’t made available to me. I pulled material for this article from a range of sources, as you’ll see below, but stay tuned for the white paper because it will likely be more definitive, at least concerning production for the Flash Media Server.
According to the Adobe website, Flash supports the Baseline, Main, High, and High 10 H.264 profiles with no levels excluded. Theoretically, this means that the Flash Player should play, and the Flash Media Server should stream, H.264 video produced at a maximum resolution of 4096x2048 and a data rate of 720Mbps. Presumably, most implementations to date don’t stretch the envelope quite that much. Adobe does have 1920x1080i video streaming from its HD Gallery (www.adobe.com/products/ hdvideo/hdgallery) but doesn’t disclose the encoding parameters used on those files.
In terms of practical knowledge, I gleaned the most from Kaourantin.net, a highly useful and topical blog written by Adobe developer Tinic Uro. In terms of supported file formats, Uro reports that the Flash Player should play .mp4, .m4v, .m4a, .mov, and .3gp files as well as files using newer extensions.
Uro explained the need for the new extensions as follows:
Why new file extensions? It will be an easy way to distinguish files which can be played back by the Flash Player. There are simply too many instances where .mov and .mp4 files cannot be played back or, vice versa, a file compatible with the Flash Player might not play back in QuickTime, an iPod, or other video device. I will also be working on a technical document to exactly outline what the Flash Player does support and what it does not support, although my previous posts already pointed out that we are very close to full support of the H.264 standard with the exception of Extended Profile and FRExt.
Companies and Suppliers Mentioned