Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ffmpeg command to add .srt based subtitles to an .mkv file
ffmpeg -i in.mkv -f srt -i in.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s srt out.mkv
@oky2abbas

This comment has been minimized.

Copy link

oky2abbas commented Feb 26, 2019

Compatible with utf8 :
ffmpeg -i input.mkv -sub_charenc 'UTF-8' -f srt -i input.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s srt out.mkv

@RobertoMaurizzi

This comment has been minimized.

Copy link

RobertoMaurizzi commented Sep 19, 2019

With the original options for map, I got subs out of sync by around 4 secs. Removing -map completely copies over all the streams and works for most files

ffmpeg -i input.mkv -sub_charenc 'UTF-8' -f srt -i subs.en.srt -map 0 -c:v copy -c:a copy -c:s srt output.mkv
@ttyusupov

This comment has been minimized.

Copy link

ttyusupov commented Feb 26, 2020

-map 1:0 is still needed for copying subtitles into output file:

ffmpeg -i input.mkv -sub_charenc 'UTF-8' -f srt -i subs.en.srt -map 0 -map 1:0 -c:v copy -c:a copy -c:s srt output.mkv
@pscopic

This comment has been minimized.

Copy link

pscopic commented Mar 18, 2020

-map 1:0 is still needed for copying subtitles into output file:

ffmpeg -i input.mkv -sub_charenc 'UTF-8' -f srt -i subs.en.srt -map 0 -map 1:0 -c:v copy -c:a copy -c:s srt output.mkv

Worked for me without the -map 1:0 so long as I omit the -map 0 too.

@nimahkh

This comment has been minimized.

Copy link

nimahkh commented Mar 21, 2020

i made this bash script with your code :
https://gist.github.com/nimahkh/36c0dac31d9cb5363cf356095014524f

@Alex24242424

This comment has been minimized.

Copy link

Alex24242424 commented Apr 27, 2020

I used this script I made. I find it more simple and it can simply be changed for other formats:
ffmpeg -i input.mkv -c copy -c:s srt out.mkv

Works very well, and the srt subtitle codec can be changed with other codecs like mov_text for mp4 videos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.