Monday, January 07, 2013

How to extract vob subtitles from an mkv file and render them as png files

Posting this because I spent far too much time figuring this out from various scraps here and there. I got a bunch of Japanese DVDs recently and ripped them to mkv. As part of learning Japanese, I want to be able to see the subtitles side by side, and use them in flash cards etc. I found recipes for extract subs from a DVD but it's not quite right for mkv. I also found tools that worked except but output distorted images.

There is also the very impressive subs2srs which will generate an anki deck with images and audio snippets and it works under wine but it actually is a little bit heavy for what I want.

First, you need to know what track has your subs. mkvinfo will tell you that. Then after that you can use the following bash script (you'll need to install mkvtoolnix and transcode).

You can invoke it as e.g. extract.sh foo.mkv 4 and you'll have a bunch of .png files generated from the 4th track of foo.mkv in the foo-sub-4/ directory. There will also be a .srtx file which gives the timings for all the subs.

My next step will be to use these timings to line the subs up and output a HTML page with them side-by-side.

No comments: