UPDATE – unless you want to understand how this works, then you should check out k9copy instead.
UPDATE – Now works on Gutsy
I wrote a bash script to help you duplicate your DVDs. This may be illegal depending on where you live, but if you use your DVDs regularly you should have backups, to protect your investment. This script will backup the DVD to your hard disk, decrypt it, and create a directory structure that you can burn back to DVD-R. The following assumes that you are using Ubuntu, but I’ve run the script on both Libranet and Mandrake with only minor modifications (see comments within the script for hints.)
- Add universe and multiverse repositories to /etc/apt/sources.list (if you need help doing that, drop me a line via the comments below).
- Paste this in a terminal to install the script’s dependencies (various media processing libraries) and to download the script itself:
sudo su -c 'echo deb http://packages.medibuntu.org/ gutsy free non-free >> /etc/apt/sources.list'
sudo su -c 'echo deb deb-src http://packages.medibuntu.org/ gutsy free non-free >> /etc/apt/sources.list'
sudo apt-get update
sudo apt-get install libdvdcss2 libdvdread3-dev mkisofs dvdbackup dvdauthor transcode lsdvd
wget http://www.flavor8.com/dvd/streamanalyze_0.4-9_i386.deb
wget http://www.flavor8.com/dvd/streamdvd_0.4-9_i386.deb
sudo dpkg -i streamdvd_0.4-9_i386.deb
sudo dpkg -i streamanalyze_0.4-9_i386.deb
wget http://www.flavor8.com/dvd/DVD-Duplicator.gz
gunzip DVD-Duplicator.gz
chmod +x DVD-Duplicator
echo "Installation done"
echo
- Now, some final configuration is needed; first, you need to work out the file system and mount points of your dvd drive, if you don’t know them already.
- To do this, type: cat /etc/fstab; you should see a table which includes something like the following:
/dev/hda /media/cdrom0 ... /dev/hdb /media/cdrom1 ... /dev/hdc /media/cdrom2 ...
- Put a DVD into the dvd drive that you want the script to use
- It should automount; in gnome or kde you’ll see a prompt asking you what you want to do. Hit cancel, or ignore.
- To work out which is the drive in question, I did the following:
> ls /media/cdrom0 > ls /media/cdrom1 > ls /media/cdrom2 AUDIO_TS JACKET_P VIDEO_TS
So, in my case, /media/cdrom2 is the drive, and (from the drive table that I got above) I can see that this refers to /dev/hdc filesystem.
- To do this, type: cat /etc/fstab; you should see a table which includes something like the following:
- Use your favorite text editor (vi, gedit, kate, whatever) and edit DVD-Duplicator; you’ll need to change DVDDEV and DVDDRIVE to whatever values you just discovered are appropriate for your system. Save.
- Now you’re ready to make some backups!
To use it, on the command line, type: ./DVD-Duplicator folder-name, where folder-name is the name of the directory that you want the dvd to be backed up to. The directory will be created if it doesn’t exist already. Example, you might type ./DVD-Duplicator thematrix. Once the script finishes, you can now use k3b (or your favorite dvd/cd burning program) to burn the dvd from the AUDIO_TS and VIDEO_TS directories that were created under the directory you specified. (Hint: the script can also generate an iso file for you to burn, if you have the hard disk space to spare; that way, you don’t have to worry about copying the files from AUDIO_TS and VIDEO_TS. To use the script in this way, you might type: ./DVD-Duplicator thematrix thematrix-iso.)
If you have questions on getting it working, suggestions for improvement, etc, please post a comment here.
Related Comments (59)
Howto: Script para copias de seguridad de DVD’s en Ubuntu…
Este bash script ayuda a realizar copias de DVD’s bajo Ubuntu. El script realiza una copia de seguridad del DVD en el disco duro, lo descifra y crea una estructura de directorio que puede ser quemada de nuevo en un DVD-R. El autor, con pequeñas modif…
I still think that DVD Shrink under wine is the best solution for linux.
I have tried just about everything out there, from dvdbackup/vobcopy, DVD Stream, DVD::RIP, etc… and none just seem as easy to use or just work like DVD Shrink.
The great thing about the script, once you get it setup, is that you can put the dvd in, run the command, and let it do its work. Literally a 30 second operation to get it running.
If that is what I was looking for, dvdbackup or vobcopy does a great job of that.
However, I re-authorized my DVDs to take everything out except the movie and the audio tracks I need. Not something that can easily be done by other programs out there right now. Though there is a GUI front-end, I forget its name, that is taking the right step in that direction.
Yes, and in fact the script uses dvdbackup in cases where it can; however, since dvdbackup doesn’t do compression, the script will test for size, and if necessary drop non-movie features, and only if necessary compress.
That sound great and all, I am sure it will come in handy for many users.
Personally, compression for me is a no no. Being an audiophile and videophile I am looking for the best quality I can get. With DVDs looking good on my HDTV, but not great when compared to HD. I just can’t sacrifice any quality. It doesn’t help when DVDs have really bad transfers, like Tombstone’s first release. That and running a bad source through my video scaler (I love my DVDo iScan VP30) doesn’t help the cause either.
DVD Shrink works great for me to just rip the DVD with what I need. No fancy settings or anything, it just works and is easy. Which unfortunately, just is more than DVD ripping software under linux claim right now.
Do you split large(r) DVDs? Or do you have a dual layer burner? (If the latter, then I guess dvdbackup will work in all cases, right?)
Well, here is the thing. I don’t burn DVDs at all.
I have a 2 TB HDD array that stores all my DVDs, CDs, photos and recorded TV. I have a MythTV box and also a Roku PhotoBridge that I use to interface with my HDTV, mainly the Roku PB since it is silent. I then stream everything from the network to the TV. The Roku doesn’t handle menus anyways, so there is no point in having them. I also never watch the bonus material, I am only interested in the movie. This also includes directors commentary, that gets ripped own too.
It just helps that I want to rip all the junk out in the first place, but it is also a huge space saver. I have many DVDs that are sitting at the 7 to 8 gig limit, but once I get rid of all the extra junk, they are sitting at 2-4 gigs. Less space taken up means longer the space lasts and longer before I have to build another HDD array.
But, I do have a DL DVD burner, though the media is right on the cuff of being cost effective.
how do you backup your 2TB server?
Currently?
I don’t.
The next 2TB array I make will most likely use Raid 5, to have a fault tolerence of a 1 drive failure. Then I will have to copy all 2TB off one to the other and then rebuild the other once in a Raid 5 format also.
couple of shell scripts i wrote to rip movie files to 4gig dvds without all the extra crap:
(simple)
http://vi.sh.nu/~jaymz/files/dvdrip.sh
(has dialog interface)
http://vi.sh.nu/~jaymz/files/torn
Cool, thanks.
This worked great!!
I want to re-post it since your site is no longer up.
I will re-post it here soon.
If you have a problem and want me to take it down there ia a contact me option on my home page.
I now use k9copy instead of DVD Shrink under wine. Works very well, and there’s no need for Wine.
An even better solution is forget “shinking” DVDs, period. Go out and get yourself a new DVD burner. Make sure it burns dual-layer DVDs (most all of them do now).
Then you won’t need to shrink anything….
That’ll be great once the media come down in price…
You can also check out http://openfacts.berlios.de/index-en.phtml?title=lxdvdrip
Yeah, I wrote this script a couple of years ago before I knew of lxdvdrip. It has several features I don’t support yet, but I still prefer my script since it’s more easily hackable.
Definitely check it out though.
=?utf-8?B?ZGVsLmljaW8udXMvcG9wdWxhcg==?=…
Google
http://www.google.com/base/sea…0&a_o759=0&a_n215=Job%20functiDate: 3/27/2006 11:15 PM
Digital Web Magazine – Preparing for Widescreen
http://digital-web.com/articles/preparing_for_widescreen/Dat...
Can’t you make a script that will make a mpeg movie with the video and audio in sync. Never been able to get the video and audio in sync
Hm, there’s no automated way that I can think of for doing that. However, seems like it should be possible to write a script that would adjust the timing by a specified amount. I’ll give it some thought.
Brilliant… so far the script is running and hopefully backing up a dvd as I type
One question; what parameters need to be changed to only back up the movie??? if that can be done
thanks
Hello, by “only back up the movie”, do you mean without any of the extras? The script will try and do that automatically if it can’t fit all the extras onto the DVD-R — first it tries to work out which is the movie (assuming it is the largest track), and then passes that to streamdvd.
The command looks like this:
dvdauthor -t -o ${OUTFILE}/backup -f \
“streamdvd -i ${DVDDEV} -t ${TRACK} -s ${VPOS},${APOS} |”
See streamdvd’s documentation for an explanation on what each of the parameters should be.
How to backup dvd’s with ubuntu…
Flavor 8 » How To: Back up your DVDs in Ubuntu……
Anybody tried qvamps? how is that foe spped compared to the alternatives?
In the ’sudo apt-get install …’ part you are missing lsdvd.
Thanks
Hi. First of all thanks for this howto and the script provided. Second of course a question. Is there a easy way in your script to make it copy the movie but also the 1 or all of the alternative spoken languages
Thanks in advance
Tino
Hi, if the dvd will fit on a dvdr without compressing it, you’ll get everything, including menus, subtitles, etc. However, if it has to compress, it will drop everything but the main audio and video track. Streamdvd cannot take more than one audio track, and it does not deal with subpictures (subtitles, etc). However, it wouldn’t be too tough to make the script give you a choice of which audio track to use; here’s how to approach it, if you want to get your hands dirty:
Look at the shrink() function; first, it works out which track to use, using lsdvd. Then it passes the track number to streamanalyze, in order to work out which video position, audio position, and shrinkage factor to use (notice that it pipes to analyzetrack, which is a function further up in the script). To get the behaviour you’re looking for, I’d modify analyzetrack so that it didn’t supply APOS, and make another call to lsdvd after streamanalyze, passing parameters like this: lsdvd -a -t ${TRACK} ${DVDDEV}
That’ll give you a list of all audio tracks, like this:
Audio: 1, Language: es – Espanol, Format: ac3, Frequency: 48000, Quantization: drc, Channels: 2, AP: 0, Content: Undefined, Stream id: 0×80
Audio: 2, Language: es – Espanol, Format: ac3, Frequency: 48000, Quantization: drc, Channels: 6, AP: 0, Content: Undefined, Stream id: 0×81
You could then parse with awk, and offer to the user as a choice, e.g. “choose audio (1 | 2)”; if the user chooses 1 (in the above example), set APOS to 0×80, otherwise to 0×81.
The only complex part of all of this is awk; if you are new to awk, do some googling on it, and read the tutorials. It’s pretty straightforward once you get into it.
Hello, great scripts.
When i use it the output comes in widescreen format. How can i avoid that?
Best regards Claus
Hello Claus,
When you type lsdvd -x /dev/your-dvd-drive , what does it tell you about the track that it identifies as the longest one? Do you have both widescreen and pan&scan on the dvd? My guess it that the script is picking the widescreen simply because it’s the longest on the dvd. Let me know if my assumption is wrong.
Thanks
You are right, the longest track are nr 01 which have widescreen format, and nr. 02 is the one i would like to use.
Is it possible with and extra option to ./DVD-Duplicator ?
Best regards Claus
claus@tv:~$ lsdvd -x /dev/hdc
libdvdread: Using libdvdcss version 1.2.9 for DVD access
Disc Title: mydvd
Title: 01, Length: 02:59:38.210 Chapters: 51, Cells: 52, Audio streams: 02, Subpictures: 09
VTS: 01, TTN: 01, FPS: 25.00, Format: PAL, Aspect ratio: 16/9, Width: 720, Height: 576, DF: Letterbox
Title: 02, Length: 00:02:04.020 Chapters: 02, Cells: 02, Audio streams: 01, Subpictures: 08
VTS: 02, TTN: 01, FPS: 25.00, Format: PAL, Aspect ratio: 4/3, Width: 720, Height: 576, DF: ?
…
Longest track: 01
Hey Claus, I snipped your comment down a little – hope you don’t mind
Yeah, this shouldn’t be too tricky to modify the script to do that. However, check out my latest post about k9copy… I think it’ll suit your needs much better. I think the script is still useful, for example if you are doing a batch of DVDs, but probably k9copy will meet most people’s needs much better.
Cheers
Hello-
/dev/hdc: 2298496 blocks are free, 2304062 to be written!
It looks very great but i have a problem, the outputs does not fit and dvd (4.7). I have tried to movies and get something like this:
( gnomebaker) Executing ‘builtin_dd if=/home/claus/potter.iso of=/dev/hdc obs=32k seek=0′
Hello, was this with k9copy or with my script? With either one you can adjust the size of your DVDRs…
In my script, edit it, and you’ll see a variable named “DVDRSIZE” — try changing to 4300 (or whatever).
In k9copy, go to the settings tab, and you’ll see “DVD size” – change to 4300 (or whatever).
Hello.
I tried k9copy with settings from 4000 but it gives the same output. I try again because i like k9copy. I found another program xdvdshrink which is as nice as k9copy, and which shrink and rip the dvd nealy perfect. My only problem is still the ratio aspect. The output is still widescreen and i want 4:3.
Well, maybe it is a specific problem to this specefic movie, but it would be nice to find a solution anyway.
k9copy and xdvdshrink damn nice programs
best regards Claus
The parsing of df for free space was invalid for ubuntu systems; please download the latest version (same link, above).
hey, you may want to mention that the user has to chmod the file to executable:
chmod +x DVD-Duplicator
hi, I am getting errors when I type make into the terminal. I first had to make sure make was installed, then I got gcc messages. I have gcc-3.3 and 4.0 installed. Make gives a long liteny of error messages. any idea’s?
Hm, you must have the “wrong” version of something. Try http://flavor8.com/index.php/2006/04/08/how-to-back-up-your-dvds-in-ubuntu-ii/ instead; if that doesn’t work for you, paste some of the output from make here and I’ll see if I can figure it out.
[Ed - trimmed error output]
make: *** [all] Error 1
rob@ubuntu:~/StreamAnalyze$
I figured it out..I had to install g++ and related libs. Thanks for the help. You can delete that long post if you wish..Thanks again!!
BTW—Works great!!!
Hi Reuben, I’m trying to download your script, but I am geting a 404 error — nothing found. Is something amiss?
-Steve S.
Hey Steve, thanks for letting me know. I just switched hosts and had missed the directory those were in. Try again, let me know how you like the script.
Cheers
Reuben
Hi – I am having some difficulty getting StreamDVD-0.4 to compile. I have all of the dependencies and the latest version of g++, gcc. I extracted the files to /usr/local/bin and cd to StreamDVD-0.4. I run make and I get the following:
g++ -g -Wall -ldvdread -lm -o streamdvd -I. -Implex streamdvd.c requant.c mplex/*.c mplex/*.cpp
streamdvd.c: In function âvoid get_av_delay()â:
streamdvd.c:176: warning: converting to âintâ from âdoubleâ
requant.c: In function âint slice_init(int)â:
requant.c:1434: warning: comparison between signed and unsigned integer expressions
requant.c: In function âvoid mpeg2_slice(int)â:
Then it goes on and on showing errors and then finally:
make: *** [all] Error 1
Can anybody help? Thanks!
I updated the instructions to install binaries of StreamDVD and StreamAnalyze.
is there a way to extract only audio from a dvd and make a cd?
Check out “tovid” (google it) — if you run it on a video file, you’ll see that at some point in its processing it splits the audio and video, and then later recombines them. So, yes, you could do this.
I ripped a DVD, but the Subtitles are missing. Is there a way to rip the subtitles and add them to the already ripped DVD-Data?
I just installed on ubuntu 7.04 and was getting errors that I didn’t have enough FREESPACE. It appears as though the ubuntu parsing is wrong again…
Changed line 150 from
FREESPACE=$(df -k $OUTFILE | awk ‘(NR > 1) {printf(”%d”,$3/1000)}’)
to
FREESPACE=$(df -k $OUTFILE | awk ‘(NR > 1) {printf(”%d”,$4/1000)}’)
and it appears to be working fine now.
Note: Comment line 28 is
Assuming I have the success others have, thanks for a great tool!
When will this script be working in gutsy?
Done
I did see that. I used your script in breezy and it worked great. K9copy, is telling me It is copying the files, but does not leave an image anywhere on my disk to copy. I downloaded the the script along with all libs and dependencies but to no avail in gutsy (I gave it a shot). dvd:rip is far too complicated for me. When I type in ./DVD-Duplicator, my system says invalid command or something like that.
I added an extra command to my instructions. Make sure you’re in the same directory that you were when you downloaded the script, and then type:
chmod +x DVD-Duplicator
(this gives the script executable permissions.)
I’d give k9copy another go – it probably tells you where the image is, or there is an option to tell it where to put the image, if you look hard enough.
k9copy asks where to put the image, I tell it and there is nothing there. I searched my entire hard drive—not there as far as I can tell. I’ll try the command–I like it better anyway.
Seems to be working. Thanks!!
This line
echo deb deb-src http://packages.medibuntu.org/ gutsy free non-free >> /etc/apt/sources.list’
Has an error and misforms the sources list.
Noticed the extra deb on the front it should be.
echo deb-src http://packages.medibuntu.org/ gutsy free non-free >> /etc/apt/sources.list’
Hi Reuben
I’m trying to use DVD-Duplicator in Hardy, but no go. Can you help?