Created
November 8, 2018 19:21
-
-
Save wechain/a7f818600158695a7015b9060818c78d to your computer and use it in GitHub Desktop.
This script automatically converts a directory of video files to H.265 HEVC with the nightly iteration of HandBrake and deletes the old files.
This file contains hidden or 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
#!/bin/bash | |
# | |
# This script automatically converts a directory of video files to H.265 HEVC with the nightly iteration of HandBrake. | |
# https://handbrake.fr/nightly.php | |
# The nightly is required because the current stable release (as of writing this) does not support the "hvc1" codec | |
# that tvOS requires on top of only really liking mp4/m4a. | |
# | |
if [ -z "$1" ]; then | |
SRC="." | |
else | |
SRC="$HOME/$1" | |
fi | |
find "$SRC" -iregex '.*\.\(mkv\|avi\)$' -exec bash -c 'HandBrakeCLI -i "$1" -o "${1%\.*}".mp4 -e x265 -q 22 -E av_aac --custom-anamorphic --keep-display-aspect' __ {} \; && find "$SRC" -iregex '.*\.\(mkv\|avi\)$' -exec rm -r {} \; | |
# | |
## Desktop notification | |
# | |
unameNote="$(uname -s)" | |
case "${unameNote}" in | |
Linux*) | |
notify-send "Encode complete." | |
;; | |
Darwin*) | |
osascript -e 'display notification "Encode complete." with title "HEVC Conversion"' | |
;; | |
*) | |
machine = "UNKNOWN:${unameOut}" | |
esac | |
echo ${desktopNotify} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment