I have a simple task - extract subtitle for exact language from tvshows. For example, I want to extract English subtitles from Netflix's show. As you know there're a few different types of subtitles: forced, full and SDH. So I want to extract all of them if it has eng language code.
To extract 1 subtitle from file I used this code for windows:
FOR %%i IN (*.mkv) DO (ffmpeg.exe -i "%%i" -map 0:s:m:language:eng -c copy "%%~ni".eng.srt)
It worked fine with 1 english subtitle per file. But if it contains 2, ffmpeg shows error
SRT supports only a single subtitles stream
MI is...
- Stream #0:2(eng): Subtitle: subrip
- Stream #0:3(eng): Subtitle: subrip
- Stream #0:4(ara): Subtitle: subrip
- ...
So I should set 2 or more output files. I tried to figure out how to do this and found similar threads on reddit and stacksoverflow. They said there's no way to do this without ffprobe. So I used ffprobe to parse all subtitle tracks and their language code.
FOR %%i IN (*.mkv) DO (ffprobe -loglevel error -select_streams s -show_entries stream=index:stream_tags=language -of csv=p=0 -i %%i > subs.txt)
File contains this info:
- 2,eng
- 3,eng
- 4,ara
- ...
As I understand I should use integers and set them values 2 and 3. I want to get output like this
- MovieName.2.eng.srt
- MovieName.3.eng.srt
If it easier to extract all subs, let it be. I tried to do this too but I dont know how to set integers and use them:( So what I should do? Thanks in advance