Skip to content

Instantly share code, notes, and snippets.

@wechain
Forked from dev01d/to_hevc.sh
Created November 8, 2018 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wechain/a7f818600158695a7015b9060818c78d to your computer and use it in GitHub Desktop.
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.
#!/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