Controlling Audio and Forced Subs from CLI

Discussion of the HandBrake command line interface (CLI)
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
ember1205
Posts: 6
Joined: Sun Jul 09, 2017 8:06 pm

Controlling Audio and Forced Subs from CLI

Post by ember1205 »

Please detail your question or problem in as much detail as possible:

I have a number of movies that have been ripped from DVD along with various audio streams and possibly subtitles. Everything has been ripped with makemkvcon on Linux. At this point, I now need to transcode the files to:

A) Correctly enable the Forced Subtitles
and
B) Ensure that there is always a Stereo audio track available

Tell us about your environment. What version of HandBrake? What operating system are you running. etc.

I run 1.0.7 on Mac OS X Sierra (GUI) and can successfully get a nice, clean transcode using one of the high / very high resolution presets and manually adding the stereo track (if it's missing) and enabling Forced for the subs.

I'm wondering if there's any guidance on how to do this from the CLI using 1.0.4 on Ubuntu Linux (16.04). It doesn't seem that there's an "export" of any sort from the GUI that would allow me to set it all up in the GUI then export it to the CLI.
User avatar
BradleyS
Moderator
Posts: 1860
Joined: Thu Aug 09, 2007 12:16 pm

Re: Controlling Audio and Forced Subs from CLI

Post by BradleyS »

The default presets probably do what you want. Try

Code: Select all

--preset="HQ 480p30 Surround"
(or HQ 576p25 Surround for PAL).
User avatar
BradleyS
Moderator
Posts: 1860
Joined: Thu Aug 09, 2007 12:16 pm

Re: Controlling Audio and Forced Subs from CLI

Post by BradleyS »

I just checked the Linux GUI. Main menu > Presets > Export. Then you can do

Code: Select all

--preset-import-file="/path/to/preset.json" --preset="My preset"
ember1205
Posts: 6
Joined: Sun Jul 09, 2017 8:06 pm

Re: Controlling Audio and Forced Subs from CLI

Post by ember1205 »

Thanks.

I'm actually want to use the "HQ 1080p30 Surround" preset as a starting point at least, and then add a stereo audio track (if not already present), order the audio as Dolby Pro Logic, 5.1, Stereo (assuming the first two are present), and then ensure forced subs are enabled.

Is there some sort of "query" option so that I can interrogate a file to see what information is present before I try and create my options?

Also, this is a headless Linux machine with no GUI. CLI is all I'm working with.
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: Controlling Audio and Forced Subs from CLI

Post by mduell »

You're better off just picking the options you want from the CLI documentation than [Censored] around with the GUI presets.
User avatar
BradleyS
Moderator
Posts: 1860
Joined: Thu Aug 09, 2007 12:16 pm

Re: Controlling Audio and Forced Subs from CLI

Post by BradleyS »

Just append your audio settings after selecting the preset. Not sure why you need Stereo with DPL2, which is Stereo with matrixed Surround channels.

Foreign Audio Search with burn in is enabled for all official presets except legacy.
User avatar
BradleyS
Moderator
Posts: 1860
Joined: Thu Aug 09, 2007 12:16 pm

Re: Controlling Audio and Forced Subs from CLI

Post by BradleyS »

The CLI --help for 1.0.4/1.0.7 is here also: https://handbrake.fr/docs/en/1.0.0/cli/cli-guide.html
ember1205
Posts: 6
Joined: Sun Jul 09, 2017 8:06 pm

Re: Controlling Audio and Forced Subs from CLI

Post by ember1205 »

BradleyS wrote: Sun Jul 09, 2017 10:42 pm Just append your audio settings after selecting the preset. Not sure why you need Stereo with DPL2, which is Stereo with matrixed Surround channels.

Foreign Audio Search with burn in is enabled for all official presets except legacy.
My intention, and maybe I'm being very misguided, is to offer as much flexibility as possible with my setup. The files are going onto a Plex media server and can be played from a a number of different clients. I've already had to "repair" a couple of movies that didn't have a Stereo audio track and refused to offer any sound when being played on certain TV's via the Plex app. Adding the stereo audio track with HandBrake corrected the issue. Since I have so many movies that I'd like to transcode to save space, I'd like to be able to do as much of this automatically as possible.

Part of what I want to be sure I provide support for is syncing of files to devices like iPads when I want to take a movie with me when I'm traveling. I believe that having a simple stereo track makes this more feasible.

Thank you for pointing out that the CLI will first load the values from the Preset I give it and will then make any additional changes beyond that with other command-line arguments.

Seems that now I need to determine how to best query these files before I start to understand what audio tracks are present, what order they're currently in, and whether or not there are subtitles present that need to have the "Forced" flag set on them (MakeMKV will rip the subtitles, but won't enable the Forced flag for them).
User avatar
BradleyS
Moderator
Posts: 1860
Joined: Thu Aug 09, 2007 12:16 pm

Re: Controlling Audio and Forced Subs from CLI

Post by BradleyS »

That's really odd, actually. DPL2 and Stereo should be the same as far as the TV is concerned. iPad will play it fine. If you never set your receiver to Pro Logic 2 mode manually, you can safely make the first track Stereo if you prefer.
ember1205
Posts: 6
Joined: Sun Jul 09, 2017 8:06 pm

Re: Controlling Audio and Forced Subs from CLI

Post by ember1205 »

For some odd reason, this one particular movie was giving me trouble. Adding a stereo audio track as the second or third track allowed it to play on this one TV. Didn't make any sense to me, but it fixed it.
ember1205
Posts: 6
Joined: Sun Jul 09, 2017 8:06 pm

Re: Controlling Audio and Forced Subs from CLI

Post by ember1205 »

I've done a fair amount of "digging around" on line and believe I have come up with the appropriate way to accomplish what I'm trying to do. The command line that I've settled on is as follows:

Code: Select all

HandBrakeCLI -i $INPUTFILE --preset "HQ 1080p30 Surround" -s scan  -o $OUTPUTFILE
Where $INPUTFILE is a MKV container and $OUTPUTFILE is a MP4 container (for my use case).

What ultimately ended up making its way into the process for me is the "-s scan" option which, IMHO, is somewhat buried in the documentation in terms of what it's usefulness is.

The "-s" option enables the ability to burn subtitles directly into the MP4 container (which only supports one) in such a way that they will display automatically. The "scan" piece tells HandBrakeCLI to search through all subtitle tracks to find one in the preferred language that contains subtitles that appear in less than 10% of the total frames of the movie. This effectively allows HandBrakeCLI to recognize a subtitle track that is used when the native language is NOT the language being spoken by different characters.

It seems to be working quite well for me to accomplish what I need, but I'd like to suggest that this feature get more detail in the docs so that it's easier to understand why it should be used.
Deleted User 11865

Re: Controlling Audio and Forced Subs from CLI

Post by Deleted User 11865 »

Code: Select all

--preset="HQ 1080p30 Surround"
…will probably work more reliably.
ember1205
Posts: 6
Joined: Sun Jul 09, 2017 8:06 pm

Re: Controlling Audio and Forced Subs from CLI

Post by ember1205 »

Thanks, Rodeo.

I don't recall seeing any complaints about the way I had it structured, and the docs don't seem to indicate the use of the equals sign. But there are plenty that indicate it should be used, so I'll change my method (and re-test, of course, to be sure I'm getting reliable results).
Post Reply