diff options
Diffstat (limited to '.local')
-rw-r--r-- | .local/bin/subextract | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/.local/bin/subextract b/.local/bin/subextract new file mode 100644 index 0000000..1b7018d --- /dev/null +++ b/.local/bin/subextract @@ -0,0 +1,14 @@ +#!/bin/sh + +# assign variables +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") + +# dump subtitle +ffmpeg -i "$1" -c copy -map "$stream" "$output_filename" + +# remove empty file +if [ ! -s "$output_filename" ]; then rm "$output_filename" ; fi |