How To Rip DVDs to xvid avi Files In Linux

Okay, this guide will take you through ripping the contents of a regular DVD movie to an xvid-encoded avi file step by step using Linux command line tools only. I’ll concentrate on Ubuntu and Fedora but it should be easy on other distros too. Before we start, this article hinges on the use of libdvdcss. Depending on your country and Linux distribution, this may be easy or difficult. Google your distro name and “libdvdcss” if you can’t get hold of it.

For Fedora, you’ll need to get the libdvdcss package from a different repo than the standard ones. Add it with: –

rpm -Uvh http://rpm.livna.org/livna-release.rpm
yum install libdvdcss

If that doesn’t work, you can download the RPM file directly here. You can install the RPM manually with: –

rpm -ivh libdvdcss2-1.2.9-1.i386.rpm

For Ubuntu, you can install the libdvdcss package with: –

sudo apt-get install libdvdread4 && sudo /usr/share/doc/libdvdread4/install-css.sh

You’ll need some other tools too. Under Ubuntu, install with: –

sudo apt-get install vobcopy ffmpeg libxvidcore4 lame

Under Fedora, this is slightly different with: –

yum install vbocopy ffmpeg xvidcore lame

Next, create a mount point directory for your DVD files. I’m using /mnt/dvdrom but you can choose anything, anywhere although if you’re not root (as in Ubuntu), you might need to prefixing “sudo” to this.

mkdir /mnt/dvdrom

After you’ve done this, insert the DVD movie you want to burn and mount the DVD-ROM drive. For this example, I’m using the DVD of David Carradine’s 1976 classic “Carquake” also known as “Cannonball”. Man, I love me some of those old muscle cars. Anyway, I digress – but choose a DVD you want to backup :-)
Depending on your distribution, this may be one of the following devices under /dev. On modern distributions this is usually /dev/sr0, so the following will work.

mount /dev/sr0 /mnt/dvdrom

Again, under Ubuntu you might need to use “sudo” for this. Some older Linux distros have /dev/cdrom or a symlink from /dev/cdrom to /dev/sr0. It may even be auto-mounted under /media.

Anyway, one way or another you have your DVD mounted under /mnt/dvdrom. Now you need to use “vobcopy” to copy the VOB chapter files. Create a directory to hold these files. Make sure it’s on a partition with at least 10GB on it as this process can be heavy on file space. I’m using “/home/myuser/tmp” for this. Make sure you’re inside the directory. I’m using /home/myuser/tmp so the following will work: –

cd ~/tmp

Once you’re inside your chosen work directory, run the following command assuming your DVD movie is mounted on /mnt/dvdrom.

vobcopy -m -i /mnt/dvdrom -F 5 -v

This will mirror (-m) the contents of the DVD to your current directory from your chosen mount point. This process can take a long time. So go do something else for a while and come back. Also if you’re worried about your session dying or you want to push this process to the background, you can use: –

nohup vobcopy -m -i /mnt/dvdrom -F 5 -v > output.txt &

…which will to the same thing in the background but write it’s output to output.txt. Check the date/time on the last modifed column with a “ls -lah” on that directory or do a “ps -elf | grep vobcopy” to see if it’s still running. You can check the progress of the output with “tail -f output.txt” to see the percentage done updated in real time.

Once this is done, change to the new subdirectory VIDEO_TS – this is the directory structure of the DVD. If you do an “ls -lah” on that directory, you’ll see the VOB files listed. Mine for the rip of “Carquake” looks like this: –

total 1.2G
drwxr-xr-x 2 root root 4.0K Mar 25 02:11 .
drwxr-xr-x 3 root root 4.0K Mar 23 20:03 ..
-rw-r--r-- 1 root root  12K Mar 23 20:03 VIDEO_TS.BUP
-rw-r--r-- 1 root root  12K Mar 23 20:03 VIDEO_TS.IFO
-rw-r--r-- 1 root root  14K Mar 23 20:03 VIDEO_TS.VOB
-rw-r--r-- 1 root root  50K Mar 23 20:03 VTS_01_0.BUP
-rw-r--r-- 1 root root  50K Mar 23 20:03 VTS_01_0.IFO
-rw-r--r-- 1 root root 4.0K Mar 23 20:03 VTS_01_0.VOB
-rw-r--r-- 1 root root 283M Mar 24 03:29 VTS_01_1.VOB
-rw-r--r-- 1 root root 314M Mar 24 10:24 VTS_01_2.VOB
-rw-r--r-- 1 root root 252M Mar 24 17:45 VTS_01_3.VOB
-rw-r--r-- 1 root root 287M Mar 25 00:52 VTS_01_4.VOB
-rw-r--r-- 1 root root  64M Mar 25 02:11 VTS_01_5.VOB

Looking at this, we can surmise that the film itself is probably on the files VTS_01_1.VOB – VTS_01_5.VOB. So the next thing you’ll want to do is to convert these multiple VOB files into one. This is easily done with: –

ffmpeg -i concat:"VTS_01_1.VOB|VTS_01_2.VOB|VTS_01_3.VOB|VTS_01_4.VOB|VTS_01_5.VOB" -c copy concat.vob

This will give you one file called CONCAT.VOB. Now we need to convert the VOB file to our Xvid AVI file. Do this with: –

ffmpeg -i concat.vob -f avi -vcodec libxvid -acodec libmp3lame -qscale 3 output.avi

This should give you a file called “output.avi” which has xvid video encoding and mp3 audio encoding. Consider your DVD ripped :-)

Update 28/03/2013: If you have a DVD with dual audio, for example English and Japanese or something, you can choose to extract one for the audio in your xvid avi. Check out the -map switch to ffmpeg here. Using the -map option, you can choose to extract one of the specific audio tracks to embed in the xvid avi file.

, , , , ,

Comments

  • g says:

    Worked flawlessly, thank you.
    Total Comment by g: 1

  • Eric says:

    Hi Jon

    When I try to run

    ffmpeg -i concat:”VTS_01_1.VOB|VTS_01_2.VOB|VTS_01_3.VOB|VTS_01_4.VOB|VTS_01_5.VOB” -c copy concat.vob

    It comes back with

    *** THIS PROGRAM IS DEPRECATED ***
    This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.

    Could you tell me how to do it with avconv?
    Total Comment by Eric: 1

  • Loreley Arened says:

    Works perfectly for me. Thanks
    Total Comment by Loreley Arened: 1

Comments are closed.