Last active
December 13, 2022 20:22
-
-
Save abjdiat/6383447 to your computer and use it in GitHub Desktop.
Bash Script To Extract Subtitles From MKV file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
nano sub-extractor.sh | |
###paste the following | |
filename="$1" | |
if [[ $filename ]] | |
then | |
m=$(mkvinfo $filename|grep 'No EBML head found'); | |
if [[ $m ]]; | |
then echo "This is not a valid mkv file"; | |
else | |
echo "proceeding..."; | |
mm=$(mkvinfo $filename|grep -i -A 2 -B 2 subtitle); | |
if [[ $mm ]]; | |
then | |
echo "subtitles found, proceeding..."; | |
mmm=$(echo $mm|grep -o 'mkvextract: [0-9]*'|grep -o '[0-9]*') | |
arry1=$(echo $mmm|tr " " "\n "); | |
for m in $arry1 | |
do mkvextract tracks $filename $mmm:${filename:0:-4}"_"$mmm; | |
done | |
else | |
echo "no subs"; | |
fi; | |
fi; | |
else | |
echo "no file name given"; | |
fi; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment