summaryrefslogtreecommitdiffstats
path: root/roles/caption/templates/reencode.sh
diff options
context:
space:
mode:
authorSacha Chua <sacha@sachachua.com>2022-11-05 07:55:05 -0400
committerSacha Chua <sacha@sachachua.com>2022-11-05 07:55:05 -0400
commit0b07963c81155b621dd45b878b869a78b8c9de49 (patch)
tree86c8f7756784cb71d246e40967856c528a3edad4 /roles/caption/templates/reencode.sh
parentffe7c227fa5a617e23f74cab5f41758e00a6be5c (diff)
downloademacsconf-ansible-0b07963c81155b621dd45b878b869a78b8c9de49.tar.xz
emacsconf-ansible-0b07963c81155b621dd45b878b869a78b8c9de49.zip
Caption updates
Diffstat (limited to 'roles/caption/templates/reencode.sh')
-rwxr-xr-xroles/caption/templates/reencode.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/roles/caption/templates/reencode.sh b/roles/caption/templates/reencode.sh
new file mode 100755
index 0000000..e3a82eb
--- /dev/null
+++ b/roles/caption/templates/reencode.sh
@@ -0,0 +1,43 @@
+#!/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