Use FFmpeg to add an aditional subtitle to a mkv video

Running ex. on Evita from 1996

First let Examining the source file with ffprobe and grep the Stream lines with the googdies

ffprobe Evita.mkv

Then will see these stream lines

Stream #0:0(eng): Video: h264 (High), yuv420p, 1280×536, SAR 67:68 DAR 40:17, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s (default)
Stream #0:2(ita): Subtitle: subrip
Stream #0:3(eng): Subtitle: subrip
Stream #0:4(spa): Subtitle: subrip
Stream #0:5(fre): Subtitle: subrip
Stream #0:6(ger): Subtitle: subrip
Stream #0:7(dut): Subtitle: subrip
Stream #0:8(chi): Subtitle: subrip

This tells us that -map layers is:
0:0 is the video layer
0:1 is the Audio layer
0:2 is the italian subtitle layer
0:3 is the English subtitle layer
0:4 is the Spanish subtitle layer
0:5 is the Frensh subtitle layer
0:6 is the German subtitle layer
0:7 is the Dutch subtitle layer
0:8 is the Chinese subtitle layer

Now we will add the subtitle layer for the danish language, by simply copy all the source and add the contents of the Evita-dan.srt file, but if you would like to have a “named” list of which subtitle layer is which you need to do some manual labor adding the -metadata:0:9 language=dan I’m afraid. Now go ahead and do as in the code below 🙂

You determine the -metadata:s:x by simply take the highest number in source file and adding +1, on this case 8+1=9 which makes the -metadata:s:9

ffmpeg -y -i Evita.mkv -f srt -i Evita-dan.srt -map 0:0 -map 0:1 -map 0:2 -map 0:3 -map 0:4 -map 0:5 -map 0:6 -map 0:7 -map 0:8 -map 1:0 -c copy -c:s srt -metadata:s:9 language=dan Evita-dan.mkv

Skriv et svar