Add mac support

This commit is contained in:
Arkadiusz Wieczorek 2022-07-13 14:00:32 +02:00
parent 04d54485d9
commit 40275ad867

View File

@ -1,15 +1,14 @@
#!/bin/bash -x #!/bin/bash -x
# usage: change-length.sh 1.007 input.mp4 output.mp4 [--fast] # usage: change-length.sh 1.007 input.mp4 output.mp4 [0] [--fast]
# ^output.mp4 will be be 7% longer
# --fast is faster, but slightly more risky
set -euo pipefail set -euo pipefail
RATIO=$1; RATIO=$1;
IN_FILE=$2; IN_FILE=$2;
OUT_FILE=$3; 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 ""); 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" echo ratio set to "$RATIO"
@ -51,8 +50,11 @@ slow () {
echo "running with filter $FILTER"; echo "running with filter $FILTER";
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"; 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"; fi;
} }
fast (){ fast (){