16

I have a video file (in the format of .mp4, .mkv, .avi or whatever) and a subtitle file (.srt). I want to embed the subtitle file into the video file so that I have only one file - the video file in contrast to the video and the subtitle file.

Is it possible? How?

1
  • 1
    Soft embedded subs that can be turned off are the way to go (might not be possible with AVI though); hard subs are really irritating and not only does adding them cause quality loss, but removing them is not possible without further significant loss.
    – Karan
    Dec 17, 2012 at 17:39

4 Answers 4

8

MKVtoolnix is another easy to use option since you already have the files you want. You can combine them into an MKV container without altering the originals in anyway. It has a nice GUI to guide you through the combination process as well.

I see user1301428 had mentioned Handbrake, which is also a very common/popular tool. I'm not as familiar with it, but if it doesn't re-encode your source AVI then it should be great.

27

A free, cross-platform solution with FFmpeg, which does bitstream copy and therefore doesn't take more than a few seconds, even for large files:

ffmpeg -i input.mp4 -i subtitles.srt -c:s mov_text -c:v copy -c:a copy output.mp4

This works for MP4. Be aware that some subtitle formats might not automatically be compatible with the chosen output formats, so you have to change the codec after -c:s:

  • MP4: Use the mov_text subtitle codec (as in the example above), which implements MPEG-4 Part 17.

  • MKV: Use srt, subrip, ssa or ass. MKV does not support mov_text.

  • AVI: Very problematic with embedded subtitles. In theory they support SubRip and SSA/ASS subtitles, but only through third party software.

See Wikipedia for a list of containers and their supported subtitle formats.

Using dedicated video encoding programs such as Handbrake will re-encode your video, which reduces its quality and could take you hours to encode – this is why you should check whether the tools support copying the video and audio bitstreams.

2
  • 1
    I have found -f srt to be necessary sometimes, otherwise great!
    – Zombo
    Jul 11, 2013 at 2:57
  • 2
    In case your subtitle file is of *.vtt format, use -c:s webvtt option, like this: ffmpeg -i input.webm -i input.vtt -c:s webvtt -c:v copy -c:a copy output.webm
    – Megidd
    May 22, 2018 at 6:28
0

You can use Handbrake. In the "Subtitles" tab you simply need to select the subtitles file and then launch the encoding.

1
  • 3
    This wil re-encode the video, which a) takes a lot of time and b) deteriorates the quality.
    – slhck
    Dec 17, 2012 at 17:31
-1
ffmpeg -i video.avi -vf subtitles=subtitle.srt out.avi

You must log in to answer this question.