4

I'd like to convert my videos with Handbrake from mkv to mp4. But I want all audio files and subtitles contained in the mkv into the new mp4 container!

I use Handbrake 0.9.9 GUI because in this version you can predefine the amount of audio tracks and subtitles per default under preferences ('Add all remaining' / 'Add all'. Now i'd like to achive the same via HandBrakeCLI.

MarcelHodan
  • 580
  • 1
  • 7
  • 27

3 Answers3

5

Update: with Version 1.0.4 there are flags for that matter: --all-audio and --all-subtitles. See this link

The -a and --subtitle parameters don't have an option for all tracks, but extra tracks get ignored. So, to append (nearly) all contained audio tracks and subtitles from the source, you can just list more tracks than you'd expect to ever find in a source. The following CLI command does the trick for me.

HandBrakeCLI.exe -i <Path>\Episode01.mkv -o <Path>\Episode01.mp4 --preset Normal 
--subtitle scan,1,2,3,4,5,6,7,8,9,10 -a 1,2,3,4,5,6,7,8,9,10

This CLI command works with the presumption that my source files won't have more than 10 subtitles or audio files. I know that mine don't have more than 4 so I'm sure to include all.

I always use the --preset Normal to convert my videos. It suites my personal needs and came with HandBrake by default :) .The encode log file shows the following CLI command.

CLI Query:  -i "<PATH>\Episode01.mkv" -t 1 --angle 1 -c 1-12 -o "<PATH>\Episode01.mp4"  
-f mp4  -4  -w 720 --loose-anamorphic  --modulus 2 -e x264 -q 20 --vfr -a 1,2 -E faac,faac 
-6 dpl2,dpl2 -R Auto,48 -B 160,160 -D 0,0 --gain 0,0 --audio-fallback ffac3 
--subtitle scan,1,2 --markers="<AppData>\Local\Temp\Episode010-1-chapters.csv" 
--x264-preset=veryfast  --x264-profile=main  --h264-level="4.0"  --verbose=1

This CLI command contains the necessary -i (input) and -o (output) arguments and the rest are defined by --preset Normal

MarcelHodan
  • 580
  • 1
  • 7
  • 27
3

As of Handbrake 1.0.4, the --all-audio and --all-subtitles options allow for automatic selection of all audio and subtitle tracks.

These can further be refined by passing in a list of languages to select from (e.g., --all-audio --audio-lang-list eng will include all English audio tracks).

mrtumnus
  • 347
  • 4
  • 17
0

In addition to mrtumnus's answer, multiple audio tracks and subtitles can be selected (separated by comma) as ISO 639-2 code:

--subtitle-lang-list eng,deu --audio-lang-list eng,fra
panticz
  • 2,135
  • 25
  • 16