Created
July 2, 2017 16:08
-
-
Save kowalcj0/b37fb623456c864df605415ebb391a8d to your computer and use it in GitHub Desktop.
Run HandBrake & MKVToolNix on a headless FreeBSD jail (FreeNas)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1 - Create a jail called `convert` using `pluginjail-10.3` template | |
# 2 - list all jails | |
jls | |
JID IP Address Hostname Path | |
1 - convert /mnt/volume/jails/convert | |
# 3 - connect to our jail | |
jexec 1 sh | |
# 4 - update | |
pkg update && pkg upgrade | |
# 5 - OPTIONAL - install bash | |
pkg install bash | |
exit | |
# 5a - connect to our jail with `bash` | |
jexec 1 bash | |
# 6 - install all required packages | |
pkg install xauth | |
pkg install xkeyboard-config | |
pkg install mkvtoolnix | |
pkg install handbrake | |
# 7 - enable SSH | |
vi /etc/rc.conf | |
sshd_enable="YES" | |
# 8 - enable X11 forwarding | |
vi /etc/ssh/sshd_config | |
AllowTcpForwarding yes | |
X11Forwarding yes | |
X11DisplayOffset 10 | |
X11UseLocalhost no | |
... | |
PermitRootLogin yes | |
# 9 - restart SSH daemon | |
service sshd restart | |
# 10 - generate DBUS UUID required by `xkb` (`xkeyboard`) | |
dbus-uuidgen > /etc/machine-id | |
# 11 - install `lame` which is required by HandBrake | |
portsnap fetch extract | |
cd /usr/ports/audio/lame | make install clean | |
# 12 - run MKVToolNix or HandBrake | |
ssh -X root@convert mkvtoolnix-gui | |
ssh -X root@convert HandBrake |
Thanks for this. I didnt use the X Server part, but installed Handbrake in a jail and I am now starting batch conversions with handbrake with a small script and nohup. Works great!
Export your favourite Handbrake Preset from the normal GUI version and put it in the same folder. Change the files and folders in this example to your specific ones:
#!/bin/bash
SRC="/sourcefolder"
DEST="/destinationfolder"
DEST_EXT=mp4
HANDBRAKE_CLI=HandBrakeCLI
for FILE in "$SRC"/*
do
filename=$(basename "$FILE")
extension=${filename##*.}
filename=${filename%.*}
$HANDBRAKE_CLI --preset-import-file /handbrakepreset.json -Z HANDBRAKEPRESETname -i "$FILE" -o "$DEST"/"$filename".$DEST_EXT
done
Then ssh into your machine
sudo jexec 1
(go into the jail)
cd /folder
(go to the folder of the script and preset)
nohup sh SCRIPTNAME &
(start the script)
Even if you kill the SSH connection, it will continue to convert all files in the folder. Make sure there are only videofiles, otherwise it will stop without converting all of them.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
even if you do all this, there won't be an X server running, so
ssh -X root@convert HandBrake
will fail with: cannot connect to X server