justinjas

It's me

About me

Tumblelog by Justin Sanders. Random photos, links and musings.

Search

Archive

Nuance Theme © by Julien Leicher
Available at themeforest.net

09/02/08 5.1 movies for Apple TV from DTS MKV files

I recently got an Apple TV.  One of the main driving forces behind it was to have easy access to the free video podcasts out there (check out geekbrief if you haven’t).  But the other thing that intrigued me was to attempt to setup my digital movie collection for Apple TV.  Since I recently lost my raid array I was kinda starting over from scratch anyways so now was the perfect time to figure out an encoding method.  Apple TV seemed like a good fit for setting up cheap boxes throughout the house to play back my 720p movies.

Of course I’d need to have 5.1 sound or else that was a deal breaker.  I read around and the state of converting regular mkv files to mov files for Apple TV seemed to be mature enough.  So I picked a unit up and dove in head first.

After searching a few forums I found out that visualhub would do pretty much everything I needed with profile support for Apple TV files with 5.1 + 2.0 sound included.  There was a major caveat though, this profile would only include 5.1 sound for files that contained AC3 encoded surround sound on them.  For me that was a big deal since a majority of my mkv movies are DTS encoded and it seemed like I’d be forced to down convert those to stereo only.

I was able to find a solution though for converting DTS mkv files over to a 5.1 + 2.0 mov format compatible with the Apple TV.  First off you’ll need a few pieces of software, some free, some not.  The visualhub software mentioned above is needed (although you might be able to use ffmpeg directly instead).  You’ll also need a copy of Quicktime Pro.  And you’ll have to download and install mkvdts2ac3 which is used to covert the DTS stream to an AC3 stream that is compatible with Apple TV.

The other two downloads should be easy to setup but mkvdts2ac3 not so much, so I’ll run through how to install it and the prereqs.

First off you’ll need the following:

  • mkvtoolnix - Matroska (MKV) tools
  • libdca - DTS to WAV decoder
  • aften - WAV to AC3 encoder


Mkvtoolnix is simple, there is a package you download and run it, done.  Libdca also isn’t bad but requires hitting the command line and doing the standard “./configure; make; sudo make install”.  

Aften was a huge pain though, for me at least.  First download the latest stable release, extract it and go into this directory.  You’ll notice there isn’t a familiar configure or makefile here, instead aften uses cmake.  You may already have cmake installed but I didn’t.  I tried getting it off of fink but the version was too old and through a bunch of errors.  Instead I ended up using dawinports to get cmake and this version worked out fine.  Use the install guide to get that setup and then run “sudo port install cmake”.

Even with a updated version of cmake I still ran into issues compiling aften.  I found a forum post (avidemux.org) that detailed the magic combination for osx.

export CFLAGS=-fno-common
cmake -DSHARED=1 ..
make
sudo make install


That should get mkvdts2ac3 up and running for you from the command line.

So with all software installed these are the steps needed to convert a DTS mkv file into a mov Apple TV file that still contains 5.1 sound.
First open up visualhub and drag in your mkv file.  Select the itunes tab, optimized for Apple TV 5.1 + 2.0, check H.264 encoding and then the quality level of you choosing (I’d suggest high or go nuts).

If you have a source file that already contains a AC3 encoded 5.1 soundtrack then you’ll get a mov file out of visual hub and you’ll be done.  However you’ll notice if your file is DTS you’ll end up with a mp4 file and it will only contain a 2.0 channel AAC file.

That’s ok for now but we need to convert the DTS track to AC3 and combine it together into one movie with both sound tracks.

In order to do this you’ll need to edit the mkvdts2ac3 script and have it stop after converting the DTS file.  After the dcadec command in the script add these lines to get the AC3 dumped to your desktop.

echo “Saving AC3 to Desktop”

cp “$AC3FILE” ~/Desktop

rm -f “$DTSFILE” #clean up
rm -f “$AC3FILE” #clean up
exit


Now you’ll need to run you’re original mkv file through mkvdts2ac3.  The result should be the AC3 file you were looking for on your desktop.

In order to combine this AC3 sound track with your mp4 file we’ll be using Quicktime Pro.  This is is actually pretty easy but took me a little while to figure out.  First off open the AC3 file with quicktime.  Go to edit -> select all to highlight the entire audio track.  Copy the audio track and close this quicktime window.  Now open your mp4 file in quicktime and do select all again.  Now use edit -> add to selection and scale.  This will paste the AC3 file into your movie and align it with the same timeline as the existing video and AAC audio.  In order to save simply go to save as and give the movie a name.

You’ll notice that now the movie is a mov file instead of mp4 and if you check window -> movie properties on it you will see there is both a 2 channel AAC track and a 5.1 AC3 track.

The good thing about this is that the 2 channel soundtrack will be used on computers or devices that don’t have AC3 playback ability but the 5.1 AC3 track will be played back on the Apple TV.

Anyways it took me awhile to figure all this out so I just wanted to post it incase anyone else was struggling with the same thing.

  • blogpost
  • apple
← Previous post Next post →