From 40275ad867274f4ff94150302725eb419fda7c86 Mon Sep 17 00:00:00 2001 From: Arkadiusz Wieczorek Date: Wed, 13 Jul 2022 14:00:32 +0200 Subject: [PATCH] Add mac support --- change-length-video-HWACCEL.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/change-length-video-HWACCEL.sh b/change-length-video-HWACCEL.sh index 66a9e0c..10016e7 100755 --- a/change-length-video-HWACCEL.sh +++ b/change-length-video-HWACCEL.sh @@ -1,15 +1,14 @@ #!/bin/bash -x -# usage: change-length.sh 1.007 input.mp4 output.mp4 [--fast] -# ^output.mp4 will be be 7% longer -# --fast is faster, but slightly more risky +# usage: change-length.sh 1.007 input.mp4 output.mp4 [0] [--fast] set -euo pipefail RATIO=$1; IN_FILE=$2; OUT_FILE=$3; -MODE=${4-"--slow"}; +IS_MAC=${4-"0"}; +MODE=${5-"--slow"}; BITRATE=$(ffmpeg -i "$IN_FILE" 2>&1 | grep bitrate | awk -F", " '{print $3}' | sed 's/bitrate: //' | sed 's/ //' | sed 's/b\/s//' || echo ""); echo ratio set to "$RATIO" @@ -51,8 +50,11 @@ slow () { echo "running with filter $FILTER"; - ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i "$IN_FILE" -b:v $BITRATE -filter_complex "$FILTER" "${OPTS[@]}" -c:v h264_vaapi "$OUT_FILE"; -# ffmpeg -i "$IN_FILE" -filter_complex "$FILTER" "${OPTS[@]}" "$OUT_FILE"; + if [ "$IS_MAC" -eq 1 ]; then + ffmpeg -c:v h264_videotoolbox -i "$IN_FILE" -b:v $BITRATE -filter_complex "$FILTER" "${OPTS[@]}" -c:v h264_vaapi "$OUT_FILE"; + else + ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i "$IN_FILE" -b:v $BITRATE -filter_complex "$FILTER" "${OPTS[@]}" -c:v h264_vaapi "$OUT_FILE"; + fi; } fast (){