Skip to content

Instantly share code, notes, and snippets.

@gmolveau
Last active October 16, 2024 15:24
Show Gist options
  • Save gmolveau/a75679291028fcb22548a61da92377e7 to your computer and use it in GitHub Desktop.
Save gmolveau/a75679291028fcb22548a61da92377e7 to your computer and use it in GitHub Desktop.
Embed subtitle (soft) in mp4/mkv file with ffmpeg without re-encoding

solution from https://stackoverflow.com/a/17584272/2627873

This solution adds the subtitles to the video as a separate optional (and user-controlled) subtitle track.

So you can choose the subtitle in VLC for example, it's not hard-coded or burned-in. And it won't re-encode the entire file so it's really fast.

  • ffmpeg is required
  • movie = great_movie.mp4 (works with mkv too)
  • subtitle = great_movie.english.srt
ffmpeg -i great_movie.mp4 -i great_movie.en.srt -c copy -c:s mov_text great_movie_subbed.mp4

Another solution : https://www.reck.dk/use-ffmpeg-to-add-subtitles-to-video/

ffmpeg -i great_movie.mp4 -i great_movie.en.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s mov_text great_movie_subbed.mp4
@franciscop
Copy link

franciscop commented Mar 25, 2021

Tip: if you want to set the title of the track to show as "English" instead of "Track 1", add -metadata:s:s:0 title="English" like this:

ffmpeg -i great_movie.mp4 -i great_movie.en.srt -c copy -c:s mov_text -metadata:s:s:0 title="🇬🇧 English" great_movie_subbed.mp4

@gmolveau
Copy link
Author

Nice, thank's :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment