CLI arguments from the GUI?

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
MickM
Novice
Posts: 68
Joined: Sat Nov 04, 2017 3:45 pm

CLI arguments from the GUI?

Post by MickM »

I've kind of given up hoping the GUI will ever meet my needs for easy batch processing, so I'm going to bite the bullet and try my luck in the unfamiliar and mirky scripting world. While I certainly don't know how the GUI works, it seemed reasonable to think it might simply a front end for HandbrakeCLI. So I made a custom preset using the GUI and tried to output the corresponding CLI command, but couldn't figure it out. Is this possible?

If it's not possible, are the full CLI arguments for the factory presets available somewhere? I rather tweak the nearest known good thing than start from ground zero. Thanks.
Woodstock
Veteran User
Posts: 4614
Joined: Tue Aug 27, 2013 6:39 am

Re: CLI arguments from the GUI?

Post by Woodstock »

The GUI hasn't been a "CLI front end" for a LONG time. If you grab one of the old 0.10.x versions from the archives, it will LOG the command line arguments necessary to match what you've selected, but it doesn't actually use the CLI to do it.

The 1.x series removed that, but it also added the ability to save presets in a fashion that the CLI can use.

Personally, I keep 0.10.x around for when I want to experiment with settings, but, most of what I process can be batched quite simply; Funimation disks use certain parameters most of the time, Sentai has slightly different ones, and other publishers have variations. The logged CLI arguments can be copied into a batch file and used with 1.x CLIs
MickM
Novice
Posts: 68
Joined: Sat Nov 04, 2017 3:45 pm

Re: CLI arguments from the GUI?

Post by MickM »

Thanks Woodstock - appreciate the very speedy response! So it appears I did something wrong. After I created my own preset "No subs mkv" I tried the command:

/Applications/HandBrakeCLI -i /Volumes/AV5_4TB/_Incomplete/South\ Park\ \(1-22\ of\ ≥23\)/Season\ 22/05\ The\ Scoots.dvdmedia -o ~/Movies/05\ The\ Scoots.mkv --preset="No subs mkv"

and it barfed at me saying the preset was invalid:

mick@Micks-MBP16 ~ % /Applications/HandBrakeCLI -i /Volumes/AV5_4TB/_Incomplete/South\ Park\ \(1-22\ of\ ≥23\)/Season\ 22/05\ The\ Scoots.dvdmedia -o ~/Movies/05\ The\ Scoots.mkv --preset="No subs mkv"
[17:56:50] Compile-time hardening features are enabled
[17:56:50] hb_init: starting libhb thread
[17:56:50] thread 700005fc0000 started ("libhb")
HandBrake 20210427113502-1af07e0f8-master (2021042801) - Darwin x86_64 - https://handbrake.fr
16 CPUs detected
Invalid preset No subs mkv
Valid presets are:
General/
Very Fast 1080p30
Small H.264 video (up to 1080p30) and AAC stereo audio, in
an MP4 container.
Very Fast 720p30
Small H.264 video (up to 720p30) and AAC stereo audio, in an
MP4 container.
...
Woodstock
Veteran User
Posts: 4614
Joined: Tue Aug 27, 2013 6:39 am

Re: CLI arguments from the GUI?

Post by Woodstock »

Side note - when writing the scripts, it is best to wrap file paths in quote characters, because sometimes they will be mis-interpreted.

Using GUI presets in the CLI involves two steps; loading the presets, then selecting the one you want.

--preset-import-gui will import presets from GUI config preset file. Then --preset lets you select the one you need from it.

You can also export your presets to a separate file, and use --preset-import-file <filespec>. But until you tell the CLI where to get the presets, you can't select it.
MickM
Novice
Posts: 68
Joined: Sat Nov 04, 2017 3:45 pm

Re: CLI arguments from the GUI?

Post by MickM »

Thanks! That got me going :-). And now I'm off to try swimming in that mirky scripting pool...
MickM
Novice
Posts: 68
Joined: Sat Nov 04, 2017 3:45 pm

Re: CLI arguments from the GUI?

Post by MickM »

So I knew this was coming - I just completely and utterly suck at scripting. I've spent hours trying to do the most fundamental thing and (even with Google searching) I can't get that right.

Here is the bare bones part of my_script that just loops through a directory's files but doesn't work:

#!/bin/bash
# The first argument is the name of the directory containing the files to compress
for fname in $1/*; do
echo "-------------> fname = $fname"
done

So in the terminal window I type
./my_script /Volumes/AV5_4TB/_Incomplete/South\ Park\ \(1-22\ of\ ≥23\)/Season\ 22
where the directory name is formed by dragging the folder from the Finder into the Terminal window. My output is:

-------------> fname = /Volumes/AV5_4TB/_Incomplete/South
-------------> fname = Park
-------------> fname = (1-22
-------------> fname = of
-------------> fname = ≥23)/Season
-------------> fname = 22/*

I'm not getting any of the files in Season 22 directory. Can anybody please help me?
MickM
Novice
Posts: 68
Joined: Sat Nov 04, 2017 3:45 pm

Re: CLI arguments from the GUI?

Post by MickM »

Just answering my own question. I couldn't figure out how to get $1/* to work in my script but the following modification made it work:

#!/bin/bash
# The first argument is the name of the directory containing the files to compress
cd "$1"
for fname in *; do
echo "-------------> fname = $fname"
done
AJSG1969
Posts: 20
Joined: Mon Jul 19, 2021 6:59 pm

Re: CLI arguments from the GUI?

Post by AJSG1969 »

That worked really well, command line I used was:

handbrakecli.exe --preset-import-gui --preset "HQ 1080p30 Surround" -i "T:\\SD DVD\\10,000 BC" -o "T:\\SD DVD\\10,000 BC\\10,000 excel 1.m4v"

Now if I wanted to run multiple commands, would I simply stick them in a "runme.bat" file, just as a series:

handbrakecli.exe --preset-import-gui --preset "HQ 1080p30 Surround" -i "T:\\SD DVD\\10,000 BC" -o "T:\\SD DVD\\10,000 BC\\10,000 excel 1.m4v"
handbrakecli.exe --preset-import-gui --preset "HQ 1080p30 Surround" -i "T:\\SD DVD\\2 GUNS" -o "T:\\SD DVD\\2 GUNS\\2 GUNS excel 1.m4v"
handbrakecli.exe --preset-import-gui --preset "HQ 1080p30 Surround" -i "T:\\SD DVD\\THREE TENORS" -o "T:\\SD DVD\\THREE TENORS\\THREE TENORS excel 1.m4v"

Thanks.
AJSG1969
Posts: 20
Joined: Mon Jul 19, 2021 6:59 pm

Re: CLI arguments from the GUI?

Post by AJSG1969 »

Am struggling with permissions now, fine on the GUI side, but if I move away from the source folder in CLI I get a file output permission error.

Have looked in https://handbrake.fr/docs/en/latest/cli ... rence.html

See no reference to permissions, have tried using local Desktop and Videos folder but always get the same issue. So this will work:

"C:\Program Files\HandBrake\HandBrakeCLI.exe" --preset-import-gui --preset "Very Fast 576p25" -i "T:\SD DVD\9" -o "T:\SD DVD\9\9.m4v"

But this won't:

"C:\Program Files\HandBrake\HandBrakeCLI.exe" --preset-import-gui --preset "Very Fast 576p25" -i "T:\SD DVD\9" -o "T:\NEWSD\9\9.m4v"

or even this:

"C:\Program Files\HandBrake\HandBrakeCLI.exe" --preset-import-gui --preset "Very Fast 576p25" -i "T:\SD DVD\9" -o "C:\Users\ag\Videos\Captures\
9.m4v"
Post Reply