Skip to main content

How to embed external subtitles in a video file using mkvtoolnix.

Official usage page.

Basic use

First, make sure that mkvmerge is installed on your system by running the following command:

apt-get install mkvtoolnix

Next, navigate to the directory where the movie file and the subtitle file are located using the cd command.

Then, use the following mkvmerge command to add the subtitle file to the movie file: 

mkvmerge -o output.mkv movie.mp4 subtitle.srt

In this command, "output.mkv" is the output movie file with the subtitles embedded, "movie.mp4" is the input movie file, and "subtitle.srt" is the input subtitle file.


Further customization

You may set the language and name of each subtitle track:

mkvmerge -o output.mkv input.mp4 \
    --language 0:en --track-name 0:English english_subtitles.srt
    --language 0:es --track-name 0:Español spanish_subtitles.srt

Note that we used for both languages the same track ID (0:), which corresponds to the input video track.

The --language needs to be properly encoded. You can list all allowed ISO 639-2 and ISO 639-1 codes with:

mkvmerge --list-languages

Other useful features

You may also set the title of the output video with:

--title "Your title"

We can check how all subtitles were added to the output:

$ mkvmerge -i output.mkv
File 'output.mkv': container: Matroska
Track ID 0: video (MPEG-4p10/AVC/H.264)
Track ID 1: audio (AAC)
Track ID 2: subtitles (SubRip/SRT)
Track ID 3: subtitles (SubRip/SRT)

If you really want to "burn" the subtitles in the video, you may use ffmpeg instead.