From 861b9ae3f2e250e45efc5bd4e8e045cd8c0da1bb Mon Sep 17 00:00:00 2001 From: Gordon GECOS Date: Mon, 28 Nov 2022 22:54:05 -0500 Subject: new command: webm2opus --- dot/local/bin/webm2opus | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 dot/local/bin/webm2opus diff --git a/dot/local/bin/webm2opus b/dot/local/bin/webm2opus new file mode 100755 index 0000000..07688dd --- /dev/null +++ b/dot/local/bin/webm2opus @@ -0,0 +1,32 @@ +#!/bin/sh +OVERWRITE= +printf_ds() +{ + local s + [ "$2" = 1 ] && s= || s=s + printf "$1" "$2" "$s" +} + +fail=0 +skip=0 +for f in "$@" +do + out=${f%.webm}.opus + if [ ! "$OVERWRITE" -a -e "$out" ] + then + skip=$((skip + 1)) + continue + fi + ffmpeg -i "$f" -c:a copy "$out" || fail=$((fail + 1)) +done + +if [ "$skip" -gt 0 ] +then + printf_ds 'Warning: refused to overwrite %d file%s\n' "$skip" "$s" >&2 +fi + +if [ "$fail" -gt 0 ] +then + printf_ds 'Error: ffmpeg failed to convert %d file%s\n' "$fail" >&2 + exit 1 +fi -- cgit v1.2.3