[DOCKER] Handbrake GUI + Automation via CLI


Recommended Posts

Sorry, I was not clear with my request. Currently converting files requires user interaction. That means you need to select input file, add it to queue and press start. I was hoping that this process could be automated. That means when some file is copied to certain folder, it triggers handbrake action (convert file). Or conversion can be initiated by shell script that is run from cron (scan folder, add to queue and start process).

 

This would be very helpful when you copying wtv files from HTPC to unRaid for further processing.

 

Some Windows applications use watchFolders method, it should be possible under Linux. It would be a killer app.

 

 

a watch folder itself is definitely possible with linux using inotify (another user here showed me how a few days ago)

 

a brief little google thus far suggests the CLI app or a combo of the GUI and CLI, gui to set the presets etc... and the CLI to take scripting.

Link to comment
  • Replies 252
  • Created
  • Last Reply

Top Posters In This Topic

In the mean time, this isn't a full watch folder type scenario but a way to stage files for easy submission to the queue http://www.howtogeek.com/199993/converting-videos-by-the-batch-with-handbrake/

 

there is this which might serve as a good starting point for a script if not good on its own. I'm not savvy enough to know https://gist.github.com/donmelton/5734177

 

and this https://trac.handbrake.fr/wiki/CLIGuide#scriptingAndAutomation

Link to comment

In the mean time, this isn't a full watch folder type scenario but a way to stage files for easy submission to the queue http://www.howtogeek.com/199993/converting-videos-by-the-batch-with-handbrake/

 

there is this which might serve as a good starting point for a script if not good on its own. I'm not savvy enough to know https://gist.github.com/donmelton/5734177

 

and this https://trac.handbrake.fr/wiki/CLIGuide#scriptingAndAutomation

 

last night i made a branch for this, added the cli and inotify to the build,

idea was to have a watch folder utilised with inotify that runs a scriot, script volume is saved local to unraid so users can edit their own script.

Link to comment

Thank you :)

 

thus far i've got inotfiy tools installed along with the cli version of handbrake.

 

the inotifiy script needs tweaking, i have a placeholder script with just an echo to screen in it.

 

script will be stored local to enable it to be user edited.

 

but really needs a scripting guru to make a default template script.

 

 

 

thus far , with this inotify script

 

#!/bin/sh
while inotifywait -r -e create /watch-folder; do
/bin/bash /script/convert.sh
echo "Converting file(s)"
done

 

 

and this conversion script, not in the build yet.

 

 #!/bin/bash
for file in /watch-folder/*
do HandBrakeCLI -v -i "$file" -o "$file".converted.mp4 --preset iPad ;

#uncomment next line to delete original
#rm $file

done

 

it's converting a file i dump in the watch folder.

Link to comment

Please be gentle ... WTF is guacamole and why would I use it?

 

[sigh] because I never believe an answer will be that easy to find I revise my question: what is really better about guac vs. what is being used now.

 

And exactly how does one ""edit the template, add port 3389"

Link to comment

Please be gentle ... WTF is guacamole and why would I use it?

 

[sigh] because I never believe an answer will be that easy to find I revise my question: what is really better about guac vs. what is being used now.

 

And exactly how does one ""edit the template, add port 3389"

 

Well, guacamole is for chips

 

in unRaid terms is an awesome vnc, rdp, blah blah remote connection software.

it can connect to anything pretty much and display the screen.

 

edit the template means go to the container and add the port 3389.

 

http://guac-dev.org/

Link to comment

Please be gentle ... WTF is guacamole and why would I use it?

 

[sigh] because I never believe an answer will be that easy to find I revise my question: what is really better about guac vs. what is being used now.

 

And exactly how does one ""edit the template, add port 3389"

 

Well, guacamole is for chips

 

in unRaid terms is an awesome vnc, rdp, blah blah remote connection software.

it can connect to anything pretty much and display the screen.

 

edit the template means go to the container and add the port 3389.

 

http://guac-dev.org/

 

The built in web ui is guac as well. So no need to add another container for guacamole. Isn't that right sparky?

Link to comment

Please be gentle ... WTF is guacamole and why would I use it?

 

[sigh] because I never believe an answer will be that easy to find I revise my question: what is really better about guac vs. what is being used now.

 

And exactly how does one ""edit the template, add port 3389"

 

Well, guacamole is for chips

 

in unRaid terms is an awesome vnc, rdp, blah blah remote connection software.

it can connect to anything pretty much and display the screen.

 

edit the template means go to the container and add the port 3389.

 

http://guac-dev.org/

 

The built in web ui is guac as well. So no need to add another container for guacamole. Isn't that right sparky?

 

indeed...

 

Link to comment

Please be gentle ... WTF is guacamole and why would I use it?

 

[sigh] because I never believe an answer will be that easy to find I revise my question: what is really better about guac vs. what is being used now.

 

And exactly how does one ""edit the template, add port 3389"

 

what he said

 

 

Well, guacamole is for chips

 

in unRaid terms is an awesome vnc, rdp, blah blah remote connection software.

it can connect to anything pretty much and display the screen.

 

edit the template means go to the container and add the port 3389.

 

http://guac-dev.org/

 

The built in web ui is guac as well. So no need to add another container for guacamole. Isn't that right sparky?

 

indeed...

Link to comment

 

 

thus far i've got inotfiy tools installed along with the cli version of handbrake.

 

the inotifiy script needs tweaking, i have a placeholder script with just an echo to screen in it.

 

script will be stored local to enable it to be user edited.

 

but really needs a scripting guru to make a default template script.

 

 

 

thus far , with this inotify script

 

#!/bin/sh
while inotifywait -r -e create /watch-folder; do
/bin/bash /script/convert.sh
echo "Converting file(s)"
done

 

 

and this conversion script, not in the build yet.

 

 #!/bin/bash
for file in /watch-folder/*
do HandBrakeCLI -v -i "$file" -o "$file".converted.mp4 --preset iPad ;

#uncomment next line to delete original
#rm $file

done

 

it's converting a file i dump in the watch folder.

 

 

 

 

log shows

 

Opening /watch-folder/Food Unwrapped.s05e01.mkv...
[01:32:46] CPU: Intel(R) Xeon(R) CPU E3-1240 v3 @ 3.40GHz
[01:32:46] - Intel microarchitecture Haswell
[01:32:46] - logical processor count: 8
[01:32:46] OpenCL: library not available
[01:32:46] hb_scan: path=/watch-folder/Food Unwrapped.s05e01.mkv, title_index=1
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening /watch-folder/Food Unwrapped.s05e01.mkv/BDMV/index.bdmv
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening /watch-folder/Food Unwrapped.s05e01.mkv/BDMV/BACKUP/index.bdmv
libbluray/bluray.c:2182: nav_get_title_list(/watch-folder/Food Unwrapped.s05e01.mkv) failed
[01:32:46] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 5.0.1
libdvdread: Encrypted DVD support unavailable.
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[01:32:46] dvd: not a dvd - trying as a stream/file instead
Input #0, matroska,webm, from '/watch-folder/Food Unwrapped.s05e01.mkv':
Duration: 00:23:30.20, start: 0.000000, bitrate: N/A
Stream #0.0: Video: h264 (High), yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 25 fps, 1k tbn, 50 tbc (default)
Stream #0.1: Audio: aac, 48000 Hz, stereo, fltp (default)
[01:32:46] scan: decoding previews for title 1
[01:32:46] scan: audio 0x1: aac, rate=48000Hz, bitrate=1 Unknown (AAC) (2.0 ch)
Scanning title 1 of 1, preview 4, 40.00 %[01:32:46] scan: 10 previews, 1280x720, 25.000 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 1:1
Scanning title 1 of 1, preview 10, 100.00 %[01:32:46] libhb: scan thread found 1 valid title(s)
+ title 1:
+ stream: /watch-folder/Food Unwrapped.s05e01.mkv
+ duration: 00:23:30
+ size: 1280x720, pixel aspect: 1/1, display aspect: 1.78, 25.000 fps
+ autocrop: 0/0/0/0
+ support opencl: no
+ support hwd: not built-in
+ chapters:
+ 1: cells 0->0, 0 blocks, duration 00:23:30
+ audio tracks:
+ 1, Unknown (AAC) (2.0 ch) (iso639-2: und)
+ subtitle tracks:
+ Using preset: iPad
[01:32:46] 1 job(s) to process
[01:32:46] starting job
[01:32:46] work: sanitizing track 1 mixdown Dolby Pro Logic II to Stereo
[01:32:46] sync: expecting 35255 video frames
[01:32:46] work: only 1 chapter, disabling chapter markers
[01:32:46] job configuration:
[01:32:46] * source
[01:32:46] + /watch-folder/Food Unwrapped.s05e01.mkv
[01:32:46] + title 1, chapter(s) 1 to 1
[01:32:46] + container: matroska,webm
[01:32:46] * destination
[01:32:46] + /watch-folder/Food Unwrapped.s05e01.mkv.converted.mp4
[01:32:46] + container: MPEG-4 (libavformat)
[01:32:46] * video track
[01:32:46] + decoder: h264
[01:32:46] + filters
[01:32:46] + Framerate Shaper (2:27000000:900000)
[01:32:46] + frame rate: 25.000 fps -> peak rate limited to 30.000 fps
[01:32:46] + Crop and Scale (1280:720:0:0:0:0)
[01:32:46] + source: 1280 * 720, crop (0/0/0/0): 1280 * 720, scale: 1280 * 720
[01:32:46] + loose anamorphic
[01:32:46] + storage dimensions: 1280 * 720, mod 2
[01:32:46] + pixel aspect ratio: 1 / 1
[01:32:46] + display dimensions: 1280 * 720
[01:32:46] + encoder: H.264 (libx264)
[01:32:46] + preset: medium
[01:32:46] + profile: high
[01:32:46] + level: 3.1
[01:32:46] + quality: 20.00 (RF)
[01:32:46] * audio track 1
[01:32:46] + decoder: Unknown (AAC) (2.0 ch) (track 1, id 0x1)
[01:32:46] + samplerate: 48000 Hz
[01:32:46] + mixdown: Stereo
[01:32:46] + encoder: AAC (libavcodec)
[01:32:46] + bitrate: 160 kbps, samplerate: 48000 Hz
[01:32:47] reader: first SCR 0 id 0x0 DTS 0
[01:32:47] encx264: encoding at constant RF 20.000000
[01:32:47] encx264: unparsed options: level=3.1:vbv-bufsize=17500:vbv-maxrate=17500
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
x264 [info]: profile High, level 3.1

Link to comment

found a better script that i tweaked a bit...

 

#!/bin/bash

########### EDITABLE VARIABLES ##########

DEST_EXT=mp4
PRESET=Ipad

#########################################



##### DO NOT CHANGE ANYTHING BELOW HERE ###############

SRC=/watch-folder
DEST=/Output
HANDBRAKE_CLI=HandBrakeCLI



IFS=$(echo -en "\n\b")
for FILE in `ls $SRC`
do
        filename=$(basename $FILE)
        extension=${filename##*.}
        filename=${filename%.*}

        $HANDBRAKE_CLI -i $SRC/$FILE -o $DEST/$filename.$DEST_EXT --preset $PRESET

chown nobody:users $DEST/$filename.$DEST_EXT

done

 

 

this one is in the build of the handbrake-scriptable in my beta repo.

 

if there aren't any issues i'll merge it into this docker to have the gui and cli all in one, you can edit in the gui like normal without ever having to use the CLI , but it's there if you should ever want to , or to use the watch folder.

Link to comment

This is great. I like the second script. It uses built-in presets and in most cases is sufficient. FYI all HandbrakeCLI options can be found here

 

https://trac.handbrake.fr/wiki/CLIGuide

 

So following what you did, command line can be tweaked to include different options, like container, resolution, etc

 

Here you will find info about built in presets

 

https://trac.handbrake.fr/wiki/BuiltInPresets

 

As you can see they are pretty long, but you can always adjust one of them to your needs.

 

 

Link to comment

This is great. I like the second script. It uses built-in presets and in most cases is sufficient. FYI all HandbrakeCLI options can be found here

 

https://trac.handbrake.fr/wiki/CLIGuide

 

So following what you did, command line can be tweaked to include different options, like container, resolution, etc

 

Here you will find info about built in presets

 

https://trac.handbrake.fr/wiki/BuiltInPresets

 

As you can see they are pretty long, but you can always adjust one of them to your needs.

 

what i'm going to do is provide the script that uses the presets i posted up there ^^^ somewhere.  it will serve as a basic template, users can change preset and file extension etc... , more adventurous types can make their own scripts based on that one, providing they use the same paths etc....

 

i'll merge the scripting version and this version sometime today, the size difference between the two versions is less than 15mb and GUI users can use the container without even knowing the CLI version is there.

Link to comment

This is an awesome Docker that is sending another VM on retirement  :D

 

If I'm encoding MKV files to x.265 the server is running at 90-100% CPU utilization. I see an average of about 9fps (XEON E3-1240 V2) vs.  >12fps on my desktop machine running on Mac OS X Yosemite (i7-4771).

 

CPUBoss review is showing a slightly higher score for the XEON - so shouldn't the encoding on the XEON be slightly faster (well GeekBench and Passmark are showing higher values for the i7  ::)) ?

 

I wasn't sure if this is rather for the HW section of the forum and it's just out of curiosity....

Link to comment

This is an awesome Docker that is sending another VM on retirement  :D

 

If I'm encoding MKV files to x.265 the server is running at 90-100% CPU utilization. I see an average of about 9fps (XEON E3-1240 V2) vs.  >12fps on my desktop machine running on Mac OS X Yosemite (i7-4771).

 

CPUBoss review is showing a slightly higher score for the XEON - so shouldn't the encoding on the XEON be slightly faster (well GeekBench and Passmark are showing higher values for the i7  ::)) ?

 

I wasn't sure if this is rather for the HW section of the forum and it's just out of curiosity....

 

your mac isn't running a storage server ... just saying, lol.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.