lisamelton / more-video-transcoding

More tools to transcode videos.
MIT License
45 stars 1 forks source link

How to pick default audio? #4

Open weaverm opened 1 year ago

weaverm commented 1 year ago

I've been running some experiments with two-pass-transcode. I was surprised to find that there's no "--main-audio #" option to select the default audio track. I'm definitely a novice at Ruby code, but after looking at the code it doesn't look like there's a way to select the default audio track. Is that the case? If so, does that imply I should be reordering audio tracks in my .mkv source files?

lisamelton commented 1 year ago

@weaverm Yes, I intentionally left out a --main-audio option to encourage people to make sure the audio tracks in their source files are in a sensible order.

You can actually select a different audio track using the --extra option but keep in mind that means you also need to specify the audio encoder, mixdown and bitrate as well.

weaverm commented 1 year ago

Looking at my script that transcodes my whole library using 'Video Transcoding' I find 338 instances of --main-audio, almost all are --main-audio 2. That'll be a lot of messing about for me to accommodate two-pass-transcode.

One of my experiments is using The Notebook (2004). This comes from a time when the lossless formats were new, so the first audio track is a stand-alone AC-3 track and the second is the TrueHD track. MakeMKV, of course, helpfully separates out the core AC-3 track from the TrueHD track, so you end up with something like this:

Audio #1
ID                                       : 2
ID in the original source medium         : 4352 (0x1100)
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Commercial name                          : Dolby Digital
Codec ID                                 : A_AC3
Duration                                 : 2 h 3 min
Bit rate mode                            : Constant
Bit rate                                 : 640 kb/s
Channel(s)                               : 6 channels
Channel layout                           : L R C LFE Ls Rs
Sampling rate                            : 48.0 kHz
Frame rate                               : 31.250 FPS (1536 SPF)
Compression mode                         : Lossy
Stream size                              : 567 MiB (3%)
Title                                    : Surround 5.1
Language                                 : English
Service kind                             : Complete Main
Default                                  : Yes
Forced                                   : No
Original source medium                   : Blu-ray

Audio #2
ID                                       : 3
ID in the original source medium         : 4353 (0x1101)
Format                                   : MLP FBA
Format/Info                              : Meridian Lossless Packing FBA
Commercial name                          : Dolby TrueHD
Codec ID                                 : A_TRUEHD
Duration                                 : 2 h 3 min
Bit rate mode                            : Variable
Bit rate                                 : 1 378 kb/s
Maximum bit rate                         : 2 772 kb/s
Channel(s)                               : 6 channels
Channel layout                           : L R C LFE Ls Rs
Sampling rate                            : 48.0 kHz
Frame rate                               : 1 200.000 FPS (40 SPF)
Bit depth                                : 24 bits
Compression mode                         : Lossless
Stream size                              : 1.19 GiB (5%)
Title                                    : Surround 5.1
Language                                 : English
Default                                  : No
Forced                                   : No
Original source medium                   : Blu-ray

Audio #3
ID                                       : 4
ID in the original source medium         : 4353 (0x1101)
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Commercial name                          : Dolby Digital
Codec ID                                 : A_AC3
Duration                                 : 2 h 3 min
Bit rate mode                            : Constant
Bit rate                                 : 640 kb/s
Channel(s)                               : 6 channels
Channel layout                           : L R C LFE Ls Rs
Sampling rate                            : 48.0 kHz
Frame rate                               : 31.250 FPS (1536 SPF)
Compression mode                         : Lossy
Stream size                              : 567 MiB (3%)
Title                                    : Surround 5.1
Language                                 : English
Service kind                             : Complete Main
Default                                  : No
Forced                                   : No
Original source medium                   : Blu-ray

My philosophy for rips has been to grab all of the English language audio tracks (because I speak English) except for the descriptive audio track (because fortunately I'm not blind). Since I keep the rips and the space required is measured in dozens terabytes, I've never worried about the few hundred megabytes of 'wasted' space in situations like this. Should I be curating my rips even harder than 'Other Transcoding' is making me do?

My home theater is only a 5.0 system (no sub necessary) and my front end can't process the positional audio formats like Dolby Atmos or DTS:X. The Apple TV 4K that is my Plex client can't passthrough those formats in a lossless way anyway. Most of my usage of --main-audio is choosing the highest quality 5.1 track in the source. I've been (perhaps irrationally) distrustful of the mix down capabilities of the various encoders to go from the proprietary positional formats to a more basic 5.1 format in a sensible way. Do you think my hesitation is misplaced?

The technical capabilities of my home theater is a statement in time. Undoubtedly one day it'll catch up again with the current state of the art. When that happens, it seems natural that I would transcode at least a subset of my collection again to support the new capabilities of my system. I'm not sure I could reorder the audio tracks in my rips such that the best track for today and tomorrow is always the first track.

lisamelton commented 1 year ago

@weaverm I'll consider adding a --main-audio option.

In the meantime, you can try adding this to your command line for those files:

-x audio=2 -x aencoder=av_aac -x ab=384 -x mixdown=5point1
weaverm commented 1 year ago

I've give that a try, thanks.

While we're chatting about audio, one of the things I've really liked about the audio handling in Other Video Transcoding is that it is a set of sensible defaults that get out of your way, but there's a lot of power that's easy to access when you need it. For example, a movie like Your Name. (2016) has both the original Japanese audio as well as an English dub. Lots of people in the anime community feel strongly about dubs, but sometimes when you're watching a movie like that with more casual fans, they're not interested in reading a whole movie's worth of subtitles. A single line of other-transcode takes care of all of it; my command line for that movie. other-transcode --x265 --main-audio 2 --add-audio 4=surround --add-subtitle 1 --add-subtitle 2=forced "$rip_prefix"/Your\ Name./Your\ Name..mkv

weaverm commented 1 year ago

I have been able to make using the the -x options work to select a different track as the default audio. I have also discovered that when one chooses this route, all the audio needs to be specified this way. For example, if you want to specify audio track 2 as the default audio track and add in a stereo commentary track 3, you end up with a command line that looks like this:

-x audio=2,3 -x aencoder=av_aac,av_aac -x ab=384,128 -x mixdown=5point1,stereo -x aname=,Commentary

See the Handbrake CLI Reference documentation for all the gory details.

@donmelton If you want to close this, I'm fine with that. If you want to use this to add --main-audio support, I'm fine with that too.

lisamelton commented 1 year ago

@weaverm Correct. As I wrote earlier:

You can actually select a different audio track using the --extra option but keep in mind that means you also need to specify the audio encoder, mixdown and bitrate as well.