Back to the Tips Index
Here is a perl script that will use the handbrake CLI (Command Line Interface) to extract mp4 tracks from a DVD. Do not use it to make illegal copies of tracks! Using the Handbrake CLI can sometimes allow extracting tracks that cannot be extracted using the graphical interface. This is especially true when if the graphical Handbrake interface quits before managing to scan the entire DVD disc.

You must download the handbrake CLI as a separate application from here:
Download the HandBrakeCLI program and drag it to your /Applications folder.

You may also find this page to be helpful:

Put the contents of the below script into a file called "ripper" and then execute:

chmod +x ripper

Then you can execute the script by invoking it in Terminal (type its name and press return). You will either have to be in the same directory where you placed the ripper file, or you will have to give the pathname to where the ripper file you created can be found. (See the discussion below the script.)

$volume=shift @ARGV;
$oroot=shift @ARGV;
$tracks=shift @ARGV;

foreach $arg (@ARGV ) {
    if ( $arg =~ /-width=(\d+)/ ) {
    } elsif ( $arg =~ /-height=(\d+)/ ) {
    } elsif ( $arg =~ /-wide=(\d+)/ ) {
    } elsif ( $arg =~ /-high=(\d+)/ ) {
    } elsif ( $arg =~ /-start=(\d+)/ ) {

my $usage=0;
if ( ! -d "/volumes/$volume" ) {
  print STDERR "no volume /volumes/$volume -- wrong name for disk or no disk\n";

if ( $oroot eq '' ) {
  print STDERR "missing filename root (second argument)\n";

if ( $tracks == 0 ) {
  print STDERR "missing tracks (third argument)\n";

if ( $usage ) {
  print STDERR "Usage: ripper.tool volume fileroot tracks\n";

my $sizearg='';
if ( $width != 0 and $height != 0 ) {
    $sizearg="--width $width --height $height";

foreach $track ( $start .. $tracks ) {
    my $cmd="/Applications/HandBrakeCLI --input /Volumes/$volume/VIDEO_TS" .
        " -o $oroot.$track.mp4 --title $track --vb 1500 --two-pass --deinterlace" .
        " --aencoder faac --encoder x264b30 --mixdown dpl2" .
        $sizearg . "--ab 160 --arate 48";
        # " --width 624 --height 480 --ab 160 --arate 48";

    print STDERR "$cmd\n";

Using ripper

After creating the file called ripper with the above contents and making it executable, insert a DVD.

You need to decide how many tracks you will try to get from it. Sometimes the first track is a combination of all the other tracks, in which case it will take a long time to rip and will make a large mp4. This is the case when there is a disc with many episodes that also has a "Play All" track. Other discs have only one useful track. Other discs have many tracks. You can get some idea by playing the dvd with a normal dvd player (E.g. Mac's DVD player or VLC) and examining the main menu. If the Handbrake graphical interface can scan the disc (but not rip it) you may be able to get a clue as to how many useful tracks there are by examining the "Title" menu.

After you know how many tracks, you must determine the volume name used to mount the DVD. This is simple:

ls /volumes
The ls command above lists the entries in the /volumes directory, which happens to be the list of mounted volumes. One of those names is the DVD you use inserted. You will have to copy-paste or type that name exactly as it appears later when you form your ripper command.

Finally, you'll need to pick a name for the mp4 file(s) generated by the handbrake CLI. The ripper tool will automatically insert a track number for you, by appending it to the name you provide. Do not include ".mp4" at the end of the name -- the ripper tool will do that for you too.

So, now you're ready to create a ripper command line. It has three required arguments, which must be in the correct order:

  1. The volume name
  2. The mp4 file name
  3. The number of tracks to rip
For example (assuming you are in the directory with the ripper tool):
./ripper COOL_DVD_S1D1 cooldvd 4
The above command will rip the first 4 tracks from a dvd mounted at /volumes/COOL_DVD_S1D1 and the tracks will be called: cooldvd.1.mp4, cooldvd.2.mp4, cooldvd.3.mp4 and cooldvd.4.mp4.

There are also some optional arguments you can provide after the first three required arguments. You can change the width and height of the resulting mp4 files. You can also skip over some tracks to start at a track other than number 1. Below is an example that is similar to the one above, but it produces 720x400 instead of the default 640x480, and it skips the first track:

./ripper COOL_DVD_S1D1 cooldvd 4 -wide=720 -high=400 -start 2
The above command will skip the first track and rip the next 3 tracks from a dvd mounted at /volumes/COOL_DVD_S1D1 and the tracks will be called: cooldvd.2.mp4, cooldvd.3.mp4 and cooldvd.4.mp4. All tracks will be 720 pixels wide by 400 pixels high.

When you use ripper it uses the Handbrake CLI to scan the disk. The Handbrake CLI puts out a long series of informational lines to let you know it is scanning each track. Right after that it reports what it found. This can include some useful information, such as the width and height of the track. You might want to quit the ripper tool and use the -wide=N and -high=N arguments to rip the track at the correct width and height as reported by the Handbrake CLI after it has scanned the track it will be ripping. You can quit the ripper tool by holding down the Control key and pressing the C key repeatedly (essentially, once per track you were going to rip).

Don't make illegal copies of DVDs! But, you may use the ripper tool wherever it is legal to use the Handbrake CLI.

All content copyright Howard Cohen 2008 , all rights reserved worlwide.