#!/bin/bash set -eu THIS_DIR="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)" PAL24FPS=0 ARGS=( "$@" ) for i in $(seq 0 "$(($# - 1))"); do case "${ARGS[$i]}" in --output|-o) OUTPUTFILE="${ARGS[$i+1]}" continue ;; --pal24fps) PAL24FPS=1 AENCODER="copy" ARGS+=("--cfr" "--rate" "25") ;; *) continue esac unset "ARGS[$i]" done set -- "${ARGS[@]}" set -x HandBrakeCLI \ --encoder x264 --x264-preset slow --quality 20 --loose-anamorphic \ --aencoder "${AENCODER:-fdk_aac}" --mixdown 7point1 --aq 3 \ --audio-lang-list eng \ --subtitle scan --subtitle-forced \ --markers \ "$@" if [ "$PAL24FPS" -eq 1 ]; then mv "$OUTPUTFILE" "pal25fps $OUTPUTFILE" "${THIS_DIR}/fix-pal-speedup" "pal25fps $OUTPUTFILE" "$OUTPUTFILE" rm "pal25fps $OUTPUTFILE" fi