Backing up DVD movies under Slackware

Posted on . Updated on .

Warning: you won’t find an easy tutorial using graphical tools below, but a description on how to do this using several command line tools. Also, it seems doing the following is illegal in some countries, for some stupid reason.

Let’s suppose you have a possibly encrypted DVD movie that you want to back up to one of those 4.4 GB DVD-R or DVD+R discs you can buy in a store. To do this, you must solve two problems. The first one is about the DVD movie being encrypted, that will probably make a simple copy with dd fail, reporting an Input/Output error while trying to create the disc image. The second problem you may have is that the DVD movie disc is too big to be copied directly. For example, my American Beauty original disc has around 7 GB of data and I can’t copy it directly.

So let’s start describing the available tools in general, before diving directly into Slackware. While trying to solve those two problems I reached a Gentoo HOWTO on backing up DVDs. It mentions several ways of handling encrypted DVDs. The tricks to make dd work didn’t give me good results. dd didn’t spit any error message creating the DVD image after I had played the movie with MPlayer, but the resulting image wasn’t properly created and failed to play in MPlayer itself and in the home DVD player. The second best solution in that list looks to be dvdbackup. You’d need to install libdvdcss, libdvdread and dvdbackup itself. Another good solution is to find out which patches, if any, Gentoo uses to make K3B handle encrypted DVDs and finally install the two already mentioned libraries and recompile K3B so it can copy encrypted DVDs too. None of those solutions solve the second problem, anyway.

There are some very good graphical tools out there that let you author DVD movie discs. One of the best is, apparently, ManDVD. But let’s have a look at the list of requirements and see which ones are not present in the Slackware official packages, if you were to use ManDVD:

  • DVD Slideshow >= 0.7.5 (not provided by Slackware)

  • mplayer/mencoder (not provided by Slackware)

  • mkisofs >= 2.01

  • xine > 0.99.4

  • lame >= 3.97 (not provided by Slackware)

  • dvdauthor >= 0.6.11 (not provided by Slackware)

  • mjpegtools >= 1.8.0 (not provided by Slackware)

  • netpbm >= 10.29 (not provided by Slackware)

  • ImageMagick >= 6.2.4

  • transcode >= 1.0.2 (not provided by Slackware)

  • dvd+rw-tools >= 5.21.4

For me, that’s too complicated. My solution was to use two unofficial packages only, MPlayer/Mencoder and dvdauthor, as outlined in a Linux.com article on creating video DVDs, which itself is partly based on some excellent sections from the MPlayer documentation. Specifically, the section titled "Using MEncoder to create VCD/SVCD/DVD-compliant files". Two packages, which are not dependant on each other, are easier to manage in my humble opinion.

The outline of what you need to do is to create an MPEG file containing an AC3 audio stream and an MPEG-2 video stream, and use dvdauthor to create a DVD video disc with it. The Linux.com article describes how to convert any video to this format. This is even easier if you are creating the MPEG file from the DVD disc itself because it will probably already have the audio stream in that format, and the video stream in the proper format for sure.

Start by playing the DVD movie with MPlayer in order to locate the proper video title and select the proper audio stream with the -alang option, and also to get information on the audio stream format. For example, I’m interested in backing up my original American Beauty disc, using the Spanish audio stream. I play the movie with mplayer -alang es dvd://1.

MPlayer reports I’m using the Spanish audio stream and gives me the following useful information about the video and audio streams:

[...]
Selected DVD audio channel: 129 language: es
MPEG-PS file format detected.
VIDEO:  MPEG2  720x576  [...]
[...]
Opening audio decoder: [liba52] AC3 decoding with liba52
Using SSE optimized IMDCT transform
Using MMX optimized resampler
AUDIO: 48000 Hz, 2 ch, s16le, 448.0 kbit/29.17% [...]
[...]

Great, everything under the expected format, so I can try to copy the video and audio streams directly. The options needed to have a DVD-compliant MPEG file are -of mpeg -mpegopts format=dvd or, also, -of mpeg -mpegopts format=dvd:tsaf. The tsaf format option inserts timestamps on every frame if possible. This may be useful, so let’s use it. Do I need to reencode the video or audio streams? Not for now. Let’s run mencoder copying the audio and video streams and produce an MPEG file:

mencoder \
    -of mpeg -mpegopts format=dvd:tsaf \
    -alang es -oac copy -ovc copy \
    -o american-beauty.mpg dvd://1

The resulting file should be quite big. It takes some time to generate it but not too much. This is because we’re not reencoding the audio or video streams, but copying the streams as fast as we can. In my computer the process runs at about 175-200 frames per second. The movie plays at 25 frames per second in the PAL system. This means a two-hour long movie should be ready in 15-18 minutes. During the process, mencoder estimates how big the resulting file will be. In my case, it predicted a final size around 4500 MB, that is, 4.42 GB. Would that fit in the disc? We’ll see.

The next step is to create an XML file for dvdauthor, named american-beauty.xml in my case, with the following content:

<dvdauthor>
  <vmgm />
  <titleset>
    <titles>
      <pgc>
        <vob file="american-beauty.mpg" />
      </pgc>
    </titles>
  </titleset>
</dvdauthor>

And, finally, let’s use dvdauthor to produce a video DVD image:

mkdir image
dvdauthor -o image -x american-beauty.xml

This will take some time too, it will use another 4+ GB of disc space. When it finishes, the image directory we just created will contain a VIDEO_TS and an AUDIO_TS subdirectories, with everything ready. Run K3B and click on File > New project > New video DVD project. It will create a new project with the AUDIO_TS and VIDEO_TS directories. Clic on AUDIO_TS and drag the files from the AUDIO_TS directory in your harddrive to it, and repeat the operation with the VIDEO_TS directory. If the files fit in the disc, put a disk label and burn it.

Two side notes: there may be no files inside the AUDIO_TS directory, so don’t worry if it’s empty. You can also check the result before burning it, using mplayer -dvd-device ./image dvd://1.

What if the files didn’t fit?

If they don’t fit, you have several solutions. First off, you can buy a double-layer disc and use that instead. It will probably fit and I think the price is worth it. If you can’t burn double-layer discs, you can’t losslessly copy the video and audio streams as we did. You’d need to reencode the audio stream, or the video stream, or both. In my opinion, the first candidate should always be the audio stream. In the example above, you could see the audio stream was in AC3 format, 2 channels and 448 kbit. If it had 6 channels (5.1 surround sound), you could start by changing it to stereo sound, using the -channels 2 option and reencode the audio to a lower bitrate, replacing -oac copy by -oac lavc -lavcopts acodec=ac3:abitrate=192. I doubt you’ll hear the difference and it will save you some space. For example, I was off by a few MB and reencoding the audio stream was enough. On top of that, reencoding the audio stream is a cheap operation that won’t take much time, as opposed to reencoding the video stream.

If that’s not enough, you’ll have to reencode the video stream. You can replace -ovc copy using the options present in the MPlayer documentation webpage, using -ovc lavc and adding the video options to the -lavcopts command-line option.

Result

Once you’ve finally made it, the resulting disc will only contain the movie in unencrypted form with the selected audio stream. Insert the disc in your home DVD player and the movie should automatically start playing. No ads, no menus, no wait. Just the movie. I hope you like it that way.

Load comments