This post is a follow up on a previous post HandBrake AppleTV Hi Profile Setting which includes what constant quality settings to use, etc. If not familiar with it maybe read it as this expands upon that post. A couple of pertinent facts:
1. As of AppleTV OS 3.0 extensive testing has shown that the AppleTV can handle weightb just fine.
2. As is said in the Edit comment from the previous post the AppleTV can not handle weightp. So weightp=0 MUST be included in any AppleTV custom preset. This is because the AppleTV as of this writing uses a modified version of QuickTime 7.0 which did not handle that option at all. Horrible blockiness and artifacts will show especially on fades.
3. When encoding High Definition sources (1080p, 720p) to a proper AppleTV preset extreme bitrate spikes can cause the AppleTV to drop frames. Therefore for safety Video Buffer Verifier (known as VBV) options need to be put in place as safeguards for just this event.
4.[Edit] As of this HandBrake svn commit and its corresponding Nightly Build, HandBrake is no longer overriding x264′s default of b-pyramid being on which I discuss here. Using b-pyramid on the current AppleTV firmware will not only screw up your encodes … but will in fact freeze the AppleTV which only a restart can correct (NOTE: this does not affect the last public release of HandBrake 0.9.4 however there is no downside to adding it to your custom presets as you update HandBrake you will be “future proof” as far as b-pyramid is concerned).
Trimming the fat off the option string (removing unnecessary options):
First we start off with the advanced options string from the first post:
ref=3:mixed-refs=1:bframes=3:me=hex:subq=7:b-adapt=2:8x8dct=1:weightb=0:trellis=0:weightp=0
As per item number one the current AppleTV can handle weightb just fine as well bframes=3, me=hex, subq=7 and 8x8dct are all default in hb’s x264 encoding library so we slim the options string down to:
mixed-refs=1:b-adapt=2:trellis=0:weightp=0
As per number 4 above regarding b-pyramid we want to make sure its turned off by adding:
b-pyramid=none
So we now have:
mixed-refs=1:b-adapt=2:b-pyramid=none:trellis=0:weightp=0
Now having said that as per number three above I am adding vbv parameters to control very high bitrate spikes which are:
vbv-maxrate=5500:vbv-bufsize=5500
This now results in a new advanced option string for the Hi Profile AppleTV preset which looks like this:
mixed-refs=1:b-adapt=2:b-pyramid=none:trellis=0:weightp=0:vbv-maxrate=5500:vbv-bufsize=5500
A few words about video buffer verifier (vbv) settings:
Some playback devices have published video buffer specs in which case setting the vbv is pretty easy. We would know the maximum rate and the size of the video buffer that can be filled. However as usual the AppleTV is a bit of a black box when it comes to any published specs and even the spec that are published are notoriously conservative. So these settings were determined through a lot of testing … and testing … and retesting using some of my toughest material. The idea is to put a cap on peak bitrates so that the AppleTV does not drop frames during tough scenes, yet keep the cap high enough so that for most material the encoder can use as much bitrate as it needs to keep quality up. Currently these have been bullet proof over many tests. For what its worth these vbv settings will allow a .75 second spike as high as 12,833 kbps. The AppleTV publishes a peak bitrate of 13,000 kbps though fails to mention on what duration that spike can be maintained. At any rate using the settings above with rf 22 causes most HD sources to stay well below that so the cap is never hit. But, if its needed its better to cap some bitrate than drop frames. Frankly the effect of the capped bitrate is all but indistinguishable when it happens.
In the end … I suggest that if you use these advanced options with this x264 option string in the HandBrake advanced panel you should be more than happy with your AppleTV encodes especially considering the file size / bitrate tradeoff for visual quality.