Saturday, April 02, 2011

Extracting video with subtitles from an MKV file

Although Handbrake can convert MKV files and burn the subtitles into the video stream, it does not handle fancy SSA subtitles very well.  The only program that I've found that seems to render SSA subtitles very well is mplayer.  I used mplayer and x264 to convert by running the following:

mplayer -ass -nosound inputmovie.mkv -vo yuv4mpeg:file=>(x264 --demuxer y4m --qp 15 --bitrate 2500 --profile main --level 5.1 --preset slow  -o outputmovie.mp4 -)
 This also works:

mplayer -ass -nosound inputmovie.mkv -vo yuv4mpeg:file=>(x264 --demuxer y4m --crf 15 --profile main --level 5.1 --preset slow  -o outputmovie.mp4 -)

I used the Main H.264 profile with a high level instead of using the High H.264 profile since the High profile resulted in the video starting with a gray screen and other artifacts when viewing via Quicktime.

2 comments:

  1. Thank you for the post. I've been trying to figure out how to deal with SSA files.

    Did you ever try using Video Monkey?

    ReplyDelete
  2. No, I haven't tried it. I usually use Handbrake when I'm going from DVD->MP4. In this case I was trying to go from MKV->DVD and needed something that I could feed to Compressor (part of Final Cut Studio).

    I probably could have used ffmpeg or mencoder to encode the MPEG-2 directly for use in DVD Studio Pro.

    One negative thing I encountered with rendering the SSA files is that the subtitles were laid out for viewing on a computer screen. When watching it on DVD on my TV, the subtitles at the top of the screen (song subtitles) were clipped due to overscan.

    MPlayer OSX Extended (http://www.mplayerosx.ch/) seems to play MKVs with SSAs a bit better than VLC.

    ReplyDelete