scripts/sub_extract_convert

24 lines
627 B
Plaintext
Raw Permalink Normal View History

2020-07-30 13:44:20 +00:00
#!/usr/bin/env bash
# usage: $scriptname $files $output_sub_format
output_sub_format=${@: -1}
2022-07-09 19:18:29 +00:00
for i in "$@"
2020-07-30 13:44:20 +00:00
do
if [ ! -e "$i" ];
then
echo "File does not exist."
continue
fi
index=$(ffprobe -v 8 -show_streams -select_streams s "$i" | grep index | cut --delimiter="=" -f 2)
2022-07-09 19:18:29 +00:00
if [ -z "$index" ];
2020-07-30 13:44:20 +00:00
then
echo "No subtitle streams found."
exit
fi
ffprobe -v 8 -show_streams -select_streams "$i"
filename=${i%.*}
2022-07-09 19:18:29 +00:00
mkvextract "$i" tracks "$index":"${filename}.en.ass"
if [ -n "$1" ];
2020-07-30 13:44:20 +00:00
then
2022-07-09 19:18:29 +00:00
subtitleedit /convert "${filename}.en.ass" "$output_sub_format" 2>/dev/null | grep --color=none ass
2020-07-30 13:44:20 +00:00
fi
done