Command line syntax (after reading -heelp and google)

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
anthonyfca
Posts: 14
Joined: Mon Oct 04, 2021 2:24 pm

Command line syntax (after reading -heelp and google)

Post by anthonyfca »

Description of problem or question:

Can't get my first command line right


Steps to reproduce the problem (If Applicable):

I have tried all these:

HandBrake -Z —preset “Very Fast 720p30” -i, --input 201609231238GP017326a.MP4 -o, --output 201609231238GP017326a720p.MP4

HandBrakeCLI -Z —preset 720p30 -i, --input 201609231238GP017326a.MP4 -o, --output 201609231238GP017326a720p.MP4

HandBrakeCLI -Z —“Very Fast 720p30” -i, --input 201609231238GP017326a.MP4 -o, --output 201609231238GP017326a720p.MP4

HandBrakeCLI -i, --input 201609231238GP017326a.MP4 -o, --output 201609231238GP017326a720p.MP4

Changed filename to file01

HandBrakeCLI -i, —file01.MP4 -o, —file01720p.MP4

HandBrakeCLI -i, —input file01.MP4 -o, —output file01720p.MP4

HandBrakeCLI - Z —“Very Fast 720p30” I, —input file01.MP4 -o, —output file01720p.MP4

HandBrakeCLI - Z —“Very Fast 720p30” i, —input file01.MP4 -o, —output file01720p.MP4

HandBrakeCLI - Z —“Very Fast 720p30” i, —file01.MP4 -o, —file01720p.MP4



HandBrake version (e.g., 1.0.0):

mini@Minis-Mac-mini-2 testtwo % handbrakecli --version
[16:28:55] Compile-time hardening features are enabled
[16:28:55] hb_init: starting libhb thread
[16:28:55] thread 70000d12a000 started ("libhb")
HandBrake 1.4.2



Operating system and version (e.g., Ubuntu 16.04 LTS, macOS 10.13 High Sierra, Windows 10 Creators Update):

MACOS BigSur
11.6 (20G165)
Intel UHD Graphics 630 1536 MB
Mac Mini 2018

HandBrake Activity Log ***required*** (see How-to get an activity log)

[16:22:15] macgui: Handbrake Version: 1.4.2 (2021100300)
[16:22:15] Compile-time hardening features are enabled
[16:22:15] hb_init: starting libhb thread
[16:22:22] macgui: ScanCore scanning titles with a duration of 10 seconds or more
[16:22:22] CPU: Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
[16:22:22] - Intel microarchitecture Kaby Lake
[16:22:22] - logical processor count: 12
[16:22:22] hb_scan: path=/Volumes/External7tb/test, title_index=0
disc.c:437: error opening file BDMV/index.bdmv
disc.c:437: error opening file BDMV/BACKUP/index.bdmv
bluray.c:2646: nav_get_title_list(/Volumes/External7tb/test/) failed
[16:22:22] bd: not a bd - trying as a stream/file instead
libdvdread: Couldn't find device name.
libdvdread: DVDOpenFilePath:findDVDFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdnav: vm: vm: failed to read VIDEO_TS.IFO
[16:22:22] dvd: not a dvd - trying as a stream/file instead
[16:22:22] batch: scanning /Volumes/External7tb/test/.DS_Store
[16:22:22] hb_stream_open: open /Volumes/External7tb/test/.DS_Store failed
[16:22:22] libhb: scan thread found 0 valid title(s)
[16:22:22] macgui: ScanCore scan done


Code: Select all

Please replace this text with the contents of your log file between the two code tags - OR -  provide a pastebin URL in place of these 3 lines.
If you are unable to do so, please state why so we can help you.

Humble Apologies I have no idea what that means. What "two code tags"? I have even less idea what a "pastebin URL" is.

My hopeful purpose is to recursively reduce the file size of about 3,000 MP4 files using say preset "Very Fast 720p30".
I seem to be struggling because I am guessing pretty wildly at how to "convert" the help syntax in to actual syntax.
I would dearly like to see several examples, very simple ones.

In (what seems to be) pseudocode terms I am trying to do this:

HandBrakeCLI -Z —preset “Very Fast 720p30” -i, --input 201609231238GP017326a.MP4 -o, --output 201609231238GP017326a720p.MP4

as a starter.

For example where it says "input" and "output" I am thinking it does not mean to include that text.
Also, on exit it seems my directory is being changed and I didn't notice that for a while.
All the attempts I have tried are listed above, all ending in depressing failure.

Usually and for years I have used the gui interface, but the lack of folder recursion (for reasons explained) means I have to delve deeper.

Regards

Anthony
anthonyfca
Posts: 14
Joined: Mon Oct 04, 2021 2:24 pm

Re: Command line syntax (after reading -heelp and google)

Post by anthonyfca »

My most recent attempt:

mini@Minis-Mac-mini-2 testtwo % LS
201609231238GP017326a2.MP4 File01.MP4
mini@Minis-Mac-mini-2 testtwo % HandBrakeCLI - Z —“Very Fast 720p30” i, —file01.MP4 -o, —file01720p.MP4

[16:43:35] Compile-time hardening features are enabled
[16:43:35] hb_init: starting libhb thread
[16:43:35] thread 700001e66000 started ("libhb")
Missing input device. Run HandBrakeCLI --help for syntax.

HandBrake has exited.
mini@Minis-Mac-mini-2 testtwo %
anthonyfca
Posts: 14
Joined: Mon Oct 04, 2021 2:24 pm

Re: Command line syntax (after reading -heelp and google)

Post by anthonyfca »

I have also (just) tried this:

mini@Minis-Mac-mini-2 testtwo % HandBrakeCLI --preset-import-gui
[16:52:20] Compile-time hardening features are enabled
[16:52:20] hb_init: starting libhb thread
[16:52:20] thread 70000fd5e000 started ("libhb")
Missing input device. Run HandBrakeCLI --help for syntax.

as it looks like presets need to be imported from the gui version before use.
anthonyfca
Posts: 14
Joined: Mon Oct 04, 2021 2:24 pm

Re: Command line syntax (after reading -heelp and google)

Post by anthonyfca »

failed again with this:
mini@Minis-Mac-mini-2 testtwo % HandBrakeCLI - Z —“Very Fast 720p30” i, —/Volumes/External7tb/test/testtwo/file01.MP4 -o, —/Volumes/External7tb/test/testtwo/file01720p.MP4

[17:06:49] Compile-time hardening features are enabled
[17:06:49] hb_init: starting libhb thread
[17:06:49] thread 70000dec6000 started ("libhb")
Missing input device. Run HandBrakeCLI --help for syntax.
anthonyfca
Posts: 14
Joined: Mon Oct 04, 2021 2:24 pm

Re: Command line syntax (after reading -heelp and google)

Post by anthonyfca »

Excluding the preset I get this:

mini@Minis-Mac-mini-2 testtwo % HandBrakeCLI -i, —file01.MP4 -o, —file01720p.MP4

[17:22:09] Compile-time hardening features are enabled
[17:22:10] hb_init: starting libhb thread
[17:22:10] thread 700008aab000 started ("libhb")
HandBrake 1.4.2 (2021100300) - Darwin x86_64 - https://handbrake.fr
12 CPUs detected
Opening ,...
[17:22:10] CPU: Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
[17:22:10] - Intel microarchitecture Kaby Lake
[17:22:10] - logical processor count: 12
[17:22:10] hb_scan: path=,, title_index=1
disc.c:333: failed opening UDF image ,
disc.c:437: error opening file BDMV/index.bdmv
disc.c:437: error opening file BDMV/BACKUP/index.bdmv
bluray.c:2646: nav_get_title_list(,/) failed
[17:22:10] bd: not a bd - trying as a stream/file instead
libdvdread: Encrypted DVD support unavailable.
libdvdread: Can't stat ,
No such file or directory
libdvdread: Could not open ,
libdvdnav: vm: failed to open/read the DVD
[17:22:10] dvd: not a dvd - trying as a stream/file instead
[17:22:10] hb_stream_open: open , failed
[17:22:10] scan: unrecognized file type
[17:22:10] libhb: scan thread found 0 valid title(s)
No title found.

HandBrake has exited.

Unrecognised file type. It's like it is looking for an external optical device like DVD Blueray
anthonyfca
Posts: 14
Joined: Mon Oct 04, 2021 2:24 pm

Re: Command line syntax (after reading -heelp and google)

Post by anthonyfca »

Should I mention I failed to install using the download so I used "homebrew" ?
The available download says it is a zip file, but it isn't; or does not respond as such.
anthonyfca
Posts: 14
Joined: Mon Oct 04, 2021 2:24 pm

Re: Command line syntax (after reading -heelp and google)

Post by anthonyfca »

Here is a good example, if more complex, of what I was hoping to be able to learn to do,

from one of the replies to this thread:

viewtopic.php?f=10&t=40444

#!/bin/bash
set -e
set -x

mkdir -p x265

DIRN=$(dirname '"$1"')
if [ -n $DIRN ]; then
DIRN="${DIRN}/"
fi;

for fname in ${1}/*; do
filename=$(basename "$fname")
FNAME="${filename%.*}"
EXTIN="${filename##*.}"
EXTOUT=".mkv"
OUTFNAME="${FNAME}${EXTOUT}"

case ${EXTIN} in
mkv|mp4|m4v|avi|flv)
if [ -f "${DIRN}x265/${OUTFNAME}" ]; then
echo "Skipping ${filename} as already in x265 directory"
else
if [ -f "${DIRN}${filename}" ]; then

echo "Converting ${filename} to ${FNAME}${EXTOUT} in directory ${DIRN}"
# --audio-lang-list "jpn,eng,und" --audio-lang-list="jpn"
# --subtitle-lang-list eng --subtitle-default=1
# --all-subtitles --subtitle-default=1 -e x265_10bit
# --encoder-tune animation
nice -n 0 HandBrakeCLI -i "${DIRN}${filename}" -o "/tmp/${OUTFNAME}" -e x265 --encoder-preset slow -q $2 --vfr --crop 0:0:0:0 --no-loose-crop -x "pools=20:weightb=1:force-cqp=1" --first-audio --aencoder copy --audio-copy-mask aac,ac3 --audio-fallback fdk_aac --mixdown none --no-comb-detect --no-deinterlace --no-decomb --no-detelecine --no-hqdn3d --no-nlmeans --no-chroma-smooth --no-unsharp --verbose=10 --all-subtitles --subtitle-default=1 --no-markers

echo "exitval=${exitval}"
if [ $? -eq 0 ]
then
echo "Success .. moving from tmp to x265 dir"
mv "/tmp/${OUTFNAME}" "${DIRN}x265/"
else
echo "Failure in handbrake .. exiting"
exit 1
fi
fi
fi;;
esac
done

(how do we mark this as code?) (I am assuming there is no "edit" facility", so again apologies for talking to myself at such length).
anthonyfca
Posts: 14
Joined: Mon Oct 04, 2021 2:24 pm

Re: Command line syntax (after reading -heelp and google)

Post by anthonyfca »

I cannot describe how strongly I want to know the meaning of "missing input device" I can find no explanation anywhere in here or on google - nor of course possible solutions
rollin_eng
Veteran User
Posts: 4836
Joined: Wed May 04, 2011 11:06 pm

Re: Command line syntax (after reading -heelp and google)

Post by rollin_eng »

Yeah, the angry rigatoni of the CLI can be a problem!
User avatar
Ritsuka
HandBrake Team
Posts: 1643
Joined: Fri Jan 12, 2007 11:29 am

Re: Command line syntax (after reading -heelp and google)

Post by Ritsuka »

You added a lot of "," that aren't required.
A working command would be:
HandBrakeCLI -i 01.MP4 -o 01720p.MP4
mduell
Veteran User
Posts: 8182
Joined: Sat Apr 21, 2007 8:54 pm

Re: Command line syntax (after reading -heelp and google)

Post by mduell »

"-i, --input" in the help means you can use either, not both.
anthonyfca
Posts: 14
Joined: Mon Oct 04, 2021 2:24 pm

Re: Command line syntax (after reading -heelp and google)

Post by anthonyfca »

What’s an “angry rigatoni”?

Thanks, I’ll give those a go tomorrow (after 2amhere).

Any chance an example with the preset? That’s whereIstarted using thequotes.

Anthony
anthonyfca
Posts: 14
Joined: Mon Oct 04, 2021 2:24 pm

Re: Command line syntax (after reading -heelp and google)

Post by anthonyfca »

ok so I could not reset, I tried this:

mini@Minis-Mac-mini-2 testtwo % HandBrakeCLI -o --input file01.mp4 -o --file01720p.MP4
[02:06:39] Compile-time hardening features are enabled
[02:06:39] hb_init: starting libhb thread
[02:06:39] thread 70000ea65000 started ("libhb")
Missing input device. Run HandBrakeCLI --help for syntax.
anthonyfca
Posts: 14
Joined: Mon Oct 04, 2021 2:24 pm

Re: Command line syntax (after reading -heelp and google)

Post by anthonyfca »

I do wish I could edit some of the rubbish I post!
anthonyfca
Posts: 14
Joined: Mon Oct 04, 2021 2:24 pm

Re: Command line syntax (after reading -heelp and google)

Post by anthonyfca »

ok so swopping i for an o I get this:

mini@Minis-Mac-mini-2 testtwo % HandBrakeCLI -i --file01.MP4 -o --file01720p.MP4
[02:11:15] Compile-time hardening features are enabled
[02:11:15] hb_init: starting libhb thread
[02:11:15] thread 70000f7f9000 started ("libhb")
HandBrake 1.4.2 (2021100300) - Darwin x86_64 - https://handbrake.fr
12 CPUs detected
Opening --file01.MP4...
[02:11:15] CPU: Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
[02:11:15] - Intel microarchitecture Kaby Lake
[02:11:15] - logical processor count: 12
[02:11:15] hb_scan: path=--file01.MP4, title_index=1
disc.c:333: failed opening UDF image --file01.MP4
disc.c:437: error opening file BDMV/index.bdmv
disc.c:437: error opening file BDMV/BACKUP/index.bdmv
bluray.c:2646: nav_get_title_list(--file01.MP4/) failed
[02:11:15] bd: not a bd - trying as a stream/file instead
libdvdread: Encrypted DVD support unavailable.
libdvdread: Can't stat --file01.MP4
No such file or directory
libdvdread: Could not open --file01.MP4
libdvdnav: vm: failed to open/read the DVD
[02:11:15] dvd: not a dvd - trying as a stream/file instead
[02:11:15] hb_stream_open: open --file01.MP4 failed
[02:11:15] scan: unrecognized file type
[02:11:15] libhb: scan thread found 0 valid title(s)
No title found.

Which look like a great improvement.
To check my file is there:
mini@Minis-Mac-mini-2 testtwo % ls
-o, 201609231238GP017326a2.MP4 File01.MP4
mini@Minis-Mac-mini-2 testtwo %

is this case sensitive? No same result.

It seems to think I am giving it a drive source, like a DVD drive and not a file.

Thanks for helping me make progress.

Anthony
anthonyfca
Posts: 14
Joined: Mon Oct 04, 2021 2:24 pm

Re: Command line syntax (after reading -heelp and google)

Post by anthonyfca »

"-i, --input" in the help means you can use either, not both.

That's just the sort of clarity I need.
(I first used the cli in 1984)

thanks again - anthony
Post Reply