📅 2015-Jan-24 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ mkv, mkvmerge, srt, subtitles ⬩ 📚 Archive
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
$ 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 in.srt
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