Question about Subtitles for 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
CraigNan
Posts: 9
Joined: Sun May 03, 2015 8:40 pm

Question about Subtitles for CLI

Post by CraigNan »

Hello,

I have a question about setting up the CLI for subtitles. I'm trying this for the first time and don't quite understand on how to do this using the help file from HandBrakeCLI. I would like to add the command line to act like my current GUI setup: Foreign Audio Scan, Forced Only and Burn In checked. I see where you can do a --subtitle scan, but after that I get lost. Any help would be appreciated.
User avatar
BradleyS
Moderator
Posts: 1860
Joined: Thu Aug 09, 2007 12:16 pm

Re: Question about Subtitles for CLI

Post by BradleyS »

If you save a preset in the GUI, you can recall it using the CLI:

Code: Select all

--preset-import-gui --preset=“My Preset”
CraigNan
Posts: 9
Joined: Sun May 03, 2015 8:40 pm

Re: Question about Subtitles for CLI

Post by CraigNan »

Thanks for your reply. I'm very new to this, so when I tried that I got the following error:

[08:21:26] hb_init: starting libhb thread
[08:21:26] thread 1 started ("libhb")
[08:21:26] Preset (null): Incorrect value type for key AudioDitherMethod. Converting.
[08:21:26] Preset (null): Incorrect value type for key AudioDitherMethod. Converting.
[08:21:26] Last error repeated 1 times
[08:21:26] Preset BluRay 2: Incorrect value type for key PresetDescription. Converting.
[08:21:26] Preset BluRay 2: Incorrect value type for key PictureCombDetectCustom. Converting.
[08:21:26] Preset BluRay 2: Invalid video framerate ()
[08:21:26] Preset (null): Incorrect value type for key AudioDitherMethod. Converting.
[08:21:26] Preset (null): Incorrect value type for key AudioDitherMethod. Converting.
[08:21:26] Last error repeated 1 times
[08:21:26] Preset TV Shows: Incorrect value type for key PresetDescription. Converting.
[08:21:26] Preset TV Shows: Incorrect value type for key PictureHeight. Converting.
[08:21:26] Preset TV Shows: Incorrect value type for key PictureCombDetectCustom. Converting.
[08:21:26] Preset TV Shows: Incorrect value type for key PictureWidth. Converting.
[08:21:26] Preset TV Shows: Invalid video framerate ()
[08:21:26] Preset (null): Incorrect value type for key AudioDitherMethod. Converting.
[08:21:26] Preset (null): Incorrect value type for key AudioDitherMethod. Converting.
[08:21:26] Last error repeated 1 times
[08:21:26] Preset Person: Incorrect value type for key PictureHeight. Converting.
[08:21:26] Preset Person: Incorrect value type for key PictureCombDetectCustom. Converting.
[08:21:26] Preset Person: Incorrect value type for key PictureWidth. Converting.
[08:21:26] Preset Person: Invalid video framerate ()
Missing input device. Run handbrakecli --help for syntax.
User avatar
BradleyS
Moderator
Posts: 1860
Joined: Thu Aug 09, 2007 12:16 pm

Re: Question about Subtitles for CLI

Post by BradleyS »

Please paste the entire command you're running. Also, the HandBrake version should be at the top of the output; otherwise please paste the output of HandBrakeCLI --version.
CraigNan
Posts: 9
Joined: Sun May 03, 2015 8:40 pm

Re: Question about Subtitles for CLI

Post by CraigNan »

OK, I think the reason I got the errors is when I do a '--preset-list' I don't see my preset. I see all of the others, but none of my presets saved under "User Preset" and when I try to modify a default preset, I can't save the changes. Also, when I save my preset, it doesn't save my "Track Names" under the Audio tab and that is why I asked for help with the subtitle section for the CLI.
User avatar
BradleyS
Moderator
Posts: 1860
Joined: Thu Aug 09, 2007 12:16 pm

Re: Question about Subtitles for CLI

Post by BradleyS »

Okay. Still going to need the requested info above.
CraigNan
Posts: 9
Joined: Sun May 03, 2015 8:40 pm

Re: Question about Subtitles for CLI

Post by CraigNan »

C:\Program Files\Handbrake>HandBrakeCLI --preset-import-gui --preset="Person"

C:\Program Files\Handbrake>HandBrakeCLI --version
[09:32:39] hb_init: starting libhb thread
[09:32:39] thread 1 started ("libhb")
HandBrake 1.0.7
Woodstock
Veteran User
Posts: 4614
Joined: Tue Aug 27, 2013 6:39 am

Re: Question about Subtitles for CLI

Post by Woodstock »

Your command line does not include the input and output files, which means nothing is going to happen, other than loading the presets.

A command line would look more like this (although this isn't using the preset load):
"C:\Program Files\Handbrake\HandBrakeCLI.exe" -i "Z:\Kiddy Grade\Kiddy Girl-And HD01.mkv" -t 1 -o "V:\Anime\dubbed\k\Kiddy Grade\Kiddy Girl-And HD01.mkv" -f mkv --strict-anamorphic -e x264 -q 20 --cfr -a 1,2 -E av_aac,copy:ac3 -B 160,0 -6 dpl2,auto -R Auto,Auto -D 0,0 --gain=0,0 --audio-copy-mask none --audio-fallback ac3 --subtitle 1 --subtitle-default=1 -x ref=1:weightp=1:subq=2:rc-lookahead=10:trellis=0:8x8dct=0 --verbose=1
CraigNan
Posts: 9
Joined: Sun May 03, 2015 8:40 pm

Re: Question about Subtitles for CLI

Post by CraigNan »

Thanks Woodstock, that helps a lot. Would something like this work? --subtitle scan --subtitle-forced --subtitle-burned
CraigNan
Posts: 9
Joined: Sun May 03, 2015 8:40 pm

Re: Question about Subtitles for CLI

Post by CraigNan »

This is currently what I have written. Am I close? This doesn't include any of the audio lines, I'm still working on that.

Command Line: <C:\Program Files\Handbrake\HandBrakeCLI.exe> --input "<D:\Ripped Movies\Blah Blan - S01E23 - Blah.mkv>" --output "<D:\Converted Movies\Blah Blah - S01E23 - Blah.mkv>" --format av_mkv --markers --auto-anamorphic --modulus 2 --decomb --nlmeans=medium --nlmeans-tune film --encoder x264 --quality 17.0 --encoder-preset slow --encoder-tune film --encoder-profile high --encoder-level 4.1 --rate 23.976 --cfr --audio-lang-list eng --subtitle-lang-list eng --subtitle scan --subtitle-forced --subtitle-burned
Woodstock
Veteran User
Posts: 4614
Joined: Tue Aug 27, 2013 6:39 am

Re: Question about Subtitles for CLI

Post by Woodstock »

Leave out the < and > characters around file names...

I have not played with leaving the subtitle options "unqualified" (no numbers associated with them), simply because for what I do, the foreign audio scan simply does not work as expected (I know its limitations). When I'm putting together the command line, I've already viewed the MKV source file to figure out which audio and subtitle tracks, and their order, I want to use.
User avatar
BradleyS
Moderator
Posts: 1860
Joined: Thu Aug 09, 2007 12:16 pm

Re: Question about Subtitles for CLI

Post by BradleyS »

CraigNan wrote: Would something like this work? --subtitle scan --subtitle-forced --subtitle-burned
That should work.
CraigNan wrote: when I do a '--preset-list' I don't see my preset.
You should be able to see them loaded with:

Code: Select all

HandBrakeCLI --preset-import-gui --preset-list
A full encode command would look like:

Code: Select all

HandBrakeCLI --preset-import-gui --preset="MyPresetName" -i "C:\Path\To\SourceVideo.mp4" -t=1 -o "C:\Path\To\DestinationVideo.mp4"
Or you can skip the --preset* commands and add everything manually per Woodstock's example, if you prefer.
CraigNan
Posts: 9
Joined: Sun May 03, 2015 8:40 pm

Re: Question about Subtitles for CLI

Post by CraigNan »

Thanks everyone for your help. I pretty much got everything working except for the audio and subtitle's. It appears that it only writes out one audio track with the wrong track name. The subtitle issue is that it writes out the subtitle track throughout the show and not just the forced track if one is there. Here is what I have:

"C:\Program Files\Handbrake\HandBrakeCLI.exe" -i "D:\Ripped Movies\The Big Bang Theory - S01E01 - Pilot.mkv" -o "D:\Converted Movies\The Big Bang Theory - S01E01 - Pilot.mkv" -f av_mkv -m --auto-anamorphic --modulus 2 --decomb --nlmeans=medium --nlmeans-tune film -e x264 -q 17.0 --encoder-preset slow --encoder-tune film --encoder-profile high --encoder-level 4.1 --cfr --audio-lang-list eng -E copy:dts -A "DTS Passthru" -R 48,ac3 -B 640 -6 5point1 --gain 0 -A "AC3 5.1" -R 48,av_aac -B 160 -6 dpl2 --gain 0 -A "AAC Stereo" -R 48 --audio-fallback ac3 -s scan -F --subtitle-burned

Any ideas what might be wrong? Also, for the Framerate (FPS) in the help, it doesn't show if I can use "Same as source". Is that valid?

Thanks again for your help.
User avatar
BradleyS
Moderator
Posts: 1860
Joined: Thu Aug 09, 2007 12:16 pm

Re: Question about Subtitles for CLI

Post by BradleyS »

Not specifying -r is equivalent to Same As Source. Unless you have a reason for forcing constant frame rate (which is just variable fixed to the average, when not specifying a rate), just leave off --cfr and HandBrake will do The Right Thing™. Another option is to do what we do in the official presets, and set --pfr -r N, where N is the maximum frame rate your playback device(s) can handle. Think of it as a limiter that only kicks in when necessary. Useful for variable and high frame rate sources.
-E copy:dts -A "DTS Passthru" -R 48,ac3 -B 640 -6 5point1 --gain 0 -A "AC3 5.1" -R 48,av_aac -B 160 -6 dpl2 --gain 0 -A "AAC Stereo" -R 48 --audio-fallback ac3
Perhaps you meant:

Code: Select all

-E copy,av_aac -R auto,48 -B 640,160 -6 5point1,dpl2 -A "5.1","Stereo" --audio-copy-mask ac3,dts --audio-fallback ac3
The first track will either be AC3 or DTS passed through, falling back to AC3 encoding. The second track is guaranteed to be AAC.

Probably need to see an encode log to help with the subtitles.
Post Reply