From 707483813e83a97aac107fa259af2669a3b559b4 Mon Sep 17 00:00:00 2001 From: James <> Date: Fri, 17 Jun 2022 22:37:53 +1000 Subject: [PATCH] Fix preset detection A preset file can contain more than one preset. As such, it's required to specify the actual "PresetName" for the preset that needs to be used, in addition to the actual *.json preset file. --- README.md | 6 ++++++ encode.sh | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2499a7e..1b36b1e 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,12 @@ Use this rudimentary script to batch encode a folder of video files with HandbrakeCLI, using a custom preset. +#### Prerequisites + +``` +sudo dnf install jq HandBrake HandBrake-gui +``` + #### How to use 1. Create a custom Handbrake preset. diff --git a/encode.sh b/encode.sh index 92f0978..8409e49 100755 --- a/encode.sh +++ b/encode.sh @@ -2,7 +2,8 @@ # Load an exported *.json Handbrake preset file PRESET='--preset-import-file' -PRESETFILE='x265_10bit_crf23_slow_pt_audio_or_op192' +PRESETFILE='x265_10bit_crf23_slow_pt_audio_or_op192.json' +PRESETNAME=$(cat $PRESETFILE | jq '.PresetList[].PresetName' | cut -d'"' -f 2) # Set the source directory as the current directory SRC="." @@ -23,5 +24,5 @@ EXT='mkv' IFS=$'\n' for INPUTFILE in `find . -type f -execdir basename {} ';'`; do OUTPUTFILE=${INPUTFILE%.*} - HandBrakeCLI "$PRESET" "$PRESETFILE" -i "$SRC"/"$INPUTFILE" -o "$DEST"/"$OUTPUTFILE""$OUTPUTSUFFIX"."$EXT" + HandBrakeCLI "$PRESET" "$PRESETFILE" -Z "$PRESETNAME" -i "$SRC"/"$INPUTFILE" -o "$DEST"/"$OUTPUTFILE""$OUTPUTSUFFIX"."$EXT" done -- GitLab