SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2012-03-07 08:23:14

jk26926
Member
Registered: 2008-12-12
Posts: 32

dvd backup script

I have small children and they are hard on DVD videos.
I prefer not to purchase the same ones over and over again.
I also prefer the portability of having my videos in digital format.
Between k9copy , K3B, and Brasero coupled sometimes with AcidRip. all of my back up / conversion needs were met until recently. That is when I went on the hunt again. I found dvdbackup and was able to use it coupled with genisoimage to catch what others had missed. It's time consuming though. Of course like any #!er I decided a script was in order. I am not great at it just yet but this one works just like I planned. Tested repeatedly and moved it to /bin to make it globally executable.
I named it dvdin but feel free to name it anything you like.
gedit Script_name.sh
Copy all and paste into Script_name.sh
Save
Edit as you see fit.
make sure you have the dependencies (see line 2 of the script) what did not come with #! I got with sudo apt-get install. 
Save again.
In command line run "chmod +x Script_name.sh" without quotes.
sudo cp or mv Script_name.sh /bin/Script_name
To run it is goofy simple just navigate to the target directory and run "Script_name movie _title"
WARNING this will briefly take up twice the disc space of the dvd.
The script follows...

#!/bin/sh
#dependencies: dvdbackup, genisoimage, espeak(if you like)
#following line not needed but gives a reminder if you forget. 
echo var_1=title
#backup dvd with dvdbackup var_1=title
dvdbackup -Mv -n $1
#Only there to help me keep track of the process 
date
#create .iso image with genisoimage
genisoimage -dvd-video -o "$1".iso $1
#Only there to help me keep track of the process 
date
#remove directory created by dvdbackup that's all now in the .iso
rm -rv $1
#uncomment and or edit the following as you please 
#only there to let me know the process finished
#echo call me rock god
#eject
#espeak "pay attention to me "$(whoami)""

If  the results are too large for your taste you can still walk it through mencoder and shrink it.
I've found AcidRip to be the most user friendly front end for mencoder the results are reliable and what you ask for as far as quality. Larger file size equals better copy.
To use the .iso just run "sudo mount  -o loop movie_title.iso /media/cdrom0" (make sure there is not a disk in the drive)
Then open AcidRip and it should load itself by default.
WARNING in Statler I had to get the Debian multimedia package and then purge/reinstall AcidRip to get it working correctly. Probably will work if you install Debian multimedia before installing AcidRip.

Offline

Be excellent to each other!

#2 2012-03-07 08:29:05

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: dvd backup script

cool. very simple and the script looks good. the only thing you might want to consider is quoting your variables, especially $1, to catch possible special characters, spaces etc. i see you do it sometimes but it can't hurt to just do it all the time.

good job of taking this to the commandline instead of using all sorts of GUI-stuff.

Offline

#3 2012-03-07 08:32:46

jk26926
Member
Registered: 2008-12-12
Posts: 32

Re: dvd backup script

Offline

#4 2012-03-07 09:47:11

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: dvd backup script

Offline

#5 2012-03-07 13:14:48

Kino
#! CrunchBanger
Registered: 2010-07-29
Posts: 130

Re: dvd backup script

Hi,

How does this differ from readom??

After unmounting the dvd drive I only need to use the single  command:

readom /dev/scd0 f=/home/folder/name.iso

and the job is done.

However, this will not work with encrypted dvds.

Offline

#6 2012-03-07 14:03:45

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: dvd backup script

^ never heard of readom before. is this for mounting the iso-file?
i think the advantage of using 'mount' is that it's native on every Linux system... or is readom native as well?

Offline

#7 2012-03-07 14:20:17

Kino
#! CrunchBanger
Registered: 2010-07-29
Posts: 130

Re: dvd backup script

As far as I know readom (read optical media) is native - I don't recall installing it (but I might have done!)

The dvd drive has to be unmounted before using readom so after inserting the dvd into the drive, enter in the terminal:

sudo umount /dev/sdc0

followed by the readom command.

If it is not an encrypted dvd then an iso file will be created in the folder specified.

Offline

#8 2012-03-07 15:05:47

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

Re: dvd backup script

'readom' comes with the 'wodim' package.

Offline

#9 2012-03-07 15:08:56

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: dvd backup script

oh, it rips the media in the drive to a .iso ? cool, never knew that. useful indeed!

Offline

#10 2012-03-07 16:48:35

Darksoul71
New Member
Registered: 2012-03-07
Posts: 9

Re: dvd backup script

Hi there,

I share the same problem here:
I have two women who are not paying attention to my DVDs smile

Beside this I wanted to have all my DVDs on a centralized storage attached to my HTPC. Currently I am in progress of transfering all DVDs to file with this script:

#!/bin/bash
# This script "rips" all titles of a DVD automagically into separate mpg-files. 
# Doing this for encrypted DVDs of course relies on a mplayer compiled with libdcss support

# Get prefix from Commandline. Of course the prefix can also be with target path
prefix=$1

# Loop through all 99 theoretically available titles on DVD 
# and dump them all to file 
for count in {1..99}
do
  # Generate an two-digit prefix
  if [ $count -lt 10 ]; then
    file_count="0$count"
  else
    file_count="$count"
  fi
      
  if [ -n "$2" ]; then
    # -dvd-device /path/to/my.iso       -> Dump Video stream(s) from ripped ISO-file
    # -dvd-device /path/to/my/ripped/dvd/ -> Dump Video stream(s) from ripped DVD structure 
    #                         somewhere in your filesystem
    mplayer dvd://$count -dvd-device "$2" -dumpstream -dumpfile $prefix-$file_count.mpg
  else
    mplayer dvd://$count -dumpstream -dumpfile $prefix-$file_count.mpg
  fi 
done

# Check if DVD was single title only and rename
# single output-file to title without extension
if [ ! -f "$prefix-02.mpg" ];
then
  mv "$prefix-01.mpg" "$prefix.mpg"
fi

The script will accept a target filename with possible directory prefix as first parameter. If you have already copied over the DVD as ISO or file structure to your harddisk, you can simply give the path to the ISO or subdirectory via second parameter.

The script will copy the conent of each title into a single vob-file containing all stuff from the original file (Subtitles, audio, video). You will loose the language information though.

Benefit of your method: The resulting ISO resembles the original structure of the DVD and can be easily burned to a DVD-R. MPlayer will also play back DVDs stored as ISO as well without mounting them as loop back device.

Benefits of "my" method: I can only keep the main movie which I can select directly via XBMC without the hassle of using a DVD menu. The big disadvantage of course: Those "mpeg" files can not be directly be (re)burned as DVD but since I use them as DVD replacement and not DVD backup this is fine. When doing full ISO files you will also need much more space. I usually simply strip away unneeded audio and subtitle streams from the DVD backup prior using the script when I know that the movie has tons of languages which I will not use.

Even more perfect would be a shell script which demuxes the vob file, converts the video to h264 and remuxes all into a MKV container but I am still struggeling with subtitle handling on this topic. This way I could store even more movies on my external HDD without sacrifising video quality.

Regards,
D$

Offline

#11 2012-03-07 17:30:50

pvsage
Internal Affairs
From: North Carolina
Registered: 2009-10-18
Posts: 13,970

Re: dvd backup script

I know Handbrake supports ripping to mkv, and comes with a command-line interface.  Don't know about subtitles in it though.

EDIT:  By the way, welcome to CrunchBang, Darksoul71!  Please drop by the Introductions area and say "Hi".  We have coffee & donuts in the break room.

Last edited by pvsage (2012-03-07 17:33:22)

Offline

#12 2012-03-08 08:47:05

yuh_learn
#! CrunchBanger
Registered: 2009-09-02
Posts: 118

Re: dvd backup script

I use a simple DVD backup script that spits out an iso aswell. It uses lsdvd, dd, and notify-send and looks like this:

#! /bin/bash

if [ "$1" == "-h" ]; then
    echo "This script provides an easy way to rip DVDs"
    echo "Usage: rip [FILENAME]"
    exit
fi

title="$1"

if [ "$title" == "" ]; then
    title=$(lsdvd | grep "Disc Title:")
    title="${title:12}.iso"
fi

if [ -a $title ]; then
    echo "This file already exists"
    exit
fi

dd if="/dev/dvd" of="$title"
echo "Done!"

notify-send -i media-dvd "DVD rip finished" "Done ripping $title"

PS:

Of course you don't need to use lsdvd to grep the disc title or use notify-send to execute a notification after the rip is finished, but I find the use of dd very handy.

Last edited by yuh_learn (2012-03-08 08:50:48)

Offline

#13 2012-03-08 11:20:07

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

Re: dvd backup script

I use cli:

sudo dd if=/dev/sr0 of=/path-to-where-you-store-your-isos.iso bs=16M

gives a bit-by-bit copy.

Offline

#14 2012-03-08 12:21:52

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

Re: dvd backup script

sudo dd if=/dev/sr0 of=/path-to-where-you-store-your-isos.iso bs=16M

Offline

#15 2012-03-08 13:54:56

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

Re: dvd backup script

Yes, that is right, damo.
You would have to do the md5sum checking manually, but it is easy:
Plus, you can add a progress bar!
For the copy:

pv -ptre /dev/sr0 | dd of=/tmp/cd.iso bs=16M

Verification
# md5sum of CD image

pv -ptre /dev/sr0 | md5sum

# md5sum of the copy

pv -ptre /tmp/cd.iso | md5sum

The last 2 commands display the md5sum on 2 consecutive lines, so easy visual verification is possible

The pv program comes with a package called ... pv

hth

Last edited by xaos52 (2012-03-08 13:55:28)

Offline

#16 2012-03-08 21:22:01

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

Re: dvd backup script

Offline

#17 2012-03-09 09:29:32

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

Re: dvd backup script

To tell you the truth, I did not know of the existence of readom until it was mentioned in this thread.
Plus: pv gives you feedback on its progress and speed.

Offline

#18 2012-04-19 18:23:02

Darksoul71
New Member
Registered: 2012-03-07
Posts: 9

Re: dvd backup script

#!/bin/bash
my_files=$(find . -name *.mpg)
#echo $my_files

for file in $my_files; do
  outfile=$(echo $file | sed "s/.mpg/.mkv/g")
  echo "$outfile"  
  HandBrakeCLI -i "$file" -o "$outfile" -E copy --audio-copy-mask ac3,dts -e x264 -b 1000 -2 --width 720 -loose-crop --subtitle scan --subtitle-forced 
  #rm -f "$file"
done

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: bleh

Debian Logo