Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] macOS/Linux - Batch extract subtitles with fmpeg
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter
March 15, 2025 6:35 AM
Found this neat little trick how to extract subtitles in batch using ffmpeg.
for f in *.mkv; do ffmpeg -i "$f" -map 0:s:m:language:eng "${f%.*}.srt"; done
This assumes you are in the directory where the MKV video files are, and that you want to extract the english subtitles, and that the subtitles are in SRT format. Note that "0:s:m" assumes that you are looking at the first subtitle only!
Say you want to do the same for MP4 files and you're looking for Dutch SRT subtitles, then you can try one of these two:
for f in *.mp4; do ffmpeg -i "$f" -map 0:s:m:language:nld "${f%.*}.srt"; done
for f in *.mp4; do ffmpeg -i "$f" -map 0:s:m:language:dut "${f%.*}.srt"; done
Note the differences and keep in mind that you will need ffmpeg.