Here's a script I use quite a bit........I have a friend who films and edits videos (singers and bands), which get put on a local Comcast channel, periodically. Then he has a master disc made and I rip-n-burn a bunch for him.....

So this script actually started out as two separate scripts, about one page of code for each........Then I started adding a few features, here and there. But, after a few mishaps, I started adding sanity checks until I felt comfortable and could rest easy that I did a good job.......If there was a mistake to be made, I probably made it........

This is not for editing, only ripping and burning.....But rest assured, it will get done right, or the script will scream and holler if something is wrong......

A few of the features include:

* Burn one disc, or a bunch at a time, and let you know which disc you're on* Tray will pop out for loading discs, and when the job(s) get done* Will automatically find the correct device for burning or ripping, or let you know if nothing appropriate is found* Will accept "file:///" URLS in path name

The script is well commented, so the script is also the documentation. Save it as burnvideo, and create a symlink called ripvideo in the same directory. A good place is to put it is in /usr/local/bin.

Also, this script is not only bash-specific but also made to run on Linux, due to probing the /proc directory for getting the drive info.......I suppose it could be ported to other OSes, but I'll leave that to you.........

burnvideo/ripvideo - NOTE: This script will always have the latest changes/updates included, while any changes made will be announced in one of the posts below.

Code:

#!/bin/sh################################################################################# burnvideo/ripvideo - burn and rip DVD videos## This is actually two programs combined into one. The script is saved as# '/usr/local/bin/burnvideo', and then a 'ripvideo' symlink is made in the same# directory. Example:# ln -s burnvideo /usr/local/bin/ripvideo## Requirements:# Linux OS# dvdbackup growisofs mkisofs <-- might have to install these# cat dd isosize fold grep mkdir mount rm rmdir sed tac tr umount## NOTE: This is a Linux only program, due to probing the /proc directory for# device info. For the external programs, the first three programs may have# to be installed, while the rest are standard programs and shipped with the# majority of Linux distros.### Written by CTWaley (aka, thegeekster), (c) February 2006## You may do anything you want with this script, as long as the line directly# above remains with it. Which means, give credit where credit is due!#################################################################################

## This is the directory to place the temporary video image when burning discs.## It should be located in a partition with plenty of room to hold the image.VIDTMP="/home/fun/video/tmp"

###### DO NOT EDIT BELOW THIS POINT ############################################

## The hex value '\x1b' is the same as the more familiar octal value '\033',## which represents the <Esc> key on the keyboardB="\x1b[1m" # Boldb="\x1b[0m" # Unbold (actually 'undo' whatever was 'done' in the first place)

## These two help identify what the hex values we're using mean"TAB="\x09"LF="\x0a"

## Function that reads the raw data from a device, using 'dd'. ## NOTE; This function is based on a script called 'rawread' by Steve Litt, ## which can be found at "Coasterless CD Burning" ## <http://www.troubleshooters.com/linux/coasterless.htm#rawread>: raw_read(){ local -i BS COUNT

test $IMGSIZE -ne $SRCSIZE && ## Double-checking for any size mismatches { warn_msg "There is a size mismatch between ${B}${SOURCE}${b} and ${B}$VIDTMP/${IMAGE}${b}. This may mean there isn't enough room to create the image, or there may be hardware/software issues to be taken care of." return 1;} ## Reassigning SOURCE to the temp image SOURCE="$VIDTMP/$IMAGE" return 0}

Usage: $PROG [-c NUM] /my/video/directory $PROG [-c NUM] /my/video/filename.isoThe name given to the video will be the name of the directory/ISO given. NUM isthe number of copies to be made (optional).

_USAGE_ fi}

## This is an important function to determine what we need to do, based on the## return code. Usage: test_iso image|block devicetest_iso(){ isoinfo -i "$1" >/dev/null 2>&1 return $?

## Some results of the return code.:<<_RETURNS_ 0: target is ISO 9660 formatted 1: target is not an ISO image, it is a file or corrupt image 2: target does not exist 5: target is audio formatted 6: target is not an ISO, it is an empty device (no disc in tray) 13: permission denied to open target (fix perms or run as root) 19: target is not an ISO, it is an unused character device 21: target is not an ISO, it is a directory 22: target is not an ISO, it is a blank/unformatted disc 29: target is not an ISO, it is a character device 30: target is unreadable (missing or bad) 255: target is too small to be a valid image_RETURNS_}

## See if we have 'growisofs'. If not, say so and bail which growisofs >/dev/null 2>&1 || { error_msg "Cannot find 'growisofs', which is needed for burning DVDs.\n" exit 1;}

## Does more than one disc need to be burned? If so, chop off the ## option switch in $1 to see if NUM is appended to the switch case $1 in --copy*) ## We'll only shift once here since NUM _must_ be appended test -z "${1/--copy=/}" && ## If empty, say so and bail { error_msg "No number of copies specified in ${B}${1}${b}.\n" print_usage <&2 && exit 1;} NUM=${1/--copy=/} && shift 1 ;; -c*) if [ -z ${1/-c/} ]; then ## If empty, assign $2 to NUM and shift the command args twice NUM="$2" && shift 2 ## If still empty, say so and bail test -z "$NUM" && { error_msg "Not enough arguments on the command line." print_usage >&2 && exit 1;} else ## It must not be empty, so we'll only need to shift once NUM="${1/-c/}" && shift 1 fi ;; *) ## We don't have any request for more than one disc to burn NUM=1 ;; esac

## Sanity checks # Okay let's see if we have a valid number to work with: [[ $NUM =~ [^[0-9]]* ]] && ## If not all numbers, say so and bail { error_msg "${B}${NUM}${b} is not a valid, whole decimal number.\n" exit 1;} # Now, let's see if we have any args left after the shifting: test -z "$1" && { error_msg "Not enough arguments on the command line." print_usage >&2 && exit 1;} # Assign SOURCE before test if $1 exists (will also accept 'file:///' URLs): test "$1" == "." && SOURCE="$(pwd)" || SOURCE="$(sed 's|file:/{1,3}|/|' <<<"$1")" # Finally, if the last arg does not exist, say so and bail: test ! -e "$SOURCE" && { error_msg "${B}${SOURCE}${b} does not exist. Might be a typo.\n" && exit 1;}

## This test is to see what action is needed, based on the return code: test_iso "$SOURCE" case $? in 0) #<--- We're dealing with a valid iso (either an image or block device) ## Sanity check test $(egrep '(AUDIO|VIDEO)_TS' <<<"$(isoinfo -p -i $SOURCE)" | wc -l) -ne 2 && { error_msg "The ISO, ${B}${SOURCE##*/}${b}, does not contain a valid video directory structure. You will need to make another one. Make sure there is both a ${B}VIDEO_TS${b} and an ${B}AUDIO_TS${b} subdirectory present.\n" && exit 1;}

## If the source is a block device (not an iso image) and more ## than one burn is requested, then create a temorary image. ## This will reduce the overall time it takes to produce the ## finished videos: if [ -b $SOURCE -a $NUM -gt 1 ];then tmp_iso $SOURCE && eject $SOURCE 2>/dev/null || { echo -n "If you wish to continue, the copying will be done directly from drive to drive (on-the-fly). However, the time to create the new discs will be much longer for each disc. Do you wish to continue? [Y|n] " | fold ## A 20-second timeout should be plenty of time to answer read -t20 ## If reply equal "n[o]", abort: [[ "$REPLY" =~ "^[nN][oO]?$" ]] && echo "===> Aborting\n" && exit 0;} fi; unset REPLY SRCSIZE="$(find_size $SOURCE)"

## See if we have enough room to burn a 4.7G DVD: if [ $SRCSIZE -ge 4700000000 ]; then warn_msg "The source is too big to fit on a 4.7G DVD. You will need a 'double-layer' disc, and a DVD writer that supports burning double-layered discs. Do you wish to continue? [N|y] " | fold && read -t20 ## Reply must equal "y[es]", or abort: [[ "$REPLY" =~ "^[yY]([eE][sS])?$" ]] || echo "===> Aborting\n" && exit 0 fi

## This test is to see what action is needed, based on the return code: test_iso "$DEV" case $? in 0) #<--- We're dealing with a valid iso (an image or block device) ## Instead of making multiple calls to 'isoinfo', make one call ## and save results. ISOINFO="$(isoinfo -d -i $DEV 2>/dev/null)"

## Now we'll start weeding out the desired info we saved: # For LABEL, we'll ask if the current one found is okay: LABEL="$(sed -n 's/Volume id: (.+)/\1/p' <<<"$ISOINFO" | toUpper)" LABEL="${LABEL//[^[:alnum:]]/_}" read -t20 -p "Enter a name of your choosing for the video, or simply hit <Enter> to use the default [$LABEL]: " test "$REPLY" && LABEL="$(toUpper <<<"${REPLY//[^[:alnum:]]/_}")" unset REPLY

## Let's make sure we have a good image (more sanity checks) test_iso $DEST/$LABEL.dvd if [ $? -ne 0 ];then ## If not good, bail { error_msg "The image, ${B}$LABEL.dvd${b}, is not a valid ISO 9660 image. You will need to start over." && exit 1;} else ## If good, recheck for proper video structure ## This test may seem redundant and unnecessary, but I've ## acually burned a batch of DVDs with an incorect video ## tree in the image :-\ test $(egrep '(AUDIO|VIDEO)_TS' <<<"$(isoinfo -p -i $DEST/$LABEL.dvd)" | wc -l) -ne 2 && { error_msg "The ISO, ${B}$LABEL.dvd${b}, does not contain a valid video directory structure. You will need to make another one. Make sure there is both a ${B}VIDEO_TS${b} and an ${B}AUDIO_TS${b} subdirectory present.\n" && exit 1;} fi

case $PROG in # How were we called? burnvideo) burn_video "[email protected]" ;; ripvideo) rip_video "[email protected]" ;; *) ## Making sure the script hasn't been renamed accidently... ^_^ echo "\n===> ERROR: This program has been renamed. The proper name for this program is 'burnvideo', along with a symlink (in the same directory) pointing to it called 'ripvideo'.\n" | fold >&2 exit 1 ;;esac

eject $DEV 2>/dev/null

exit 0

Enjoy ---thegeekster

Last edited by thegeekster on Fri Sep 29, 2006 10:52 pm, edited 8 times in total.

One is to separate the programs from the case statement in the MAIN section of the script and put them into their own functions.......This is to make it easier to determine where one program ends and the other begins, not only for you but for me too...

Two is adding more comments.......I almost forgot to credit Steve Litt for the 'raw_read' function, which is based on his 'rawread' script at Coasterless CD Burning .........plus more explanations at the top of the script, and some clarification on usage for a few functions.......

The verbose commenting I added just before posting this script to help others follow along with the coding, so I forgot to add here and there.......It only had enough comments for me to remember why I did what I did, and that was all.....

---thegeekster

Last edited by thegeekster on Tue Sep 26, 2006 2:28 pm, edited 1 time in total.

I was wondering if this would work on bought dvd's. Have you checked it on say Sony DVD movies? I have been having the hardest time copying my sony dvd's. I am currently backing up all my dvd's, especially the kids' movies. Right now I don't have anything that will copy sony DVD's

I was wondering if this would work on bought dvd's. Have you checked it on say Sony DVD movies? I have been having the hardest time copying my sony dvd's. I am currently backing up all my dvd's, especially the kids' movies. Right now I don't have anything that will copy sony DVD's

It will work on most retail DVD movies from the store, but not all.

The ones I noticed that won't read are usually disney movies.......I'm pretty sure they use their own encryption scheme, as 'dvdbackup' chokes, and raw ripping chokes, with I/O errors..........The only way around that would be to have a DVD drive that allows raw reading, bit by bit, without checking for whatever checks are made to report I/O errors.....

I did make the script to make backups of movie DVDs I own, to be able to store the originals so they won't get damaged through (ab)use........

For those retail DVDs, they're all double-layer discs, typically holding from 7-8 gigs per disc.......I have a burner that can handle double-layer discs, which allows me to copy them whole without having to strip out anything to make it fit on a normal DVD.........The only difference on those copies are they won't be encrypted anymore since they get unencrypted during the backup process.......

Long answer: Whenever I announce any changes, I will post what has been changed.....AND.....make the changes in the original post....

That way, anyone who comes along and makes a copy will have the latest changes, without having to hunt through the entire thread for the latest update.........But I should probably say so in the original post so someone else doesn't have to ask the same question.....

Oh ya, there will be another change in the making which should make it easier to copy ANY encrypted discs.........Which means it should be an exact copy, bit for bit, including the encryption........

I just haven't been able to do any testing, yet........But that will have to wait as I finish up recovering everything from a failing disk..........It's started to make the infamous "click-of-death" noise, and has choked a few times, causing a little data corruption (of course.......it's the disk with my main OS on it )........I've been having to browse around using a live cd (BackTrack) until I get everything situated........

It only copies the entire disk, so you'll need a double-layer DVD to burn retail movies........Sorry about that, but I like to copy the entire contents of the disc (with all the extras) and I have a burner that can handle double-layer discs.....

You'll need something like DVDShrink for Linux...........

Wait a minute...........After a quick look around, I came across this app: K9Copy.........This seems to be equivalent to DVDShrink in that it compresses (shrinks) the retail double-layer DVD (DVD9) to fit on a standard 4.7G DVD (DVD5).........Hmmm, I'm going to have to check it out when I get up and running..........One caveat is it's a KDE app (lucky for me ).......Also requires DVDAuthor, libdvdread, growisofs, and vamps (for compression)........

Also, check out the Vamps homepage..............seems they have a Qt based app, called qVamps, which (at first glance) seems to provide similar functionality as K9Copy, but has different dependencies (except DVDAuthor is also required).........

Well, folks, it's *famous last words* time..........I just remembered about another "little" thing in the script .......

In the ripvideo function, I forgot about the part where I temorarily mount the DVD to copy any other goodies that may be present in the DVD (usually found in a few retail movie DVDs)..........The temp mountpoint I used is /mnt, which might cause some problems for those of you who have their devices mounted in a subdirectory there.........

This is because of the current FHS standard which recommends using /mnt just for a temporary mountpoint (traditional 'old school' practice), and to use /media for other types of media. like '/media/cdrom', '/media/floppy', etc.........

I been doing it this way for so long, I forget that not all distros are 'FHS compliant' in that regard........So, until everyone is on the same page, I've moved that temp mountpoint to /tmp/ripvid.XXXXXX, which will be created, used, and removed.......

The change includes adding a random generator function for creating the temp name, as follows:

I was wondering if this would work on bought dvd's. Have you checked it on say Sony DVD movies? I have been having the hardest time copying my sony dvd's. I am currently backing up all my dvd's, especially the kids' movies. Right now I don't have anything that will copy sony DVD's

Well, I just found out when doing some research on editing video DVDs, there are newer, stronger copy protections out, called ARccOS and RipGuard DVD, used by Sony, Disney and others which basically are affiliated with these two........

So, there's some good news and bad about these copy protections.........

(1) Good news is.......there are programs out which can handle these newer copy protections....
(2) Bad news is......they are Windows programs, meaning they're GUI apps and not scriptable....
(3) Good news is......they've been recently upgraded to work in Linux using WINE, or have an actual Linux executable......
(4) Bad news is.......some are made to work with other Windows programs.....

The ones I've come across worth mentioning, so far, are:

RipIt4Me - uses DVD Decrypter as a ripping engine and FixVTS to clean the ripped files.........DVD Decrypter rips the VOBs and related files to disk (which can also be accomplished with vobcopy or dvdbackup) and FixVTS makes the necessary adjustments to overcome the copy protection.....Requirements: Windows 9x, Me, 2000, 2003, XP, Linux under Wine........This seems to be a highly rated app in all the DVD video forums.....Caveat lector: DVD Decrypter is no longer being maintained, but the latest version runs fine in Linux using WINE with a little tweaking

FixVTS - A single, standalone Windows executable that does not require any installing, and the current version (v1.602) was modified to run under WINE.......Requires the VOBs to already be copied to the hard disk, although it might be possible to simply mount the DVD and let FixVTS work on the VOBs from there......For this procedure to work, you will need to have FixVTS work in backup mode rather than directly on the source VOBs.........

PgcEdit - "The Swiss Army knife of DVD editing", according to the home page. "PgcEdit is a DVD IFO and Menu editor designed to allow the modification of the navigation commands and parameters of an already authored DVD structure."PgcEdit is also an excellent tool to learn how a DVD works, with his powerful Trace function. "Since v0.6.0, PgcEdit is also the first program able to burn a Double Layer DVD-Video on DL DVD+R or DL DVD-R, with an interactive interface (including a preview), to select the position of the layer break."........This is a Tcl/Tk app, but there's a standalone Linux binary at the site which already has the interpreter built in (probably a Starpack, but not sure)..........Or you can compile it yourself, in Linux, if you have Tcl/Tk already installed.........

There're are probably others out there, all for the Windows platform, most likely, and/or cost lot's of money, but these are ones that get mentioned more frequently in a few of the video help forums on the web.........I've yet to come across any Linux commandline apps that can handle these newer copy protection schemes.......But I'll give these a try and let you know the outcome.............

Only thing I don't like is they're all GUI apps, and I am looking for something that is scriptable (PgcEdit looks the most promising for scripting, just need to brush up on my Tcl)..........But I'm going to keep my eyes open for a Linux command line version..........

In the meantime, I will be updating my script to make it more "generic" rather than specific for my setup..........I just haven't had the time to work on it as I would like, lately.........Also, I will need to rip out the portion dealing with retail DVDs in my script, until I can find something suitable to replace it with..........

pgcedit [A DVD IFO and Menu editor designed to allow the modification of the navigation commands and parameters of an already authored DVD structure].
http://home.tiscali.be/debie.roland/pgcedit/[edited on 28-Aug-2005, after I got the package to run]

I'm familiar with a lot of these apps, but which ones can handle the ARccOS or RipGuard DVD copy protection schemes..........a lot of those apps are frontends for the basic command line apps, and for dealing with copy protection, the only linux app I'm aware of is the libdvdcss library which cannot handle these newer schemes........

This is why I was looking at the Windows apps, those I mentioned *can* handle those copy protection schemes.........I've yet to find any Linux-based command line apps that will.......PgcEdit is not command line, it's a GUI app.......

Who is online

Users browsing this forum: No registered users and 10 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum