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.