Understanding H.264 Encoding Parameters - Profiles and Levels

Though H.264 codecs come from different vendors, they use the same general encoding techniques and typically present similar encoding options. Here I review the most common H.264 encoding options.

Understanding profiles and levels

According to the aforementioned article, Overview of the H.264/AVC Video Coding Standard, a profile "defines a set of coding tools or algorithms that can be used in generating a conforming bitstream, whereas a level "places constraints on certain key parameters of the bitstream." In other words, a profile defines specific encoding techniques that you can or can't utilize when encoding the files (such as B-frames), while the level defines details such as the maximum resolutions and data rates.

Take a look at Figure 1, which is a filtered screen capture of a features table from Wikipedia's description of H.264. On top are H.264 profiles, including the Baseline, Main, High, and High 10 profiles that Flash Player supports. On the left are the different encoding techniques available, with the table detailing those supported by the respective profiles.

Figure 1. Encoding techniques enabled by profile (source: Wikipedia)

As you would guess, the higher-level profiles use more advanced encoding algorithms and produce better quality (see Figure 2). To produce this comparison, I encoded the same source file to the same encoding parameters. The file on the left uses the Main Profile; the files on the right uses the Baseline. A quick check of the chart in Figure 1 reveals that the Main Profile enables B slices (also called B-frames) and the higher-quality CABAC encoding, which I define later in this article. As you can see, these do help the Main Profile deliver higher-quality video than the Baseline.


Figure 2. File encoded using the Main profile (left) retaining much more quality than a file encoded using the Baseline profile (right). Click the figure to see the full frame in a separate window

So, the Main and High profiles deliver better quality than the Baseline Profile; what's the catch? The catch is, as you use more advanced encoding techniques, the file becomes more difficult to decompress, and may not play smoothly on older, slower computers.

This observation illustrates one of the two trade-offs typically presented by H.264 encoding parameters. One trade-off is better quality for a file that is harder to decompress. The other trade-off is a parameter that delivers better quality at the expense of encoding time. In some rare instances, as with the decision to include B-frames in the stream, you trigger both trade-offs, increasing both decoding complexity and encoding time.

To return to profiles: At a high level, think about profiles as a convenient point of agreement for device manufacturers and video producers. Mobile phone vendor A wants to build a phone that can play H.264 video but needs to keep the cost, heat, and size requirements down. So the crafty chief of engineering searches and finds the optimal processor that's powerful enough to play H.264 files produced to the Baseline Profile. If you're a video producer seeking to create video for that device, you know that if you encode using the Baseline profile, the video will play.

Accordingly, when producing H.264 video, the general rule is to use the maximum profile supported by the target playback platform, since that delivers the best quality at any given data rate. If producing for mobile devices, this typically means the Baseline Profile, but check the documentation for that device to be sure. If producing for Flash Player consumption on Windows or Macintosh computers, this means the High Profile.

This sounds nice and tidy, but understand this: While encoding using the Baseline Profile ensures smooth playback on your target mobile device, using the High Profile for files bound for computer playback doesn't provide the same assurance. That's because the High Profile supports H.264 video produced at a maximum resolution of 4096 × 2048 pixels and a data rate of 720 Mbps. Few desktop computers could display a complete frame, much less play back that stream at 30 frames per second.

Accordingly, while producing for devices is all about profile, producing for computers is all about your video configuration. Here, the general rule is that decoding H.264 video is about as computationally intense as VP6—or Windows Media, for that matter. So long as you produce your H.264 video at a similar resolution and data rate as the other two codecs, it should play fine on the same class of computer. (For comparative playback statistics for H.264, VP6 and VC-1, check out my StreamingMedia.com article, Decoding the Truth About Hi-Def Video Production.)

In general, this means that as long as you're producing SD video at 640 × 480 resolution and lower, it should play fine on most post–2003 computers. If you're producing at 720p or higher, these streams won't play smoothly on many of these computers. You should consider offering an alternative SD stream for these viewers.

What about H.264 levels? If producing for mobile devices with limited screen resolution and bandwidth, you also have to choose the correct level, which again should be specified by the device manufacturer. However, since Flash Player can handle any level supported by any of the supported profiles, you don't have to worry about levels when producing for Flash Player playback on a personal computer.


Comments (4)

Per olsen
Said this on 1-26-2011 At 07:01 am

confusion about H.264

Flash is at container format, normaly compressed using VP6/spark/H.264

wicki says that MPEG4 AVC/ H.264 is "the same" http://en.wikipedia.org/wiki/H.264

question; You use H.264 codec for F4V file, what is your reason for this, wouldent MPEG4 AVC give better quality for same bitrate ?, and suported for same versions of flash player.

im using an AVCHD camera, shoot in HD, cut and save as avchd (codec) in MPEG4 AVC file, this quality is much better, on the net,  than when i save in flash. i think this is becaurce i keep same format, through the proces.

Best regards

Per Olsen Denmark

Said this on 1-26-2011 At 06:12 pm

Per:

>>Flash is at container format, normaly compressed using VP6/spark/H.264.

Correct.

>>wicki says that MPEG4 AVC/ H.264 is "the same" http://en.wikipedia.org/wiki/H.264

Correct.

>>question; You use H.264 codec for F4V file, what is your reason for this, wouldent MPEG4 AVC give better quality for same bitrate ?, and suported for same versions of flash player.

They're the same - H.264 is the same as MPEG4 AVC.

>>im using an AVCHD camera, shoot in HD, cut and save as avchd (codec) in MPEG4 AVC file, this quality is much better, on the net,  than when i save in flash. i think this is becaurce i keep same format, through the proces.

Not sure what you're asking here, sorry. Please:

- when you say "save as avchd (codec) in MPEG4 AVC file" what are the parameters? (resolution, frame rate, data rate).

- When you say ""i save in flash," again, what are the parameters?

Let me know and maybe I can be more useful.

Jan

Said this on 6-22-2011 At 09:20 pm

Hello Jan.

I want to thank you for all your great infromation and tutorials you host here.

They are great!

Specially this one, you made me clear my mind in a lots of things about h264.

I'm actually encoding a file right now (I use Rhozet Carbon Coder 3 which uses the same h264 enconder as Adobe) Everybit of the guide helped :D

Thanks a lot for that.

You'll see me around here, at least, reading stuff.

Greetings from Argentina

 

Sincerely,

Cristian.

 

Said this on 6-22-2011 At 09:31 pm
Cristian:

Wow, thanks for taking the time to write. Carbon Coder is a great tool for H.264, you should get very good results.

I'm glad that you're finding the site useful.

Thanks again.

Jan
Post a Comment
* Your Name:
* Your Email:
(not publicly displayed)
Reply Notification:
Approval Notification:
Website:
* Security Image:
Security Image Generate new
Copy the numbers and letters from the security image:
* Message: