]> code.delx.au - transcoding/blob - rip-dvd
Moved from jamesstuff
[transcoding] / rip-dvd
1 #!/bin/bash -e
2
3 DVD_DEVICE="${DVD_DEVICE:-/dev/dvd}"
4
5 if [ -z "$1" ]; then
6 echo "Usage: $0 NAME [num]"
7 exit 1
8 fi
9
10
11 # Calculate the name for ripping
12 base="$1"
13 last="$(find . -maxdepth 1 -type d -name "${base}*" | sort -n | tail -n 1)"
14 if [ -z "$last" ]; then
15 num="1"
16 elif [ -n "$2" ]; then
17 num="$2"
18 else
19 num="${last##./${base}}"
20 num="$(($num + 1))"
21 fi
22 next="${base}${num}"
23
24
25 # Sometimes the cached keys are wrong, since it only takes a few seconds to
26 # recrack I prefer to do it each time
27 rm -rf ~/.dvdcss
28
29 # Need to use libdvdread/libdvdcss to unlock the drive before copying
30 identify-dvd "$DVD_DEVICE"
31
32
33 echo
34 echo
35 echo "Will rip to '$next'"
36 for i in $(seq 3 -1 1); do
37 echo " $i..."
38 sleep 1
39 done
40
41
42 # Rip to ISO skipping bad sectors then decrypt to VIDEO_TS directory
43 set -x
44 rm -rf "${next}" "${next}.iso"
45 ddrescue -n -b 2048 "$DVD_DEVICE" "${next}.iso"
46 dvdbackup -n "$next" -M -i "${next}.iso" || true
47 identify-dvd "$next"
48 rm "${next}.iso"
49 eject "$DVD_DEVICE"
50