Ripping DVDs
Published by packi on

While rummaging through my projects folder I’ve discovered the following script, I’ve written some time ago. It’s a script that rips the longest track from a DVD, but doesn’t compress them. That preserves all the languages, subtitles and doesn’t introduce new compression artifacts. But at the expense of disk space, that’s not too valuable nowadays, a DVD needs about 5 to 7 GB.
You’ll need lsdvd and transcode installed in order to run this script.

#!/bin/bash
#
# shellrip.sh − Copyright © 2006 by Patrick Staehlin <me@packi.ch>
#
# Rips the vob's from a DVD in 1 GB chunks.
#
# Usage:
# ./shellrip.sh [tracknr] [target_dir]
#
# The default tracknr is the longest track on the disk.
# If you don't specify target_dir, the dîrectory will be the dvd's title.
#

lsdvd /dev/dvd > tmpout 2> /dev/null
title=`grep "Disc Title" tmpout | cut -c 13-`
trackToRip=`grep "Longest" tmpout | cut -c 16-`
rm tmpout

if [ "x$2" != "x" ]; then
  title=$2
fi

titleAbs=`pwd`/$title;

if [ "x$1" != "x" ]; then
  if [ $trackToRip = $1 ]; then
    mkdir $title;
    cd $title;
  else
    trackToRip=$1;
    mkdir $title;
    cd $title;
    mkdir $1;
    cd $1;
    titleAbs=$titleAbs/$1;
    title="$title-$1";
  fi
else
  mkdir $title;
  cd $title;
fi

echo "DVD: $title will rip $trackToRip";
dr_exec tccat -t dvd -T $trackToRip,-1,1 -i /dev/dvd 2> /dev/null | 
dr_splitpipe -f $titleAbs/nav.log 1024 $titleAbs/$title vob 2> /dev/null | 
tcextract -a 0 -x ac3 -t vob | tcdecode -x ac3 | tcscan -x pcm