thefoggiest.dev

Ripping DVDs with mplayer/mencoder

I have a sizeable collection of DVDs but I find it way more convenient to store them on the hard drive of my home server and stream them to my TV. This way I can browse using my remote, I don’t have to click watch movie or something to that effect in a menu and I don’t have to sit through an endless series of commercial messages before I even get to that menu.

I find that using MEncoder to do that will invariably produce excellent results and over time I have assembled what I found in various howto’s and compiled it into a set of instructions that work for me. Below is a step by step guide how to rip a DVD into an xvid file. I currently use MEncoder SVN-r35014-4.7.1, but these steps work with most versions of MEncoder.

1. Setup

First copy or mount the DVD, or cd to a copy, whatever is most convenient. From here on, DVD means either:

  • the directory where the copy of the DVD is,
  • the mountpoint of the DVD, or
  • an iso-file.

2. Audio

Find the correct audio language using:

$ mplayer dvd://1 -dvd-device <DVD> -v | grep aid

Note the number behind “<language code> aid:”, from here on AID.  Also note the bit rate for the wanted file size (BITRATE).

3. Video

Note the crop data (CROPDATA) to remove the black areas above and below the image:

$ mplayer dvd://1 -dvd-device <DVD> -vf cropdetect

CROPDATA  are four numbers separated by colons. Often the correct ones appear only after a few seconds. Note those.

Find the appropriate amounts for scaling (width[:height]):

$ mplayer dvd:// -dvd-device <DVD> -vf crop=<CROPDATA> | grep VO

Note the numbers behind “=>”. They are separated by an x, but mencoder will need a colon instead, like this: w:h (SCALEDATA).

Make a preview in two passes. Note: from now on we’ll use mencoder instead of mplayer.

$ mencoder dvd://1 -dvd-device <DVD> -vf crop=<CROPDATA>,scale=<SCALEDATA>
 -aid <AID> -nosub -oac mp3lame -ovc xvid -xvidencopts pass=1 -o /dev/null 
 -ss 10:00 -endpos 0:30

When you get the following error:

Unknown option on the command line: -oac

you’ve used mplayer instead of mencoder.

Pass 2:

$ mencoder dvd://1 -dvd-device <DVD> -vf crop=<CROPDATA>,scale=<SCALEDATA>
 -aid <AID> -nosub -oac mp3lame -ovc xvid -xvidencopts
 bitrate=<BITRATE>:pass=2 -o preview.avi -ss 10:00 -endpos 0:30

Watch the preview and determine if it looks good:

$ mplayer preview.avi

Create the avi-file with name AVIFILE:

$ mencoder dvd://1 -dvd-device <DVD> -vf crop=<CROPDATA>,scale=<SCALEDATA>
 -aid <AID> -nosub -oac mp3lame -ovc xvid -xvidencopts pass=1 -o /dev/null
$ mencoder dvd://1 -dvd-device <DVD> -vf crop=<CROPDATA>,scale=<SCALEDATA>
 -aid <AID> -nosub -oac mp3lame -ovc xvid -xvidencopts
 bitrate=<BITRATE>:pass=2 -o <AVIFILE>

Categorised as: howto, linux


Comments are closed.