You are not logged in.

#1 2009-03-07 05:22:33

whukes
Member
Registered: 2008-07-18
Posts: 34

rdvdp - easy dvd ripping script

rdvdp is a script I wrote to make backing up DVDs to x.264 simple and fast. It uses handbrake and dvdbackup

What I wanted was a simple bash script where I could pop in a dvd, run the script with no special options, and come back 45min later with a nice x.264 rip. the other task I wanted the script to handle was being able to rip a dvd with episodes on it (tv shows, etc.). rdvdp handles both cases with ease.

For more info check out rdvdp.whukes.com

#!/bin/bash

#CONFIGURATION
DIN="/dev/dvd" #input
DOUT="/home/$USER/" #output
VBTR="4000" #bitrate
ABTR="192" #bitrate
FFRM="mp4" #file format: mp4/avi/ogm/mkv
VLE="x264" #video encoder: ffmpeg/xvid/x264/theora
CUP="1" #clean files when finished (DOUT/.rdvdpseries not removed)
    
discinfo(){
    TITLE[INDEX]=`dvdbackup -i ${DIN} -I | grep information | cut -c44-56`
    TNUM[INDEX]=`dvdbackup -i ${DIN} -I | grep containing | cut -c43-45`
}

discchange(){
    let INDEXA=DISC-1
    if [ "$INDEX" -ne "$INDEXA" ]; then 
        echo "...ejecting disc..."
        eject
        read -p "please insert the next disc [enter]" CHNG
    fi
}

dvdbkup(){
    while [ $INDEX -lt $DISC ]; do    
        discinfo        
        dvdbackup -i ${DIN} -o ${DOUT} -M
        discchange
        let INDEX=INDEX+1    
    done

    INDEX=0
    while [ $INDEX -lt $DISC ]; do
        handbrake -i ${DOUT}/${TITLE[INDEX]}VIDEO_TS -o ${DOUT}/${TITLE[INDEX]}.${FFRM} -t ${TNUM[INDEX]} -U -F -f ${FFRM} -e ${VLE} -b ${VBTR} -B ${ABTR}
        if [ $CUP = "1" ]; then
            rm -rf ${DOUT}/${TITLE[INDEX]}
        fi
        let INDEX=INDEX+1
    done
exit
}

hndbrk(){
    while [ $INDEX -lt $DISC ]; do    
        discinfo        
        handbrake -i ${DIN} -o ${DOUT}/${TITLE[INDEX]}.${FFRM} -t ${TNUM[INDEX]} -U -F -f ${FFRM} -e ${VLE} -b ${VBTR} -B ${ABTR}
        discchange
        let INDEX=INDEX+1    
    done    
exit
}

series(){
    echo "...displaying info..."; sleep 2
    dvdbackup -i ${DIN} -I > ${DOUT}/file
    cat ${DOUT}/file 2>/dev/null
        
    sleep 2
    read -p "number of episodes: " NUME
    title
    
    INDEX=0
    while [ $INDEX -lt $NUME ]; do
        let INDEXA=INDEX+1
        read -p "Episode [${INDEXA} / ${NUME}] name: " SNME[INDEX]
        SNME[$INDEX]=${SNME[$INDEX]// /_} #replace ' ' with '_'
        read -p "Episode [${INDEXA} / ${NUME}] title: " STTL[INDEX]
        read -p "Episode [${INDEXA} / ${NUME}] chapter(s): " SCHP[INDEX]
        echo
        let INDEX=INDEX+1
    done
    
    title
    echo "verify the following: "; sleep 1
    INDEX=0
    while [ $INDEX -lt $NUME ]; do
        let INDEXA=INDEX+1
        echo "=============================================="
        echo "Episode [${INDEXA} / ${NUME}] name: ${SNME[INDEX]}"
        echo "Episode [${INDEXA} / ${NUME}] title: ${STTL[INDEX]}"
        echo "Episode [${INDEXA} / ${NUME}] chapter(s): ${SCHP[INDEX]}"
        echo 
        let INDEX=INDEX+1
    done
        
    read -p "proceed [Y\n]: " PROC
    if [ -n $PROC ]; then
        if [ $PROC = "n" ]; then
            series
        fi
    fi
    
    if [ $CUP = "1" ]; then
        rm ${DOUT}/file
    fi
    echo "...dump to ${DOUT}/.rdvdpseries..."; sleep 1

    INDEX=0
    touch ${DOUT}/.rdvdpseries
    while [ $INDEX -lt $NUME ]; do
        echo "handbrake -i ${DIN} -o ${DOUT}/${SNME[INDEX]}.${FFRM} -t ${STTL[INDEX]} -c ${SCHP[INDEX]} -U -F -f ${FFRM} -e ${VLE} -b ${VBTR} -B ${ABTR}" >> ${DOUT}/.rdvdpseries
        let INDEX=INDEX+1
    done
        
    title
    echo "about to start series mode"
    sleep 3
    
    INDEX=0
    while [ $INDEX -lt $NUME ]; do
        handbrake -i ${DIN} -o ${DOUT}/${SNME[INDEX]}.${FFRM} -t ${STTL[INDEX]} -c ${SCHP[INDEX]} -U -F -f ${FFRM} -e ${VLE} -b ${VBTR} -B ${ABTR}
        let INDEX=INDEX+1
    done    
exit
}    

title(){
    clear
    echo
    echo "          _          _       "
    echo "         | |        | |      "
    echo "  _ __ __| |_   ____| |_ __  "
    echo " |  __/ _  \ \ / / _  |  _ \ "
    echo " | | | (_| |\ V / (_| | |_) |"
    echo " |_|  \__ _| \_/ \__ _|  __/ "
    echo "                      | |    "
    echo "                      |_|    "
    echo
    echo " It's Automatic! version: 0.2.1"
    echo
}

run(){
    if [ $RUN = "1" ]; then
        dvdbkup
    else
        hndbrk
    fi
}

main(){
    RUN=0 
    INDEX=0 
    DISC=1 
    title
    read -p "dvdbackup mode [N/y]: " DBP
    read -p "multi-disc mode [N/y]: " MDM
    read -p "series mode [N/y]: " SSM
    
    if [ -n "$DBP" ]; then
        if [ $DBP = "y" ]; then
            RUN=1
        fi
    fi
    
    if [ -n "$MDM" ]; then
        if [ $MDM = "y" ]; then
            echo
            read -p "enter the number of discs: " DISC
            run
        fi
    fi
    
    if [ -n "$SSM" ]; then
        if [ $SSM = "y" ]; then
            series
        fi
    fi

    run
}

main

edit: fixed that typo big_smile thanks zenlord

Last edited by whukes (2009-03-12 01:56:42)

Offline

#2 2009-03-08 19:12:21

zenlord
Member
From: Belgium
Registered: 2006-05-24
Posts: 1,221
Website

Re: rdvdp - easy dvd ripping script

Looks very nice - I will try it out when I have the time.

Looks like you mad a typo in
echo " It's auotmatic! Version: 0.2"

Maybe you can bump the version smile

Zl.

Offline

#3 2009-03-24 20:11:23

strankan
Member
From: Sundsvall - Sweden
Registered: 2006-11-08
Posts: 97

Re: rdvdp - easy dvd ripping script

Great script! Comes in handy now that I'm beginning to move all my movies to the computer. One thing though: Older dvds that don't have any title set doesn't seem to work. It just says "title not found" and then exits the script. Not a big deal for me since I only had one of those around. Don't know if it's an issue with handbrake, dvdbackup or the script itself. Anyways, Thank you! smile

Offline

#4 2009-03-25 11:06:59

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: rdvdp - easy dvd ripping script

Bash doesn't have some sort of built in character limit for variable names you know...

Offline

#5 2009-05-15 00:11:29

kronix
Member
From: Sydney, Australia
Registered: 2006-06-09
Posts: 10

Re: rdvdp - easy dvd ripping script

Forgive my ignorance but I'm trying to compile dvdbackup but am unsure of the libdvdread directories. The install instructions are:

Compile dvdbackup.c in the src dir like this gcc -o dvdbackup -I/my/prefix/to/libdvdread/include -L/my/prefix/to/libdvdread/lib -ldvdread dvdbackup.c

From what I can gather is libdvdread 'includes' reside at /usr/include/dvdread and the 'lib' is in /usr/lib but this doesn't seem to be working. Any help or knowledge would be appreciated.

tuxer.


Am I standing too close? Should I proceed to breath out my arse--Charlie Utter, Deadwood

Offline

#6 2009-10-17 23:56:19

rab
Member
Registered: 2006-06-15
Posts: 185

Re: rdvdp - easy dvd ripping script

ahha. you may want to make sure that ${TITLE[INDEX]} is not null... especially if the $DOUT is set to the home dir, which it is by default.

rm -rf ${DOUT}/${TITLE[INDEX]}

... and yes, it did rm my home dir.


rawr

Offline

#7 2009-10-18 03:11:56

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: rdvdp - easy dvd ripping script

always do `grep rm script.sh` before you run any script from the interweb. lol i bet you got a good backup.


This silver ladybug at line 28...

Offline

Board footer

Powered by FluxBB