Table of Contents
MEncoder
mencoder
is the video/audio transcoding utility shipped with mplayer
.
Like the player, it's a very mighty utility, perfectly performing the tasks it
was designed for.
DVD Ripping
This is how I used to rip my DVDs using mencoder
(meanwhile I switched to using ffmpeg:
Information to have at hand when beginning
- title (and maybe chapters) which are to be ripped
- start/end offsets of movie if parts of the title are crap
- necessary cropping values
- the original aspect ratio of the movie
- the desired audio track's id
- original number of audio channels, and number of channels to encode to
- subtitle id if needed
Ripping The Audio Track
% mencoder dvd://3 -aid 129 -ss 0:03:18 -af pan=2:1:0:0:1:1:0:0:1:0.5:0.5:0.5:0.5 \ -ovc frameno -o frameno.avi -oac mp3lame -lameopts vbr=2
- dvd://3 specifies the title
- -aid 129 selects the second audio track
- -ss 0:03:18 starts ripping 3 minutes, 18 seconds after the original beginning
- -channels 6 force using six channels, so they can be customly mapped
- -af pan=2:1:0:0:1:1:0:0:1:0.5:0.5:0.5:0.5 output to 2 channels, map lf to l, rf to r, lb to l, rb to r, split center and subwoofer by half volume to l and r
- -ovc frameno special video codec containing just audio
- -o frameno.avi target filename, must be exactly like this
- -oac mp3lame encode audio to mp3 using lame
- -lameopts vbr=2 encode to VBR
when mencoder
finishes encoding audio, it will output some hints for later
choice of video bitrate, pasting them to a temporary place is a good idea.
First Pass Of Encoding
% mencoder -dvd-device NBK_18 dvd://3 -ss 0:03:18 -oac copy -o /dev/null -ovc lavc \ -lavcopts vcodec=mpeg4:vbitrate=1400:vhq:vqmin=2:vqmax=31:aspect=16/9:threads=4:vpass=1 \ -vf crop=710:430
- -oac copy
mencoder
uses the fileframeno.avi
for audio, which is already perfectly encoded - -o /dev/null discard output, this run is just for getting some file information
- -ovc lavc use
lavc
for encoding to avi - -lavcopts vcodec=mpeg4:vbitrate=1400:vhq:vqmin=2:vqmax=31:aspect=16/9:threads=4:vpass=1 encode to mpeg4, 1400bit/s, enable high quality, set minimum/maximum compression to 2/31, encode aspect ratio in file (only supported by
mplayer
), encode using four threads and set pass to first one - -vf crop=710:430 crop to 710×430 video aspect
Second Pass Of Encoding
% mencoder -dvd-device NBK_18 dvd://3 -ss 0:03:18 -oac copy -o target_filename.avi -ovc lavc \ -lavcopts vcodec=mpeg4:vbitrate=1400:vhq:vqmin=2:vqmax=31:aspect=16/9:threads=4:vpass=3 \ -vf crop=710:430
- -o target_filename.avi from now on, actually write to a file
- vpass=3 set this to be pass 2-N of an N-Pass encoding run
Third And Subsequent Passes Of Encoding
Just repeat the second pass to achieve better results. Doing this more than four times is said to not help really much anymore.
Hints
To speed up or allow delayed encoding of a DVD, it's content is best copied to
disk. I do this using vobcopy
. Just create and change into a new directory,
then run:
% vobcopy -m -i /mnt/dvd
where /mnt/dvd is the path to the mounted DVD drive. To allow
mplayer
/mencoder
to operate on the ripped files on disk, the option
-dvd-device /path/to/rip
can be used.
Converting Audio Tracks
Not as easy as one may think, at least mencoder
itself didn't let me do
it. But luckily mplayer
does the job:
% mplayer -ao pcm:file="audiotrack.pcm" -vo null audiotrack.m4a
for encoding I then simply use lame:
% lame -m s -q 2 --vbr-new -V 3 audiotrack.pcm audiotrack.mp3
Encoding to SVCD
DivX support in many DVD players is still completely broken. So instead of trying to find the right DivX encoding parameters for each DVD player device out there separately, using a well-known (and also well-supported) video format instead seems to be more practical. And this is where good old SVCD comes into play.