About a week ago I had to save two DVD disks on my hdd and instead of wasting 9GB of disk space I started playing with mencoder. I looked a lot on the internet, lots of options, lots of ways to do it… it not very easy. In the end I decided on the following:

  • x264 video codec
  • mp3 audio codec( in my case, the audio wasn’t important, otherwise I would’ve decided on AAC)
  • mkv container
  • mencoder, mkvtools and ogmtools for the procedure

Here are the commands.
Info about the chapters and ripping the title on the HDD:

dvdxchap -t 1 /dev/dvd > 1.chapters
mplayer dvd://1 -dumpstream -dumpfile 1.vob

First pass only analyzes the video and writes a log file for the second pass:

rm *.log #remove old logs
mencoder -v 1.vob \
-alang en \#language english
-vf yadif \#yadif deinterlacer
-ovc x264 \ #codec x264
-x264encopts subq=4:bframes=4:b_pyramid:weight_b:pass=1:psnr:bitrate=1800:turbo=1 \ #1800 bitrate gives a good size to qualit ratio
-oac copy \ #for now only copy the audio
-ofps 24000/1001 \#approx 23.9 fps
-slang en \
-o /dev/null

Second pass:

mencoder -v 1.vob \
-alang en \
-vf yadif \
-ovc x264 \
-x264encopts subq=5:partitions=4x4:8x8dct:frameref=3:me=hex:bframes=4:b_pyramid:pass=2:psnr:bitrate=1800 \
-oac mp3lame \ #mp3lame audio codec
-lameopts abr:br=256:vol=7 \ #256kbits bitrate
-ofps 24000/1001 \
-o 1.avi #write everything as avi for now

At this stage we have a perfectly working AVI at around 1800MB per 4.3GB DVD. I, however, want the chapter information from the DVD. The next step for me is to open the DVD and start going trough the chapters and editing the titles in the 1.chapters file from Chapter 01 Chapter 02… to something that makes more sense.

Then I merge the audio and video from the .avi and the chapter information in one .mkv file:

mkvmerge --title "Title of the DVD" -o 1.mkv --chapters 1.chapters 1.avi

After I make sure that 1.mkv works, I cleanup:

rm -rf 1.vob 1.avi 1.chapters *.log

That’s it. The .mkv file supports multiple tracks of audio, subtitles and many more.

There could be a better way to do all this, but this worked for me.