Skip to content

Instantly share code, notes, and snippets.

@mayeaux
Forked from gmolveau/embed_sub.md
Created November 18, 2022 00:46
Show Gist options
  • Save mayeaux/971ad6af2ac133600df5e9b10719c601 to your computer and use it in GitHub Desktop.
Save mayeaux/971ad6af2ac133600df5e9b10719c601 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment