This is how to grab an audio track from a video DVD using vobcopy and ffmpeg.

I wanted to rip the music from a Tangerine Dream DVD I have, and play it on other devices.

Note: this procedure works with stereo AC3 tracks. Multichannel tracks would be different, but I don’t have any to figure out right now.

Software Prerequisites

If the DVD has been “scrambled” with CSS, you need to install libdvdcss first.

You also need to install vobcopy and ffmpeg.

On FreeBSD, libdvdcss is available in the ports (not a package), and can be installed like this:

# cd /usr/ports/multimedia/libdvdcss
# make install clean

See FreeBSD Ports in the FreeBSD Handbook for more information about installing from the ports collection.

vobcopy and ffmpeg can be installed as packages:

# pkg install vobcopy
# pkg install ffmpeg

DVD Device Node

When you insert a DVD, a device node such as /dev/cd0 will be created.

You will also see /dev/iso9660/DVD-name. Ignore this iso9660 device node. You only need the main CD/DVD device node.

Check DVD Contents

Use vobcopy to verify the DVD is readable, and to see the contents:

# vobcopy --info /dev/cd0

You should see something like this:

Vobcopy 1.2.0 - GPL Copyright (c) 2001 - 2009 robos@muon.de
[Hint] All lines starting with "libdvdread:" are not from vobcopy but from the libdvdread-library

[Info] Path to dvd: /dev/cd0
libdvdcss debug: opening target `/dev/cd0'
libdvdcss debug: using libc API for access
libdvdcss debug: disc reports copyright information 0x1
libdvdcss debug: drive region(s), region mask 0xff, RPC-II, no region code set
libdvdcss error: CSS error: drive will prevent access to scrambled data
libdvdcss debug: scrambled disc on a region-free RPC-II drive: possible failure, but continuing anyway
libdvdcss debug: requesting authentication grant ID (AGID)
libdvdcss debug: drive authenticated, using variant 0
libdvdcss debug: authentication established
libdvdcss debug: authentication success flag set, ASF=1
libdvdcss debug: disc key does not need to be decrypted
libdvdcss debug: Content Scrambling System (CSS) key cache dir: /root/.dvdcss/ROS_TANGERINE_DREAM-2018012513453300-0000000000/
[Info] Name of the dvd: ROS_TANGERINE_DREAM
[Info] There are 23 titles on this DVD.
[Info] There are 56 chapters on the dvd.
[Info] Most chapters has title 2 with 11 chapters.
. . .
[Info] DVD-name: ROS_TANGERINE_DREAM
[Info]  Disk free: 29783 MB
[Info]  Vobs size: 0 MB

Audio Formats

Audio tracks on DVDs are encoded using the AC3 codec. In my case, I can’t use AC3 files directly because I use iTunes to catalogue my music. So the audio codec and container will need to be changed to something iTunes understands.

We don’t want to re-encode into another lossy format because that will degrade the sound beyond what was already lost in the AC3 encoding.

The two lossless formats iTunes understands are WAV and ALAC. WAV is fine, but ALAC lets you embed more metadata.

Identifying the Titles to Extract

The vobcopy --info command lists information about all the titles found on the DVD, but you have to guess which titles correspond to the tracks you want to extract.

I did this by noting the track length when watching them on a DVD player, and then searching for matching lengths on the DVD.

For example, Here is how you can determine the track length of title 4:

# vobcopy -n 4 -o - /dev/cd0 > tmp.vob

# ffprobe tmp.vob

At the end of the output, you will see something like this, which shows the duration:

Input #0, mpeg, from 'tmp.vob':
  Duration: 00:08:12.68, start: 0.360000, bitrate: 5310 kb/s
  Stream #0:0[0x1bf]: Data: dvd_nav_packet
  Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, smpte170m/bt470bg/bt470bg, progressive), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn
    Side data:
      cpb: bitrate max/min/avg: 8249600/0/0 buffer size: 1835008 vbv_delay: N/A
  Stream #0:2[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s

Note: piping vobcopy into ffprobe doesn’t work; Duration becomes “N/A”.

Extracting the Music

Once you know the title numbers, you can extract the audio and convert to the required format:

vobcopy -n 4 -o - /dev/cd0 | \
ffmpeg \
    -drc_scale 0 \
    -i - \
    -vn \
    -acodec alac \
    -metadata comment="ripped from DVD AC3" \
    -metadata artist="Tangerine Dream" \
    -metadata title="Cloudburst Flight (Lisbon 2010)" \
    -metadata album="Revolution of Sound" \
    -metadata track=4 \
    cloudburst-flight.m4a

The -drc_scale 0 option inhibits AC3 dynamic range compression.

-acodec alac says to use the ALAC codec within the m4a container.

The -metadata options are conveniences. I put the comment there so I don’t later mistakenly think this is really a lossless track.

The metadata keys ffmpeg accepts are listed here: ffmpeg metadata options.

At this point the .m4a file can be imported into iTunes and the metadata will be visible.

iTunes

I only use iTunes (er, I mean, “Music”) to catalogue music. I don’t actually play anything with it.