How to batch convert subtitles inside an mkv from .ass to .srt
Go to solution
Solved by WereCatf,
7 minutes ago, elfensky said:it seems to convert, but it seems not to be able to write the file to disk. I tried running with sudo, no difference
*sigh* No, you don't need sudo to run the script. It seems either the script didn't correctly catch the subtitle-language from mkvinfo, or it's not specified at all. I added a small tweak to the script now:
#!/bin/bash for x in *.mkv do numTracks=$(mkvinfo "$x"|grep -c "S_TEXT/ASS") if [ $numTracks -ne 1 ] then echo "No tracks to convert or more than one! Aborting." exit 1 fi for subTrack in $(mkvinfo "$x"|grep -B4 "S_TEXT/ASS"|grep "Track UID"|cut -d ":" -f 2) do trackLang=$(mkvinfo "$x"|grep -B4 "S_TEXT/ASS"|grep -C3 "Track UID: $subTrack"|grep "Language:"|cut -d ":" -f 2|tr -d '\040\011\012\015') if [ -z "$trackLang" ] then trackLang="eng" fi let subTrack-- ffmpeg -i "$x" -map 0:$subTrack out.srt if [ $? -ne 0 ] then echo "Failed to convert subtitle to SRT!" exit 1 fi mkvmerge -o output.mkv "$x" --language 0:$trackLang --default-track "0:yes" out.srt if [ $? -ne 0 ] then echo "Failed to merge subtitle to $x!" exit 1 fi rm out.srt mkdir -p Converted echo "Successfully converted $x to output.mkv with added SRT-subs!" mv output.mkv "Converted/$x" break done done
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now