FFmpeg Map English Subtitles or Audio Stream Only
Dynamic FFmpeg Subtitle Stream Mapping by Language
You can map English subs only by using -map 0:s:m:language:eng
. With FFmpeg you can dynamically map streams which match certain criteria such as language that you specify. If you’re looking for the 3-letter language codes go to https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes. This is very handy within script loops when calling the FFmpeg binary in case some streams within media containers differ. For additional example scripts for FFmpeg batch transcoding/remuxing check out this post blog.travisrunyard.us/ffmpeg-batch-transcode-audio. This is the syntax:
<stream #>:<video/audio/subtitle>:<metadata>:<property>:<value>
Map all subtitle streams where language is English:
0:s:m:language:eng
# full cli example: for f in *.mkv; do ffmpeg -y -i "$f" -default_mode infer_no_subs -map 0:v:0 -map 0:a:1 -map 0:s:m:language:eng -dn -map_chapters -1 -c:v copy -c:a aac -c:s copy "${f/DDP/AAC}"; done
Map all audio streams where language is English:
0:a:m:language:eng
# full cli example: for f in *.mkv; do ffmpeg -y -i "$f" -default_mode infer_no_subs -map 0:v:0 -map 0:a:1 -map 0:a:m:language:eng -dn -map_chapters -1 -c:v copy -c:a aac -c:s copy "${f/DDP/AAC}"; done
You get the idea. For the video stream it would be 0:v:m:language:eng
. You may also use any other stream attribute in replacement of language, such as title. It’s basically an IF statement without saying IF.
Equivalent of the above scripts in cmd/batch for use on Wintel systems:
for %%A IN ("*.mkv") Do ffmpeg -y -i "%%A" -default_mode infer_no_subs -map 0:v:0 -map 0:a:1 -map 0:a:m:language:eng -dn -map_chapters -1 -c:v copy -c:a aac -c:s copy "./%%~nA_New.mkv"
Sources:
https://trac.ffmpeg.org/ticket/7356