I am trying to extract (first, in case of many) subtitle track from mkv files (via CLI only, no GUIs) using ffmpeg or mkvextract.
But there is one downside to this: I have to write the output name manually. In a batch, you don't know if the subtitles are
.ass or maybe even a different format, so writing blindly
subs.srt does not sound like a good idea.
Is there a way to extract subtitles while maintaining the original format?
For example, does ffmpeg have a way to get subtitles format info then do something like the command above with the type? (ideally native method via the tool, OS agnostic)
I can do this:
ffmpeg -i video.mkv subs.srt
ffmpeg -i video.mkv -map 0:s:0 subs.srt
But is there a way to avoid specifying the output name? For example with mkvextract I can do this:
mkvextract attachments ..\input_video.mkv 1
And I will get the warning (not error):
"No destination file name specified, will use attachment name."
Which is actually the behavior I want, but that applies for attachments.
There is no
mkvextract subtitles as mkvextract considers the subtitles as part of tracks. So if track order is messed up and subtitles is not the 3rd track, using a similar command with mkvextract won't work.
ffmpeg: I am stuck with (possibly) wrong file extension
mkvextract: I have a risk of extracting some random track and not the subtitles.