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.
You may want to check out doom9.org. Also, there are ways to convert the subtitle into another format which mplayer would load automatically if it is named with the same name (minus the .ext).
Just thought I’d mention something (potentially) helpful (for further digging into the matter). Sorry if it clutters up. Feel free to delete this comment.
Heh, no problem. I’m all about taking the most simplistic route possible, regardless of how much space it has. The fact of the matter is, with all the DVD issues out there, there isn’t a magic bullet that will correctly work with everything. So for me keeping as close to the source as possible is the most error-free way to go. The only problem is you have to have about 3 TB handy. Ah well.
Thanks. And here is an additional detail that took me a while to figure out. I had a idx/sub vobsub with 2 tracks, and only wanted to keep the second track (skip track 0, merge track 1). My command ended up being:
mkvmerge -o output.mkv video.avi –subtitle-tracks 1 subtitles.idx –track-order 0:0,0:1,1:1
(0:0 is first track of first file (video), 0:1 is 2nd track of 1st file (audio), 1:1 is second track of 2nd file (2nd subtitles))