Oh, man, this is something I’ve been struggling to wrap my brain around for a good while, and I finally got it figured out. I’ve always wanted to be able to add subtitles to my matroska videos … no real reason other than it’d be nice. I don’t normally turn them on, but I do occasionally. The problem I kept running into was the same with a lot of software documentation out there — it was just sparse or assumed you knew some certain terms or skipped over explanations. Adding to the complexity is the fact that there are a few subtitle formats that different containers can handle.
In my setup, I’m once again skipping a few steps to just plain keep this simple, mostly at the cost of space, though even that is hardly anything. As an example, on a 1.5 GB MPEG2, the resulting VobSub file is 1 MB. I can live with that.
Anyway, here’s what I have so far … and I promise to update the Gentoo wiki as soon as I get time to cover this more in detail. The first step is to rip the subtitles from the DVD. To do that you have to calculate the subtitle index, which I won’t go into right now. On the DVD I used, “It’s the Great Pumpkin, Charlie Brown” it was the first (and only) subtitle track for the movie, so it was pretty easy for me.
In fact, here’s the command I used to rip both the movie and the subtitles at once:
$ mencoder dvd://1 -ovc copy -oac copy -vobsubout subtitles -vobsuboutindex 0 -sid 0 -o pumpkin.avi
This created three files: pumpkin.avi (the unencoded MPEG2), subtitles.idx and subtitles.sub.
After that, and this is where I never realized how easy it is, to dump it all into Matroska, you just add the .idx file along with the others you are going to mux.
$ mkvmerge -o pumpkin.mkv pumpkin.avi subtitles.idx
When watching the movie with MPlayer, you can toggle through the possible subtitles with the ‘j’ key.
I can’t believe it was as simple as that.