MKVMerge Error: Demultiplexer failed to initialize


I tried to merge a subtitle SRT file with a video MP4 file using MKVMerge as explained here. It failed with this error:

$ mkvmerge -o out.mp4 foo.mp4 
mkvmerge v5.6.0 ('Kenya Kane') built on Jun  7 2012 15:57:56
'foo.mp4': Using the demultiplexer for the format 'QuickTime/MP4'.
Error: The demultiplexer for the file 'foo.mp4' failed to initialize:
The file could not be opened for reading, or there was not enough data to parse its headers.


Googling for this error message did not provide any solution.

I updated MKVMerge to the newer version 6.7.0. The same command on the same files worked successfully! 🙂

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