Command Line DVD Ripping

I recently took on the task of digitizing our old VHS tapes. While
digging through the tapes I came across an old, region-2-encoded DVD
copy of *Rocketman*, starring Harland Williams. I bought it years
ago before it was available on region 1 DVD. In those days I had a DVD
drive which I kept set to region 2, but no longer. It’s time to get rid
of this thing, but not before we make ourselves an MP4 copy.

DVD region 2 is the designation for most of Europe, so in addition to
the region issue, most region 2 disks are formatted for PAL systems.
This particular movie was sped up approximately 1fps to match PAL
framerates, and stretched vertically to fill in the extra vertical space
on PAL screens. Since we’re going to be dealing with raw video streams
anyway, we’ll take the time to slow down and rescale the final product.

Linux wants for nothing when it comes to video processing applications.
The trick is to sort through them all and find the right tools for the
job. Everything we need is available in the Ubuntu repositories.

First, we set the region flag on the DVD drive to region 2. This can be
done with a simple program called **regionset**. Note that most DVD
drives only permit a limited number of changes to this setting. We’ll
run **regionset** and follow the prompts:

$ regionset

Next, we copy the VOB file from the DVD to the disk, so that we can
manipulate the audio and video streams. **vobcopy** will do the job:

$ vobcopy -l

This creates a file called ROCKETMAN1.vob in the current directory. At
this point we can eject the DVD and re-set the region flag. Everything
else will be based on this VOB file.

Our next step is to use **mplayer** to extract the audio from the VOB
file so that we can slow it down to match the new frame rate:

mplayer ROCKETMAN1.vob -ao pcm:file=rocketman.wav -vo null

Once that’s finished, we’ll start the rather long process of ripping and
reformatting the video:

ffmpeg -i ROCKETMAN1.vob \
-f rawvideo -pix_fmt yuv420p – 2>/dev/null \
| ffmpeg -f rawvideo -r 23.976 -s 720×576 -pix_fmt yuv420p -i – \
-vcodec libx264 -pass 1 -vpre slow_firstpass -b 768K -s 720×480 \
-threads 0 -y rocketman.mp4 \
&& ffmpeg -i ROCKETMAN1.vob \
-f rawvideo -pix_fmt yuv420p – 2>/dev/null \
| ffmpeg -f rawvideo -r 23.976 -s 720×576 -pix_fmt yuv420p -i – \
-vcodec libx264 -pass 2 -vpre slow -b 768K -s 720×480 \
-threads 0 -y rocketman.mp4

That monster command actually invokes two instances of **ffmpeg**; one to
feed the raw video stream from the VOB into a pipe, the second to read
in the raw stream, apply the new frame rate, then resize and encode the
result.

While that runs we can process the audio using **sox**. This particular
movie is a little quiet, so we’ll normalize the volume while we’re
changing the speed. Our speed ratio is based on the source and
destination frame rates. The PAL-formatted VOB stream is 25fps, and
our final product will be 23.976fps (an NTSC standard). 23.976/25 is
.95904, so that is our ratio:

sox –norm rocketman.wav rocketman.flac speed .95904

When all of this time-consuming processing is finished, we can take our
converted video and audio streams and reunite them (a process known as
*muxing*) using **ffmpeg**:

ffmpeg -i rocketman.mp4 -vcodec copy \
-i rocketman.flac -acodec libfaac -ab 128K \
rocketman.final.mp4

Notice that we’re copying the video stream instead of encoding it.
That’s because we already encoded it during the ripping process.
However, we still have to compress the audio, so we specify an audio codec and bitrate.

This last step is surprisingly quick, and when it’s finished, so are we.
Of course, we’ll confirm that everything was successful before we delete
our working files. But then we’re ready to sit back and enjoy some
ridiculous antics!

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *