lisamelton / video_transcoding

Tools to transcode, inspect and convert videos.
MIT License
2.39k stars 160 forks source link

Multiple Format #274

Closed NateUT99 closed 5 years ago

NateUT99 commented 5 years ago

I'm in the middle of re-transcoding my Bluray collection and am just starting on my Miyazaki/Studio Ghibli discs. Some of these feature an English and Japanese DTS-HD stereo track. I'd like to use these as input (via FLAC) and create output with an English 224kbps DD+ and 160kbps AAC file as well as a Japanese 160kbps AAC file (so three audio tracks total).

Using the options available, I have been able to get two DD+ tracks, or two AAC tracks... but not the combination mentioned above. If anyone has any thoughts on how I could potentially meet my objective (via --handbrake-option or otherwise), I'd certainly appreciate it!

lisamelton commented 5 years ago

@NateUT99 Thanks for taking the time to ask your original Twitter question here on GitHub!

And, as I mentioned on Twitter, I don't provide a simple way to do this because AAC at 160 Kbps should be sufficient for high-quality audio. It's what I use to transcode all my stereo Miyazaki films.

But there is a way to do this with transcode-video and --handbrake-option, or its shortcut -H (that's just a single dash and a capital "H").

Let's assume that the English language audio track you want to transcode is the first track in your source file, the Japanese language track is the second track and that both are in stereo format. And let's also assume that you're using macOS.

If you were to use the --dry-run option with transcode-video like this without any other options:

transcode-video --dry-run "/path/to/Movie.mkv"

...then you would get output to the console showing the actual command which would be passed to HandBrakeCLI like this:

HandBrakeCLI --input=/path/to/Movie.mkv --output=Movie.mkv --markers --encoder=x264 --crop=0:0:0:0 --auto-anamorphic --encoder-profile=high --encoder-level=4.0 --quality=1 --audio=1 --aencoder=ca_aac --encopts=vbv-maxrate=6000:vbv-bufsize=12000:crf-max=25:qpmax=34

Notice the two audio options there: --audio=1 --aencoder=ca_aac

Those options select the first audio track as input and select the AAC encoder on macOS to used for encoding that audio. No bitrate is specified so a default of 160 Kbps for stereo will be used.

But to get what you want, we need to modify those two audio options and then add a third. We can do that like this:

transcode-video --dry-run -H audio=1,1,2 -H aencoder=eac3,, -H ab=224,, "/path/to/Movie.mkv"

...which should output something like this to the console:

HandBrakeCLI --input=/path/to/Movie.mkv --output=Movie.mkv --markers --encoder=x264 --crop=0:0:0:0 --auto-anamorphic --encoder-profile=high --encoder-level=4.0 --quality=1 --audio=1,1,2 --aencoder=eac3,, --encopts=vbv-maxrate=6000:vbv-bufsize=12000:crf-max=25:qpmax=34 --ab=224,,

Notice that the audio options are now: --audio=1,1,2 --aencoder=eac3,, --ab=224,,

Those options select the first audio track twice and the second track once. They also select the DD+ encoder (eac3) for the first track and no encoder for the next two tracks (the two trailing commas). By default, not selecting an encoder just means you get the AAC encoder. Finally, an audio bitrate of 224 Kbps is selected for the first DD+ track and no bitrate for the next two tracks, which gets you 160 Kbps for those AAC tracks.

So, TL;DR: Add -H audio=1,1,2 -H aencoder=eac3,, -H ab=224,, to your command line, assuming the English track is the first track and the Japanese track is the second track.

Does that help?

NateUT99 commented 5 years ago

Hi Don, this helps tremendously and looks like it will do exactly what I want. I’ll give it a shot after work today. Thanks again!

lisamelton commented 5 years ago

@NateUT99 You are very welcome, sir! Let me know if you run into any problems. And feel free to comment again here if that happens.