diff options
author | Gordon GECOS <u@adam> | 2022-11-28 22:54:05 -0500 |
---|---|---|
committer | Andrew Cady <d@cryptonomic.net> | 2023-04-04 16:37:00 -0400 |
commit | 861b9ae3f2e250e45efc5bd4e8e045cd8c0da1bb (patch) | |
tree | f261c08af9e71fad372fd08b3bb3a9041d3cf9cf | |
parent | 20ee182befabc679b12d26e7ee64f52f58332802 (diff) |
new command: webm2opus
-rwxr-xr-x | dot/local/bin/webm2opus | 32 |
1 files changed, 32 insertions, 0 deletions
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 @@ | |||
1 | #!/bin/sh | ||
2 | OVERWRITE= | ||
3 | printf_ds() | ||
4 | { | ||
5 | local s | ||
6 | [ "$2" = 1 ] && s= || s=s | ||
7 | printf "$1" "$2" "$s" | ||
8 | } | ||
9 | |||
10 | fail=0 | ||
11 | skip=0 | ||
12 | for f in "$@" | ||
13 | do | ||
14 | out=${f%.webm}.opus | ||
15 | if [ ! "$OVERWRITE" -a -e "$out" ] | ||
16 | then | ||
17 | skip=$((skip + 1)) | ||
18 | continue | ||
19 | fi | ||
20 | ffmpeg -i "$f" -c:a copy "$out" || fail=$((fail + 1)) | ||
21 | done | ||
22 | |||
23 | if [ "$skip" -gt 0 ] | ||
24 | then | ||
25 | printf_ds 'Warning: refused to overwrite %d file%s\n' "$skip" "$s" >&2 | ||
26 | fi | ||
27 | |||
28 | if [ "$fail" -gt 0 ] | ||
29 | then | ||
30 | printf_ds 'Error: ffmpeg failed to convert %d file%s\n' "$fail" >&2 | ||
31 | exit 1 | ||
32 | fi | ||