The Moving Picture: Everything You Always Wanted to Know About H.264 but Were Afraid to Ask

I recently taught an H.264-specific class at Streaming Media East in New York. Though the class was 3 hours long, I can distill a bunch of useful knowledge into this column if you don’t mind missing the sample videos and example screens, not to mention the insightful and surprisingly compelling lecture. Let’s begin.

H.264 is today’s “it” codec because it was jointly created by the ISO and ITU, two standards bodies that together control the cell phone, television, and computer industries. Throw in the fact that Apple, Adobe, and Microsoft (for Silverlight) have all adopted H.264, and you’ve got a technology with lots of mojo.

One unique characteristic of H.264 is that unlike WMV and VP6, which are controlled by single vendors (Microsoft and On2, respectively), many different vendors have produced H.264 codecs and their quality varies significantly at lower bitrates when you’re pushing the ragged edge of data rate efficiency. At the risk of increasing my hate mail by 400%, I’ll state that at aggressive bitrates, Apple’s codec in Compressor is clearly the least efficient H.264 codec, especially for HD output. On the other hand, the MainConcept codec in Sorenson Squeeze, Adobe Media Encoder, and Rhozet Carbon Coder and the Dicas Codec in Telestream’s Episode line of products are roughly equivalent for both SD and HD output.

When producing H.264 video, you’ll have a number of unique encoding options. First is the choice of profile. Briefly, profiles define the types of encoding techniques that can be used to produce the H.264 bitstream. The simplest Baseline profile uses the most basic techniques, which produces a stream that can be played back on low-power devices such as iPods. The Main and High profiles use more advanced encoding techniques, resulting in better quality but a stream that requires more CPU power to decode. The rule here is to use the Baseline profile for devices and the High profile for computer playback.

The next choice you’ll face in the typical encoder is the number of B-frames and “reference” frames (B-frames and P-frames being the incomplete frames in a group of pictures used in a compression format such as H.264 or MPEG-2). As you may know, B-frames are the most efficient frames in the group of pictures (GOP), since they can benefit from interframe redundancies found both before and after the B-frame in the stream. P-frames can only look backward for interface redundancies, so are less efficient, while I-frames (also called key frames) are wholly self-referential, making them the least efficient frame. The magic number I recommend for B-frames is three, which creates a sequence such as this: IBBBPBBBPBBBPBBBP, which then repeats. By the way, as with all streaming files, I recommend one I-frame every 10 seconds, or one every 300 frames in a 30 fps file, and always enable the option to add I-frames at scene changes.

Reference frames defines the number of frames within which a B-frame can find redundancies. As you would guess, B-frames find redundancies in the nearest frames, so any value beyond five seems to inflate search times (and the resultant encoding time) without improving quality. Use five for reference frames when given this option.

The final H.264 encoding option that I’ll address is entropy encoding, with two techniques available: CABAC and CAVLC. CABAC creates a higherquality, harder-to-compress stream, while CAVLC offers less quality but lower decode requirements. If you’re producing for devices, CABAC isn’t an option, since it’s not available for the Baseline profile. If you’re producing for computers, I recommend enabling CABAC and will point out that YouTube uses both the High profile and CABAC in its 720p H.264 encoded videos (check out the example here: www.youtube.com/watch?v=VJ5KJVCc5C4).

As mentioned, H.264 is now compatible with QuickTime and Flash and will be compatible Silverlight when Microsoft releases Silverlight 3.0 sometime during the second half of 2009. If producing for QuickTime playback, you can create either MOV or MP4 files. The Flash player can play these formats plus files encoded into an F4V stream, and Johnny-come-lately Silverlight promises to play files created with all three extensions. Note that all three players can play files produced using the High profile with all advanced encoding options enabled, so no worries there.

How about general configuration options such as resolution and data rate? Largely due to the historical work of a big company that only recently adopted H.264, there’s a general impression among streaming producers that H.264 video files don’t play back smoothly on low power computers. In my comparison tests, I found that H.264 required less CPU horsepower to decode than either VP6 or VC-1, which you can read about here: www.streamingmedia.com/article.asp?id=10776. Basically, if you’re converting from the VP6 or VC-1 codecs, you should be able to use the same resolution and data rate for your H.264 files and produce better looking video that requires less CPU horsepower to play back.

All of this sounds great, but H.264 does have one significant negative, which is an as-yet-undefined royalty obligation starting in January 2011 (www.mpegla.com/avc/avc-faq.cfm). No one knows what the charge will be, and it’s at least likely that there will be some de minimis exceptions for small websites. However, if you recommend that your major corporate clients adopt H.264, whether for producing podcasts or general web use, you need to advise them that they’ll probably have to send checks to the MPEG LA for the privilege.

About Jan Ozer

Avatar photo
I help companies train new technical hires in streaming media-related positions; I also help companies optimize their codec selections and encoding stacks and evaluate new encoders and codecs. I am a contributing editor to Streaming Media Magazine, writing about codecs and encoding tools. I have written multiple authoritative books on video encoding, including Video Encoding by the Numbers: Eliminate the Guesswork from your Streaming Video (https://amzn.to/3kV6R1j) and Learn to Produce Video with FFmpeg: In Thirty Minutes or Less (https://amzn.to/3ZJih7e). I have multiple courses relating to streaming media production, all available at https://bit.ly/slc_courses. I currently work as www.netint.com as a Senior Director in Marketing.

Check Also

Seedtag: Harnessing AI for Contextual Audience Targeting

Cookies are gone from Safari and Firefox, and on their way out in Chrome. This …

Why That Amazon Product Follows You Everywhere: A Look at Behavioral Tracking

We’ve all experienced it—you check out a product on Amazon, and before you know it, …

How GPAC Technology is Shaping the Future of Streaming: Key Insights from Fred Dawson

In a recent interview available on YouTube, Jan Ozer sat down with Fred Dawson, an …

Leave a Reply

Your email address will not be published. Required fields are marked *