FFMPEG settings for maximum quality h.264 video on AppleTV Gen 3

AppleTV Gen 3I believe I’m not the only person who has bought AppleTV Gen 3 and been pondering about the best way to convert the existing media collection to a format acceptable by the AppleTV. After some research & experimentation, here are my findings:

Video: AppleTV Gen 3 claims to support H.264 video bitrates of up to 25Mbits. My findings: While it has no problem playing back videos with bitrates up to 40Mbits (even encoded with the ffmpeg’s highest quality setting  of -crf 1), the buffering of the iTunes Home Sharing stream wasn’t adequate and the buffer was being exhausted every minute or so of the playback making it unwatchable.

Audio: AppleTV Gen 3 claims to support AAC stereo bitrates of up to 160Kbits. Suspiciously low, isn’t it? My findings: AAC 5.1 (6 channels) audio plays back ok on my TV at 640Kbits. AppleTV is just passing through the unencoded audio to the TV via HDMI, and TV is down-converting the audio to 2-channel stereo mode.

By the end of the day (actually somewhere around 3am) I ended up with the following command line that produced a file that played back successfully, streamed by iTunes Home Sharing over a WiFi connection (ffmpeg version 1.0.1):

./ffmpeg -i input.mkv -acodec aac -ac 6 -ab 640k -strict experimental -vcodec libx264 -preset slow -crf 14 -level 41 -maxrate 25M -bufsize 10M -f mp4 -map_metadata -1 -pix_fmt yuv420p output.mp4

The source file I tested this with was a MPEG2 TS 1920x1080i, 29.97 fps 4:2:2 YUV colorspace with DTS-HD Master Audio 5.1, 48 kHz. The output resulted in a 30% more compressed video of 6.7gb vs 12gb original file for 39 minutes of content, with average bitrate of 22.5Mbits and taking up about 200mb per minute.

3 thoughts on “FFMPEG settings for maximum quality h.264 video on AppleTV Gen 3

  1. Thanks for posting this, finally solved my issues converting video for the Apple TV and iTunes! Used your code as above and works fantastically.

Leave a Reply to Vahan Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.