Convert MKV video for the AppleTV

by postbreak

This has been my project for the past week and I think I have finally perfected it. This guide is a conglomerate of forum posts, wikis, and help from friends. What this guide accomplishes is a high definition video that plays perfectly on the Apple TV running XBMC. This is not video to be synced over iTunes, it will not work. This is still a work in progress and any input on my workflow would be great, just let me know in the comments.

So you have an Apple TV and you read that it can play 720p video right? Well getting that 720p to play nice with your Apple TV might become a nightmare as it did for me. There are so many restrictions you might consider just getting a Mac Mini, install Plex, and be done with it. If you’re cheap and a college student like me you may want to take a look at this little device.

If your MKV contains AC3 instead of DTS skip this step!

Step 1

Here are some requirements first and foremost.

  • Apple TV with XBMC
  • Mac or Linux PC
  • Xcode (for Macs)
  • Patience

Those requirements are somewhat of a no brainer so here are some more strict requirements. This step allows you to convert DTS to AC3, a crucial factor when converting a high definition video for the Apple TV. If you try to convert a video that contains DTS chances are it will be either reverted to stereo or no audio. I like to think of DTS containing DRM and AC3 being it’s free and open source brother. If you don’t know what DTS is a simple search will inform you.

Ok so there is a star on Aften, that’s because (for me at least) it is a pain to install. Instead of using ./configure make, make install, it requires cmake. So you need to download this version for Macs. So lets get started with the hardest to install.

Install Aften

svn co https://aften.svn.sourceforge.net/svnroot/aften where-you-want-to”

“cd /Aften”

“mkdir default”

“cd default”

“cmake /path-to-Aften”

“make”

“sudo make install”

Congrats, you just did most of the hard work. Now you simply have to install libdca and MKVToolnix. With libdca simply run “./bootstrap” then use ./configure, make, and finally sudo make install. I’m sure you can handle that. MKVdts2ac3 is a nice script and does not require an installer.

So now you’ve got all the requirements met it’s time to talk legality. Yeah I know, people don’t like this but it’s still very important. Buy the movie on bluray. If you’re going to be watching high definition rips you should own the actual disc right?

Now that I got that out of the way lets strip DTS and convert it to AC3. Make sure you chmod your mkvdts2ac3 file so it is executable!

“/path/to/mkvdts2ac3 /path/to/matroska.mkv”

If your paths are correct and you have met the requirements congratulations, you converted the DTS audio track to AC3. simply add “-n” and it will remove the DTS track after conversion.

Step 2

Ok you’re still with me? It takes 13 minutes to convert 2 hours and 20 minutes of audio from DTS to AC3 on my 2 year old Macbook. I told you patience was a requirement. Now we need to convert the actual video. This is where things get tricky. The Apple TV has a limit of about 6000kbp/s in video files. This is due to the 1Ghz cpu. Videos are variable so they can sit at 5000kbp/s for most of the video then spike up to 12,000kbp/s during an action scene. That’s not good because your movie will slow down to a slide show during a great scene.

720p, 1080p, ect what does it all mean? For the uninitiated 1280×720 is the resolution for 720p, the maximum resolution video the Apple TV can handle. The Apple TV can connect to 1080p televisions and then upscale the 720p video to 1080p. Confused? I don’t have a 1080p TV so I can’t comment on the upscaling. What I can comment on is that 720p moniker. My Apple TV won’t play genuine 720p videos. I have to down convert to get smooth sailing. The reason? That damn variable bit rate. Let me explain.

The Dark Knight is a great movie, crazy plot, awesome action scenes, ect. Well those action scenes make the bit rate spike through the roof. I converted the movie a dozen times and guess which one plays the best, the one with the lowered resolution and higher bit rate. You’re probably thinking “Thats not High Def then!” Here are some screenshots for you to compare the raw video to the version that plays on my Apple TV just fine.

Original 720p 10,000kbp/s

Original 720p 10,000kbp/s

Dark Knight 1056x594

Dark Knight 1056x594

Can you see the difference? Well yeah, I’m sure you can. Can you see a difference when sitting on the couch? If you can you have much better vision than I do. So lets get into shrinking it. You can use whatever conversion tool you’d like but I found Handbrake to be the easiest to use.

Here are some screenshots of the settings I use. I chose ffmpeg Dvix with AC3 Passthru for audio. If you do not select audio Passthru you will lose surround sound and get stereo audio.

handbrake-settings1

Don’t forget to set the audio to Passthru. The last thing you want is to waste 4 hours converting a video and end up with stereo audio.
handbrake-settings2

Overall this experience has been crazy. I have learned a lot about codecs and the limits of the Apple TV hardware. Would I do it again? In a heartbeat because I scored an Apple TV for 1/5th the price of a Mac Mini and well, after all this hard work it just the same thing a Mini would do, just a little less quality and much more time converting.

 

It's a bit grainy. You can still see the individual hairs in the mask.

It's a bit grainy. You can still see the individual hairs in the mask.

 

 

I’m not sure if I am violating any GPL codes by posting this but I am hosting all of the tools I used (other than the mkvdts2ac3 script) here incase any of those sites disappear. Nothing pisses me off more than when I stumble across a guide that does what I want but all the links are dead. If you cant find something or need help leave a comment, I actually read those. If you don’t hear a reply and your question isn’t noob like send me an email.

Advertisements