diff --git a/convert-videos-for-plex.sh b/convert-videos-for-plex.sh index 3579a99..77c5a1f 100755 --- a/convert-videos-for-plex.sh +++ b/convert-videos-for-plex.sh @@ -80,6 +80,22 @@ GREEN='\033[0;32m' BLUE='\033[0;34m' NC='\033[0m' # No Color +version=$(ls /opt/homebrew/Cellar/handbrake 2>/dev/null) +if [ "$version" != "" ]; then + handbrake="/opt/homebrew/Cellar/handbrake/$version/bin/HandBrakeCLI" + echo "Handbrake $version" +else { + cli=$(which HandBrakeCLI) + if [ "$cli" != "" ]; then + handbrake="$cli" + version=$("$handbrake" --version 2>/dev/null | sed -n '1p') + echo "$version" + else + echo "handbrake not installed!" + fi + } +fi + function removeLock { if [[ -f "$1" ]]; then rm "$1" @@ -231,7 +247,8 @@ for i in "${path}"{,**/}*.*; do fi # Modified from http://pastebin.com/9JnS23fK - HandBrakeCLI -i "${fileIn}" -o "${fileOut}""_processing""${ext}" --preset="${qualityPreset}" -O ${subtitle} ${audio} + #HandBrakeCLI -i "${fileIn}" -o "${fileOut}""_processing""${ext}" --preset="${qualityPreset}" -O ${subtitle} ${audio} + "$handbrake" -i "${fileIn}" -o "${fileOut}""_processing""${ext}" --preset="${qualityPreset}" -O ${subtitle} ${audio} # if HandBrake did not exit gracefully, continue with next iteration if [[ $? -ne 0 ]]; then