Friday, July 23, 2010

DVD Backups Using Linux

A couple of weeks ago, I finally got around to backing up some of my personal DVDs.  There are several methods that exist for accomplishing this task under Linux, so I'll list some of the common tools that are out there and then explain why I chose the tools I did.

In order to backup DVDs, here are three approaches you could take:
  • ISO - ISO image backups allow you to create archival quality backups of your DVDs by creating a copy of the DVD image on your computer.  This gives you the advantage of having the original video streams, audio streams, and DVD menus at the expense of increased storage requirements (between 4-8GB per DVD). Several applications support DVD playback and/or transcoding from ISO images: MythTV, VLC, Handbrake, K9Copy, etc.

    Examples of ISO backup software:
    dvdbackup/genisoimage (CLI) - The combination of these two command line tools is very useful for backing up DVDs.
    K9Copy (GUI) - I was reluctant at first to try this since it requires QT libraries to be installed on Ubuntu, but I'm glad I did.  It was the best GUI tool I found for creating ISO images of DVDs.
    Gnome (GUI) - Right-click on a disc's icon on the desktop, then select Copy Disc.... This works for some DVDs, but it won't work for everything.

  • Transcode - Transcoding involves converting the original video and audio streams on a DVD to another format (h.264, Ogg Theora, etc).  This has the advantage of shrinking your video down to 1 to 2 GB while still maintaining good quality video (although usually not as good as the original video).  These smaller video sizes are possible because newer video encoding schemes can compress video much better than MPEG-2 video which is the standard for DVDs.  Transcoding saves disk space but can take a long time if you have a slower computer.

    Examples of DVD transcoding software:
    Handbrake (GTK or CLI version) - Transcoding DVDs is its only job and it does it very well.
    K9Copy (GUI) - Equivalent to DVD Shrink on Windows.
    dvd::rip (GUI)
    mplayer/mencoder (CLI)
    Others - Thoggen, VLC, AcidRip, ogmrip

  • Requantizer - This method (think DVD Shrink or K9Copy in shrink/copy mode) can extract the mpeg-2 video stream, run it through a requantizer which degrades quality, and finally re-packs the video data into the stream again.  This method is quite fast and is usually used to shrink a dual layer DVD (approximately 9 GB) down to single layer size (approximately 4.7 GB).

    Examples of requantizer software:
    K9Copy (GUI)
    vamps (CLI) - low-level command line tool...not capable of making DVD backups on its own
This isn't meant to be an exhaustive list of solutions for backing up DVDs, but it should get you started in the right direction.  Experiment and choose the method/software that best suits your needs.

ISO Image Backup Instructions

I wanted a solution that preserved the original quality of the video and audio, so I went the route of creating ISO images of my DVDs.  One advantage to this method is that it still allows you to easily transcode to other formats later (for use on smartphones and other embedded devices) since software like Handbrake and K9Copy can read and transcode from ISO images as well as regular DVD discs.  Handbrake would be particularly well suited for transcoding from the ISO images at a later date because it allows you to queue multiple jobs.  Queuing jobs gives Handbrake the ability to transcode multiple DVD ISO's or your entire collection at once (one after the other) without having to transcode each DVD individually.  You might be waiting a long time if you have a lot of DVDs but at least it streamlines the process and minimizes the amount of interaction required on your part.

I chose to use the dvdbackup and genisoimage command line utilities since it was one of the simplest methods, plus it allowed me to automate the process in a bash script.  The first step is to use 'dvdbackup' to extract the video and menu files files from the DVD:

$ dvdbackup -M -v -r b -n dvdname

Replace dvdname with the volume label of the DVD disc (i.e. the name of the Movie).  You can leave off the '-n dvdname' option if you want because it can be automatically read from the DVD disc in most cases.  The '-M' option tells dvdbackup to mirror the entire disc. Refer to the dvdbackup man page for the other options that are used.

Next, use the files that were just extracted from the DVD to create an ISO image of the DVD:

$ genisoimage -dvd-video -udf -V dvdname -o dvdname.iso dvdname/

Again, replace each instance of dvdname in the command above with the volume label that you want stored in the ISO image that will be created.  This volume label should be a max of 32 characters, is normally all uppercase, and usually uses underscores instead of spaces.  The options used with genisoimage are explained below:
  • -dvd-video - generates a DVD video compliant filesystem
  • -udf - include UDF filesystem support
  • -V dvdname - applies the appropriate volume label to the ISO image so that when you play the ISO image in VLC or other software it will show the name of the movie
  • -o dvdname.iso - specify the output file for the image
  • dvdname/ - the directory containing the dvd files that were extracted with dvdbackup
That's it...two commands and you should have your DVD backed up.  I should note that there doesn't seem to be one method out there that works with every single disc, so be willing to use other software like K9Copy if this doesn't work.

1 comment: