From c4e4910c4fd78f811e9e5d84d75ca15e9d5ee9e9 Mon Sep 17 00:00:00 2001 From: Ivo Woltring Date: Thu, 7 Dec 2017 12:09:51 +0100 Subject: [PATCH] Initial commit --- .ignore | 6 ++++++ README.md | 22 ++++++++++++++++++++++ bin/m4v.sh | 30 ++++++++++++++++++++++++++++++ bin/m4vAll.sh | 6 ++++++ 4 files changed, 64 insertions(+) create mode 100644 .ignore create mode 100644 README.md create mode 100644 bin/m4v.sh create mode 100644 bin/m4vAll.sh diff --git a/.ignore b/.ignore new file mode 100644 index 0000000..dd48ed3 --- /dev/null +++ b/.ignore @@ -0,0 +1,6 @@ +.idea/ +*.iml +*.iws +.DS_* +_.* +target/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..2598443 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# Handbrake on Synology Nas + +This project is the companion code to [this](http://ivo2u.nl/dA) blog post. + +It contains the code necessary to get Handbrake CLI working on your Synology NAS. + +## usage + +* Copy scripts in the bin folder to your synology ~/bin folder +* make sure the ~/bin folder is part of your PATH +* make sure the files are executable `chmod +x ~/bin/m4v*` +* Change the `CONVERTED_FILE_LOCATION` in `m4v.sh` to point to a location on your NAS +* Change directory to you have a `*.mkv` file to convert +* `m4v.sh ".mkv"` wait and see it arrive in `CONVERTED_FILE_LOCATION` + +Note that the first time will take longer because Docker needs to download the image +of course convertion will always take quite a bit of time so you might want to start +conversions from a `screen` (read about in on the internet) to be able to log off. + +Have fun, + +Ivo. \ No newline at end of file diff --git a/bin/m4v.sh b/bin/m4v.sh new file mode 100644 index 0000000..e8bb096 --- /dev/null +++ b/bin/m4v.sh @@ -0,0 +1,30 @@ +#!/bin/sh +############################################################################### +# Please change the following variables to suit your needs +############################################################################### + +# Place where the m4v files should be saved to... +CONVERTED_FILE_LOCATION="/volume1/video/m4v/inbox" + +############################################################################### +# DO NOT CHANGE CODE BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING +############################################################################### +SAVEIFS=$IFS +IFS=$(echo -en "\n\b") +mkv="$(basename $1)" +map="$(dirname $1)" +m4v="${mkv%.*}.m4v" +m4v="$(basename $m4v)" +docker run --rm \ + --cpuset-cpus="1-2" \ + --name handbrake \ + -v "$(pwd)/$map:/input:ro" \ + -v "${CONVERTED_FILE_LOCATION}:/output:rw" \ + supercoder/docker-handbrake-cli:latest \ + -i "/input/$mkv" \ + -o "/output/$m4v" \ + -e x264 -q 20.0 -r 30 --pfr -a 1 -E faac -B 160 -6 dpl2 -R Auto \ + -D 0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 \ + -f mp4 -X 1280 -Y 720 --loose-anamorphic --modulus 2 -m \ + --x264-preset medium --h264-profile high --h264-level 3.1 +IFS=$SAVEIFS \ No newline at end of file diff --git a/bin/m4vAll.sh b/bin/m4vAll.sh new file mode 100644 index 0000000..9e16a7e --- /dev/null +++ b/bin/m4vAll.sh @@ -0,0 +1,6 @@ +#!/bin/sh +find . -iname "*mkv" -print0 | while read -d $'\0' file +do + m4v.sh "$file" + test $? -gt 0 && break; +done \ No newline at end of file