Any way to run a batch with handbrakeCLI under FreeBSD jail?

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
sirius123
Posts: 5
Joined: Wed Mar 16, 2016 4:15 pm

Any way to run a batch with handbrakeCLI under FreeBSD jail?

Post by sirius123 »

hi,

i am looking to convert a couple of tv shows that i record over the air. i have made a preset that i am satisfied with using x265 i take a 8GB Mpeg2 .ts to a 0.9GB h265 .mkv with absolutely no quality loss that i can see.

at first i though to do it with my pc in windows, but my PC is really old and not power efficient(3570k) and it make my computer unusable (working from home) so i would like to use the Skylake CPU in my TrueNAS server. i have install a handbrake jail and i am able to transcode a single video at a time, but i have at least 300 files to do.

So, i want to do a batch. i it's more simple i can do 1 folder at a time. I have maybe 6-10 folder so not to bad. i have look up and all the batch that i hear is either on windows or with a docker (like unraid), but i didn't find anything for FreeBSD. is it possible or i need to change plateform. if there is a way to convert my .json preset so ffmpeg can understand i think i could do a batch with that also.

looking forward to hear your suggestions
Woodstock
Veteran User
Posts: 4614
Joined: Tue Aug 27, 2013 6:39 am

Re: Any way to run a batch with handbrakeCLI under FreeBSD jail?

Post by Woodstock »

So, what is your question? Is there an issue with creating a shell script that lists the videos to process, or is the jail preventing handbrake from accessing the directories where the file is?

The command line is really not very different between operating systems (ok, there's the Windows \ vs / issue), but a shell script can be VERY simple, or very complex. I posted examples of some simple ones for Windows months ago.

Where things get complicated is if you want to "walk the directory tree" as part of the script, instead of simply making each path part of the command line.
sirius123
Posts: 5
Joined: Wed Mar 16, 2016 4:15 pm

Re: Any way to run a batch with handbrakeCLI under FreeBSD jail?

Post by sirius123 »

Woodstock wrote: Thu Mar 04, 2021 12:22 am So, what is your question? Is there an issue with creating a shell script that lists the videos to process,
yes, lets say that i use your example you linked

Code: Select all

title %time% "%~n1 MP4" & "C:\Program Files\Handbrake\HandBrakeCLI.exe" -i "Z:\Star Trek\The Next Generation\%~n1.mkv" -t 1 -o "V:\TV Series\Star Trek\The Next Generation\%~n1.m4v"  -f mp4  -O  -w 1440 --crop 0:0:240:240 --loose-anamorphic  --modulus 2 -e x264 -q 22 --vfr -a 1,1,3 -E fdk_haac,copy:dtshd,copy:ac3 -6 dpl2,none,none -R Auto,Auto,Auto -B 128,0,0 -D 0,0,0 --gain 0,0,0 --audio-fallback ac3 --subtitle 1 --subtitle-forced=1 --subtitle-burned=1  --verbose=1
if i break part by part:

title %time% "%~n1 MP4% =command not found


"C:\Program Files\Handbrake\HandBrakeCLI.exe"= there is no \Program file\ here. the way i command handbrake is by

Code: Select all

HandBrakeCLI ...
"Z:\Star Trek\The Next Generation\%~.mkv"=the file is not found... because i think it's actually searching the "%~.ts" exactly. here is the output when i enter the command:

Code: Select all

root@handbrake:~ # HandBrakeCLI -i "\media\Séries Télé\RPM plus (2015)\Season 06\%~.ts" -t 1 -o "\media\Séries Télé\RPM plus (2015)\Season 06\%~.mkv" -f mp4 -O -w 1440 --crop 0:0:240:240 --loose-anamorphic --modulus 2 -e x264 -q 22 --vfr -a 1,1,3 -E fdk_haac,copy:dtshd,copy:ac3 -6 dpl2,none,none -R Auto,Auto,Auto -B 128,0,0 -D 0,0,0 --gain 0,0,0 --audio-fallback ac3 --subtitle 1 --subtitle-forced=1 --subtitle-burned=1 --verbose=1
[21:08:04] hb_init: starting libhb thread
[21:08:04] thread 808c17900 started ("libhb")
HandBrake 1.3.3 (2021010700) - FreeBSD amd64 - https://handbrake.fr
4 CPUs detected
Opening \media\Séries Télé\RPM plus (2015)\Season 06\%~.ts...
[21:08:04] CPU: Intel(R) Core(TM) i3-6100 CPU @ 3.70GHz
[21:08:04]  - Intel microarchitecture Skylake
[21:08:04]  - logical processor count: 4
[21:08:04] Intel Quick Sync Video support: no
[21:08:04] hb_scan: path=\media\Séries Télé\RPM plus (2015)\Season 06\%~.ts, title_index=1
disc.c:323: failed opening UDF image \media\Séries Télé\RPM plus (2015)\Season 06\%~.ts
disc.c:424: error opening file BDMV/index.bdmv
disc.c:424: error opening file BDMV/BACKUP/index.bdmv
bluray.c:2585: nav_get_title_list(\media\Séries Télé\RPM plus (2015)\Season 06\%~.ts/) failed
[21:08:04] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 6.0.1
libdvdread: Encrypted DVD support unavailable.
libdvdread: Can't stat \media\Séries Télé\RPM plus (2015)\Season 06\%~.ts
No such file or directory
libdvdread: Could not open \media\Séries Télé\RPM plus (2015)\Season 06\%~.ts
libdvdnav: vm: failed to open/read the DVD
[21:08:04] dvd: not a dvd - trying as a stream/file instead
[21:08:04] hb_stream_open: open \media\Séries Télé\RPM plus (2015)\Season 06\%~.ts failed
[21:08:04] scan: unrecognized file type
[21:08:04] libhb: scan thread found 0 valid title(s)
No title found.


or is the jail preventing handbrake from accessing the directories where the file is?
no, i have access to the file as mention, i am able to transcode a file 1 at a time

to be more precise this is what i want to automate:

Code: Select all

HandBrakeCLI --preset-import-file /media/noovo.json -Z "noovo" -i "/media/Séries Télé/RPM plus (2015)/Season 06/[FILE_NAME].ts" -o "/media/Séries Télé/RPM plus (2015)/Season 06/[FILE_NAME].mkv"
i don't want to have to write a line of code for each title because plex DVR is writing the title of the episode in addition of the season & episode number so it would be highly manual labor to write each individual as in the first example from your link
Woodstock
Veteran User
Posts: 4614
Joined: Tue Aug 27, 2013 6:39 am

Re: Any way to run a batch with handbrakeCLI under FreeBSD jail?

Post by Woodstock »

The examples were for windows, so the breakdown is a bit different.

Code: Select all

title %time% "%~n1 MP4" &
This is specific to the Windows CMD window, not needed on *BSD.

Code: Select all

"C:\Program Files\Handbrake\HandBrakeCLI.exe"
The windows version of the path to the executable. If "HandbrakeCLI" is already in your path, then you don't have to put more than that into your script.

The -i and -o values use Windows-specific macros for the arguments. %-n1 is the "file name portion of the given path with the file extension removed". What you would use here depends on your shell - bash is different than csh as far as file name manipulation. The bash function basename is closest to the Windows CMD macro %-n1.

Most of this is moot if you explicitly include the file names in the script, like the first example shown, just adjusted to use *nix paths. I.e.:

Code: Select all

HandbrakeCLI -i "/video/source/House/House S1 HD01.mkv" -t 1 -o "/NAS/TV Series/House/House S1 HD01.m4v"  -f mp4  -O  -w 1920 --crop 0:0:0:0 --loose-anamorphic  --modulus 2 -e x264 -q 20 --vfr -a 2,2 -E ac3,copy:dts -6 dpl2,none -R Auto,Auto -B 160,0 -D 0,0 --gain 0,0 --audio-fallback ac3 --encoder-preset=medium  --encoder-profile=main  --verbose=1
HandbrakeCLI -i "/video/source/House/House S1 HD02.mkv" -t 1 -o "/NAS/TV Series/House/House S1 HD02.m4v"  -f mp4  -O  -w 1920 --crop 0:0:0:0 --loose-anamorphic  --modulus 2 -e x264 -q 20 --vfr -a 2,2 -E ac3,copy:dts -6 dpl2,none -R Auto,Auto -B 160,0 -D 0,0 --gain 0,0 --audio-fallback ac3 --encoder-preset=medium  --encoder-profile=main  --verbose=1
It takes longer to write the script, and an editor that has "column mode" is very helpful for TV episodes, where you're really only change a couple of numbers between command lines.
Post Reply