I recently purchased a large number of movies from a very cool video store which was closing. It was a terrible disaster. Sure, I got a bunch of DVDs from it. But I did not gain access to any new movies -- I could have rented all these any time I wanted. Instead, the amazing collection in the possession of the video store is now split up in the hands of a bunch of individuals like me. It is not a collection anymore, and is far, far less useful to the community.
But this is a technical blog, not a library science blog. So where could I be headed with this?
Well, I don't want to sit around and import all these DVDs by hand. I want to set up a machine so that I can just drop a DVD in there and walk away, and have it rip the DVD for me. I got a headless computer and set it on my network. It's got a DVD drive, a large hard drive, and a samba server.
I set up ivman to respond to the dvd insertion event and to fire a script.
I edited /etc/ivman/IvmConfigActions.xml. Here is a stripped-down version of that file:
<?xml version="1.0" encoding="UTF-8"?> <ivm:ActionsConfig version="0.2" xmlns:ivm="http://www.eikke.com/ivm"> <!-- This is what I added --> <ivm:Match name="hal.volume.disc.is_videodvd" value="true"> <ivm:Option name="exec" value="/opt/ripdvd.sh '$hal.block.device$'" /> </ivm:Match> </ivm:ActionsConfig>
I based that entry off of a sample that was left in the comments of the Debian ivman package's version of IvmConfigActions.xml. The comment shows how to mount the dvd and then play it with mplayer.
My version of the file runs my ripdvd.sh script, which runs Handbrake to rip the dvd. I also decorate the script with some beeps to let me know that it's working, and eject the disc when done.
Note that, while Debian provides a Handbrake package, I installed it from source instead. In building it, it downloads the source code of all of its codec dependencies and builds them.
Here's the text of my ripdvd.sh script.
#!/bin/sh # Acknowledge that we are starting beep -f 1400 -l 250 DVD="$1" HANDBRAKE=/opt/handbrake/bin/HandBrakeCLI LOG="logger -p daemon.info -t ripdvd.sh " OUTDIR="/var/Data/Movies/Imports/" function beep_success() { beep -f 750 -l 80 -r 5 -D 20 } function beep_failure() { beep -f 200 -l 900 } function dvdrip() { $LOG "Beginning rip of $DVD" local LABEL=`file -s "$DVD" | cut -f 2- -d "'" | cut -f 1 -d "'" | sed -e 's/ *$//'` $LOG "$DVD contains $LABEL" $LOG $HANDBRAKE --verbose 9 --input "$DVD" --longest --output "$OUTDIR/$LABEL.avi" --size 600 --native-language eng --aencoder lame $HANDBRAKE --verbose 9 --input "$DVD" --longest --output "$OUTDIR/$LABEL.avi" --size 600 --native-language eng --aencoder lame 2>&1 > $OUTDIR/HandBrake.log local STATUS="$?" $LOG "Finished importing $LABEL from $DVD (status = $STATUS)" return $STATUS } if dvdrip; then beep_success else beep_failure fi eject
I have also attached the ripdvd.sh script for download.
Attachment | Size |
---|---|
ripdvd.sh.txt | 919 bytes |