summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter2021-09-13 22:18:35 +0100
committerPeter2021-09-13 22:18:35 +0100
commited0439a20bfd775c3b7dc64704faf24e42eb4bed (patch)
treec7312404688db0e2e61ab9263d23a902f5c0586b
parent96671721461ef1a14971c79f73699e48b386b539 (diff)
downloaddotfiles-ed0439a20bfd775c3b7dc64704faf24e42eb4bed.tar.gz
dotfiles-ed0439a20bfd775c3b7dc64704faf24e42eb4bed.tar.bz2
dotfiles-ed0439a20bfd775c3b7dc64704faf24e42eb4bed.zip
Support additional subtitle formats in subextract
-rwxr-xr-x.local/bin/subextract6
1 files changed, 4 insertions, 2 deletions
diff --git a/.local/bin/subextract b/.local/bin/subextract
index 1b7018d..bac09b0 100755
--- a/.local/bin/subextract
+++ b/.local/bin/subextract
@@ -4,8 +4,10 @@
filename=${1%%.*}
if [ -z "$2" ]; then language=nob; else language=$2; fi
if [ -z "$3" ]; then destination=.; else destination=$3; fi
-stream=$(ffmpeg -i "$1" 2>&1 | awk -v lang="$language" -F"[#(]" '$0~lang {print $2}')
-output_filename=$(printf %s/%s_%s.srt "$destination" "$filename" "$language")
+information=$(ffmpeg -i "$1" 2>&1)
+stream=$(echo "$information" | awk -v lang="$language" -F"[#(]" '$0~lang {print $2}')
+format=$(echo "$information" | awk -v lang="$language" -F":" '$0~lang {print $4}' | xargs)
+output_filename=$(printf %s/%s_%s.%s "$destination" "$filename" "$language" "$format")
# dump subtitle
ffmpeg -i "$1" -c copy -map "$stream" "$output_filename"