How to add subtitles to video file using MKVMerge

If you like to watch videos with subtitles, you have two options. First, you have an external subtitles file and your player can pick it up while playing the video file. Second, you have a video file with an embedded subtitles stream. You may be forced to use the second option for certain video players or for streaming video content using media servers, like MiniDLNA for example.

It is possible to embed a subtitles file, for example a SubRip .srt file, into a video file to output a video file that has the subtitles stream embedded in it. The easiest method to achieve this is to output to a Matroska Multimedia Container (MKV) file. This is a commonly used container format for video files that can hold multiple streams: video, audio and subtitles. So, we create a MKV file containing the original video file (of any format) and a subtitles stream to be used along with it. The only limitation is that you will need a player that supports MKV to replay this back.

To deal with MKV files, we need the mkvtoolnix package:

$ sudo apt-get install mkvtoolnix

We use the mkvmerge tool from this package to merge a SubRip SRT file into an existing video file:

$ mkvmerge -o out.mkv in.avi


  • The input file cannot be overwritten with the output file, hence we use a different name here.

  • Multiple subtitle files can be added to MKV file incrementally in this way. This is typically used to embed subtitles of multiple languages into the file.

  • When playing with a player like VLC, one or none of the subtitles can be picked. For example, right-click in the middle of the playing video and choose Subtitle -> Sub Track.

Tried with: MKVToolNix 6.7.0-1 and Ubuntu 14.04

5 thoughts on “How to add subtitles to video file using MKVMerge

  1. You can use AvdshareΒ VideoΒ Converter to Add subtitles, like SRT, ASS, SUB, SSA, IDX to MKV for playing on various MKV devices.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.