Using Handbrake to Convert Audio

Handbrake is the best conversion utility around. It’s just good at what it does. Yes, it has many advanced features, but if you want to convert video really just pick a preset and you’re on your way.

It’s also superb at converting audio. It can take DTS or AC-3 and turn it into AC-3, MP3, AAC, or OGG. And it can do that while letting you choose a downmix, meaning you can take a nice sounding AC-3 or DTS and output 3 tracks if you wish: AC-3 at 5.1, AAC at 5.1, and a stereo (2-channel) AAC with, say, a Dolby Pro Logic II mix down. You’ll have near-perfect compatibility, depending on your needs.

The problem with handbrake is that they refuse to add video passthrough, despite it being a number 1 requested feature. All the developers do is yell at you when you ask about it. They have AC-3 and DTS passthrough, but no kind of video copying. I’ve used Mencoder and FFMPEG for audio conversion and passthroughs, but I never get an output file I’m happy with. Either the generated MP4/M4V is incompatible with something or the audio quality sucks.

Solution with an MKV (you can adapt this for another input file with, say, MP4Box with an mp4 or similar and can also try Mencoder or FFMPEG to extract)

1. Extract the audio with, say,
mkvextract tracks yourVideoFile.mkv 1:video.h264 2:audio.ac3

2. Mux the extracted audio into a video file (MP4 or MKV preferably) along with a dummy video file:
MP4Box -brand mp42 -add empty.h264 -add audio.ac3 tempOutput.mp4 

3. Convert with Handbrake:
HandBrakeCLI -i tempOutput.mp4 -E aac -6 dpl2 -o tempOutput2.mp4
(This converts an AC-3 to a Pro Logic II stereo AAC within an MP4) 

4. Output is a video file with the audio you want and a dummy video file. You can use the attached ‘empty’ video files (separate AAC and h.264 streams and a muxed .mov container).

Hopefully this helps someone out there. I purposely made the steps vague, you should apply the general method to your situation.

Empty

11 Responses to Using Handbrake to Convert Audio

  1. This is very very very unnecessary. Just use Avidemux. It has audio/video passthrough and lets you reencode anything you want.

    2.6 for windows http://avidemux.razorbyte.com.au/
    2.6 nightly http://avidemux.org/nightly/
    2.5 http://fixounet.free.fr/avidemux/

  2. This little bit of improvisation finally gave me a great solution after hours of fuitless searching. Thank you!

  3. So i have successfully used this guide to convert to dolby digital.. however what would be the mp4box command to mux the 5.1 ac3 and 2ch dolby into the final mp4 container with the origianal source video, similar to how handbrake does when ripping from dvd?

    I used a straight add, but now both audio streams are playing at the same time, i want them to be selctable from the apple TV.

    • From the mp4box documentation:

      -add inputFile#trackID=ID or -add inputFile#ID: adds the specified track. For IsoMedia files, ID is the track ID. For other media files, ID is the value indicated by MP4Box -info inputFile.

      There you go :)

  4. Another option is to set the video average quality rate to 1. The result is a great audio track with an horrible gray video. :)

    I’m using HandbrakeCLI to create this m4v “without” video, with converted audio tracks and then recombine the audio on Subler, ignoring the ugly gray video. The best part it to have a multitrack audio file converted at once. Works like a charm.

  5. I tried your instructions, which worked beautifully in converting from 5.1 to stereo so I could stream to xbox360, however the video quality is terrible. It feels like I am watching in 8-bit color and the framerate is just slow enough to be noticeable. My 410MB mkv file was converted into a 47MB mp4. Is there a way to fix this problem? I’m running it on ubuntu 12.04 server edition with the current version of the programs from their respective PPAs.

    • Is there a reason you’re converting the video along with the audio? I think you just need to add the original video into the mp4 and you should be good to go.

      • I figured out my mistake. After using handbrake on the audio with the empty video file, I went full-on retard and combined tempoutput2.mp4 and video.h264 using the same handbrake command. After screwing with it for an hour or 2 trying to figure out why it was failing, I gave up for a few days. When I pulled up the bash history, I kicked myself for being an idiot.

        Many thanks for the walkthrough!

  6. Just another random wanting to thank you for a quick workaround to this stupid problem.

  7. Thank you for posting this information and the dummy files. The method worked great to fool Handbrake.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>