Need to find the optimal H.264 video bitrate?

I think a lot of people wonder how to find the optimal video bitrate for efficient encoding of H.264 video. There is no universal answer to this, because it all depends on the content of the video material. Luckily, the video encoding genius Robert Reinhardt has created a simple little Adobe AIR app called Bitrate Starter.

image

This handy little tool will get you started, but remember that you still have to do your own testing to find the optimal settings for the best possible quality/file size ratio. Video compression, especially for web, is all about testing.

A nice little tip is to do tests on short selections of the video that represents different kinds of content. Especially look for fast motion, dark areas, lots of detail, little detail etc. Try encoding several versions of the same short clip selections with different settings, compare them, and go with the settings of the one you like best 🙂

Be aware. If you choose a frame size where the height or width is not divisible by 16, 8 or 4 (calculated by modulo operation), you might end up with a 1px green border at either bottom or right side of your frame. I have seen this problem happen several times when using strange frame sizes. The reason for this is that DCT based MPEG compression consists of macroblocks that are 16×16 pixels (at least with MPEG-2 and MPEG-4). You simply help the encoder do the most efficient compression by choosing an optimal frame size. You can read about this and other geeky fun video theory in Charles Poynton’s book, Digital Video and HDTV.

Here is a little excerpt from the book, talking about the “magic” number 16. Charles Poynton is actually the inventor of the number 1080 found in HDTV standards.

If the horizontal or vertical size is not divisible by 16, then the encoder pads the image with a suitable number of black “overhang” samples at the right edge or bottom edge. These samples are discarded upon decoding. For example when coding HDTV at 1920×1080, an encoder appends 8 rows of black pixels to the image array, to make the row count 1088.

If you look closely under width x height in the Bitrate Starter screenshot above, you will see something called grid quality. That is what this is all about. Divisible by 16 is obviously called best, 8 better and 4 good. Robert Reinhardt has actually written about this in two blog posts, which I would recommend doing a quick read-through of as well: Optimal Frame Dimensions for Flash Video and 16x frame size redux.

A few handy frame sizes I use a lot for 16×9 aspect ratio are:

  • 1280 x 720 (16)
  • 1024 x 576 (16)
  • 768 x 432 (16)
  • 640 x 360 (8)
  • 512 x 288 (16)

You can find and download Bitrate Starter from http://videorx.com under Free Tools.

Good luck, and have fun encoding!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s