diff options
author | Sacha Chua <sacha@sachachua.com> | 2022-11-05 07:55:43 -0400 |
---|---|---|
committer | Sacha Chua <sacha@sachachua.com> | 2022-11-05 07:55:43 -0400 |
commit | 5f83a3fbeb91dea9c77925e83b09b27427435cb9 (patch) | |
tree | cd8581db094b1fda2cc4d12a67db65238b6cf0a8 /roles | |
parent | d33a5923c335332f7401826e01eb2033af717a76 (diff) | |
parent | a0e8a535be2b870eafa8feecde003d98c638bcb2 (diff) | |
download | emacsconf-ansible-5f83a3fbeb91dea9c77925e83b09b27427435cb9.tar.xz emacsconf-ansible-5f83a3fbeb91dea9c77925e83b09b27427435cb9.zip |
Merge branch 'main' of git.emacsconf.org:pub/emacsconf-ansible into main
Diffstat (limited to '')
-rwxr-xr-x[-rw-r--r--] | roles/prerec/templates/reencode.sh | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/roles/prerec/templates/reencode.sh b/roles/prerec/templates/reencode.sh index d0c98c3..e3a82eb 100644..100755 --- a/roles/prerec/templates/reencode.sh +++ b/roles/prerec/templates/reencode.sh @@ -1,5 +1,43 @@ -Q=32 -CPU=8 -TIME_LIMIT='' -ffmpeg -y -i "$1" $TIME_LIMIT -c:v libvpx-vp9 -b:v 0 -crf $Q -an -row-mt 1 -tile-columns 2 -tile-rows 2 -cpu-used $CPU -g 240 -pass 1 -f webm -threads $CPU /dev/null && - ffmpeg -y -i "$1" $TIME_LIMIT -c:v libvpx-vp9 -b:v 0 -crf $Q -c:a libopus -row-mt 1 -tile-columns 2 -tile-rows 2 -cpu-used $CPU -pass 2 -g 240 -threads $CPU "$2" +#!/usr/bin/env bash + +set -euo pipefail + +# Defaults +q=32 +cpu=4 +time_limit="" +print_only=false + +while getopts :q:c:t:s OPT; do + case $OPT in + q|+q) + q="$OPTARG" + ;; + c|+c) + cpu="$OPTARG" + ;; + t|+t) + time_limit="-to $OPTARG" + ;; + s) + print_only=true + ;; + *) + echo "usage: `basename $0` [+-q ARG] [+-c ARG} [--] ARGS..." + exit 2 + esac +done +shift `expr $OPTIND - 1` +OPTIND=1 + +command="$(cat<<EOF +ffmpeg -y -i "$1" $time_limit -c:v libvpx-vp9 -b:v 0 -crf $q -an -row-mt 1 -tile-columns 2 -tile-rows 2 -cpu-used $cpu -g 240 -pass 1 -f webm -threads $cpu /dev/null && + ffmpeg -y -i "$1" $time_limit -c:v libvpx-vp9 -b:v 0 -crf $q -c:a libopus -row-mt 1 -tile-columns 2 -tile-rows 2 -cpu-used $cpu -pass 2 -g 240 -threads $cpu "$2" +EOF +)" + +if [ $print_only == true ]; then + echo "$command" +else + eval "$command" +fi |