Log in

View Full Version : Q: General question about Handbrake CLI and processing multiple audio streams


Darksoul71
23rd October 2013, 13:54
Hi all,

I hope here is the right place to ask this since I want to use Handbrake CLI rather than using the GUI version.

I am currently hacking together a crude script which shall encode / shrink multiple MKV files with Handbrake CLI. I have used Handbrake CLI for shrinking the video with h264 in CRF so far with sucess. Audio encoding is currently done via ffmpeg and remux of the external AC3 tracks is done via mkvmerge. Now I would like to do audio encoding as part of the Handbrake encoding step.

Unfortunately the Handbrake CLI help does not elaborate things when you have multiple audio streams in different formats.

Handbrake CLI is controlled via those parameters:
-a 1,2,3 = Audiotracks to process
-E <string> = Audio encoder used
--audio-copy-mask <string> = which codecs are allowed to be copied

My educated guess for a MKV with three audio streams and the wish to encode all "non-AC3" tracks to AC3 would look like this:
-a 1,2,3 -E copy:AC3,ffac3
..but I am not shure. It would be great if someone could shed some light into my darkness and keep me from experimenting with those tons of options.

:thanks:

Background: Source MKVs are either from satellite (AC3 plus MP2 audio) or BD Rips (AC3 plus DTS / DTS-HD audio).
Targeted audio format is always AC3. So raw AC3 tracks should be copied over and any non-AC3 audio tracks should be converted to AC3.

Funny enough I have not found any related posting / script snipplet for this even after some serious Google Kung-Fu :(

TIA,
D$

Darksoul71
31st October 2013, 14:00
Wow, I did not expect that many answers :rolleyes:

Anyway, here is how things work:
You need to specify the general amount of audio tracks inside the source file / media you want to add to your target, the type of audio track you want to copy and which codec to use as fallback.

So, for an MKV with 8 audio tracks you want to keep, direct AC3 stream copy of the original track and 640 kBit/s AC3 for re-encoding of all other audio tracks, the command would look like this:

-a 1,2,3,4,5,6,7,8 --aencoder copy:ac3 --audio-fallback ffac3 --ab 640


HTH,
D$

Groucho2004
31st October 2013, 14:09
Funny enough I have not found any related posting / script snipplet for this even after some serious Google Kung-Fu :(
Have you posted your question on the handbrake forum?

Darksoul71
31st October 2013, 14:24
No, not exactly. I have experienced getting often better and more qualified answers in more general forums (Arch multimedia / Arch programming ) then asking in a related forum directly. Usually doom9 has the most experienced peoples when it come to anything AV-related and we have here many "coding monkeys" as well :cool:

..but of course you are somewhat right: The first source of information should / could be the forum / wiki related to the app one is trying to use.