------------------------------------------------------------------------------- CDrom and DVD handling under linux Low level Software mkisofs -- create a ISO9660 image from a directory isoinfo -- directory listing an iso image isosize -- the actual length of the ISO file system isodump -- interactive exporation of image - ?? commands ?? devdump -- readcd -- CD/DVD reader with error handling cdrecord -- low level cd burning, for burning individual tracks cdrdao -- low level cd burner, write whole disk once Higher level software xcdroast -- read, create iso's, and burn cdroms k3b -- KDE cdrom/dvd burner (RPM requires a number of extra libraries) vcdimager -- create VCD CUE,BIN files from MPEG videos. k9copy -- compress dual layer video to single layer ISO (set output size to 4400Mb) To check out fuseiso -- userlevel ISO mounts xbiso -- extract xdvdfs??? AcetoneISO -- CD/DVD Image Manipulator isomd5sum / isovfy -- iso image comparitors ------------------------------------------------------------------------------- Creating ISO images to record onto cdroms... Reading CDROM Without error checking you can use... cat /dev/cdrom > cdrom.iso or dd if=/dev/cdrom of=cdrom.iso However many cdroms will overrun, becomming longer than nessary. To copy the ISO correctly include the ISO size in the dd command dd if=/dev/cdrom of=cdrom.iso bs=2048 count=`isosize -d 2048 /dev/cdrom` The "sdd" by Jrg Schillings will also give you a process bar. But I have not managed to locate this software anywhere on the net -- HELP! "xcdroast" will let you read ISO's from CD's (using "readcd" underneath) The "readcd" command is suposed to let you read the ISO from the CD with re-reads of disk errors. It is probably the prefered method List the contents of an image (without mounting it) isoinfo -f -i games2.iso names ending in ";1" are files, directories have not extra ending Create an ISO image from a directory mkisofs -o cdrom.iso -R -J -V "Volume_Title" directory Options: -R is for Rock Ridge Extensions (Unix long filename) -J is Joliet (Miscrosoft long filenames) -hfs another long file name extension (for macs) Alturnative to copying all files under the directory is to know make symlinks to the real file, and use "-f" option. This replaces all symlinks found in ths directory with a copy of the pointed to file in the created ISO. Of course this also means the resulting ISO will not contain any symlinks! Mount a ISO image as a file system (root) mount -t iso9660 -o ro,loop cdrom.iso /mnt ------------------------------------------------------------------------------- Burning non-ISO formats (typically for DVD video) TOC,BIN files cdrdao write --device /dev/dvd image.toc with options --speed --eject eject when finished --overburn add that little bit extra (dangerious) EG: cdrdao write --device /dev/dvd --speed 10 --eject --overburn image.toc Or use K3B burner CUE,BIN files Replace the toc file with the cue file Or use K3B burner CCD,NRG images Note directly posible however two utilities are available nrg2iso and ccd2iso http://gregory.kokanosky.free.fr/v4/linux/nrg2iso.en.html http://ccd2iso.sourceforge.net/ nrg2iso image.nrg image.iso ccd2iso image.img image.iso There is no guarantee that the resulting images will be fully usable since the ISO-image format does not support all the features used by NRG and CCD images. ------------------------------------------------------------------------------- Clone a CD or VCD cdrdao copy --keepimage --device /dev/cdrom --eject To verify the data written (and kept) repeat with copy and abort when the read part of the copy is complete... cdrdao copy --device /dev/cdrom [ctrl-C] Now compare the two data reads to check if they match... Also remove saved data if they do cmp cd*.bin && rm -f cd*.{toc,bin} ------------------------------------------------------------------------------- Burning CDROM/DVD from ISOs (command line) NB: cdrecord MUST run as root due to special fcntl controls needed, you can however make cdrecord suid to root. To find the device numbers to use (typically dev=0,0,0) run and root... cdrecord -scanbus Test burn cd-rw drive (root) cdrecord -eject -multi -dummy -v dev=0,0,0 speed=8 padsize=600m /dev/null OR cdrecord -eject -multi -dummy -v dev=0,0,0 speed=8 cdrom.iso Burn an ISO image to cd-rw drive (root) (add -multi to not close CD sesson) cdrecord -eject -v dev=0,0,0 speed=8 cdrom.iso Or on a 400Mhz or better burn a directory straight from the file system mkisofs -R -J -V "Volume_Title" directory |\ cdrecord -eject -multi -v dev=0,0,0 speed=8 -data - (See cd burning howto if a size is required). Multiple Image CDs All images must have "-multi" used on all cdrecord sessions. The first mkisofs session is generated as normal. Later must have the track number ( -C # ) included when generated. set next = `cdrecord -msinfo dev=0,0,0` echo "Next Track is $next" mkisofs -R -J -o cdrom_new.iso -C $next -M /dev/cdrom \ -V "Volume_Title" filesystem/ cdrecord -eject -multi -v dev=0,0,0 speed=8 cdrom_new.iso Bootable CDs For more info read "README.eltorito" in mkisofs distribution. * The first few blocks of the CD image must be replaced with a bootable floppy image. Create a image from a floppy with... dd if=/dev/fd0 of=boot.img bs=10k count=144 * This file is then copied into the cdrom file system, often under the sub-directory as "boot/boot.img". * A second file "boot/catalog" will be automatically created and should ne named something to avoid conflict with the other filenames. It also probably should be (as shown) in the "boot" sub-directory. BOTH file names (the image and created catalog) has to be within the ISO image. * Make ISO image naming the directory for image (containing the "boot" sub-directory). mkisofs -b boot/boot.img -c boot/boot.catalog -R ...as normal... GrowISOfs offers an easy way to store a set of directories and/or files on a DVD or CDrom. It uses mkisofs to create an image, and writes it to the DVD recorder without needing to store a copy of the image on the harddrive before recording it. growisofs -dvd-compat -Z /dev/dvd -J -R /path/to/disc/root creates an image of files located at /path/to/disc/root using ISO9660 filesystem with Joliet (-J) and Rock Ridge (-R) extensions, and record it to a DVD-R(W) media. For a better discussion, and specifically "boot to linux" cdroms, see http://www.au.linuxfromscratch.org/hints/downloads/files/bootcd.txt also http://www.au.linuxfromscratch.org/hints/downloads/files/boot-cd_easy.txt ------------------------------------------------------------------------------- ISO9660 notes.. CD data is stored on the cdrom generally in ISO9660 format The first 32Kb of this format is usally empty (all zeros) The next block contains the cdroms name and title. EG: dd if=/dev/cdrom skip=64 count=1 | strings OR dd if=/dev/cdrom skip=64 count=1 | od -c OR dd if=/dev/cdrom skip=64 count=1 | hex -g =======8<-------- #!/bin/sh # # Read the cdrom information from cdrom # RD=/dev/cdrom # or a iso image file for i in 32768,7 32776,32 32808,32 32958,128 33086,128 33214,128 \ 33342,128 33470,32 33581,16 33598,16 33615,16 33632,16 do old_IFS="$IFS" IFS="," set -- $i IFS="$old_IFS" OFFSET=$1 LENGTH=$2 echo "#`dd if=$RD bs=1 skip=$OFFSET count=$LENGTH 2> /dev/null`#" done =======8<-------- ------------------------------------------------------------------------------- Under Windows... BlindRead makes perfect ISO images from CDROMs, and can write them out in a variety of formats. DaemonTools mounts these ISO images transparently in Windows without the need to burn them to CD. The BlindRead/BlindWrite suite (Not free, but free trial period) http://www.blindwrite.com/ DaemonTools (Free) http://www.daemontools.org/ VaporCD ( http://vaporcd.sourceforge.net) has been suggested a few times too, as a open source solution. ------------------------------------------------------------------------------- Commercial CDROM burning software modify ISO images!!! I was surprised to find that commercial CD writing software does not generally create unadulterated ISO images of CD's. Nero, for example, uses some proprietary format (probably an ISO with a metadata header). ------------------------------------------------------------------------------- Create a linux only ext2 cdrom! Create a ext2 file system in a file and mount it dd if=/dev/zero of=cd.ext2 bs=1024k count=650 /sbin/mke2fs -b 2048 cd.ext2 mount -t ext2 -o loop=/dev/loop1 cd.ext2 /mnt Note mke2fs may complain that the device is not a block special. Just tell it to proceed anyway. Copy the files into the file system and when finished unmount it. Now just burn "cd.ext2" directly to the cdrom using cdrecord as if it was an ISO image. NOTE: if you mount this filesystem via the "fstab" file ensure the last two numbers are 0 (zeros) so the fsck does NOT check the filesystem (it will fail). ------------------------------------------------------------------------------- Audio CD Ripping Or even higher (Redhat 8.0 and up) grip NOTE: this program by default saves names into the "ogg" sub-directory Configure grip... Rip rip_file: ./%A %t - %n.wav Encode execute: lame cmd_line: -h -b %b --ta %A --tl %d --tt %n -- %w %m enc_file: ./%A %t - %n.mp3 Encode_opt file: ./%A.m3u ID3 remove "Created by grip" Misc remove my email address turn on Do not lowercase names turn on Do not change spaces to underscores Lower Level Rip... You can use "cdda2wav" to get the "wav" files from the cd, instead. This can extract a specific track or interval from the audio cd. You can convert wav files to mp3 using "lame" Example... # extract wav files cdda2wav -D /dev/cdrom -B rm audio_*.inf # Convert to mp3, add info to songs ls audio_*.wav > list vi list :%s/^.*.\([0-9[0-9]\).wav/lame -h --tn "\1" &/ :%s/" /" --tt "title" --ta "artist" --tl "album" / :%s/album/...../ :%s/artist/...../ # edit the song titles :wq sh list rm audio_*.wav # Rename mp3 files vi list :%s/$/.mp3/ :%s/^.*--tt "\([^"]*\)" --ta "\([^"]*\)".* \(.*\)/mv \3 "\2 - \1".mp3 :%s/ */ /g :%s/'//g :wq sh list rm list The "cdparanoia" does a simular job as "cdda2wav" ------------------------------------------------------------------------------- DVD ripping See the use of mplayer options in my version of the script bin/scripts/dvd2avi Install FreshRPMs rpm perl-Video-DVDRip Note original ImageMagick is needed for install Run dvdrip For the lowlevel commands, look at the ogmtools README file ------------------------------------------------------------------------------- Decode DVD frames to PNG mplayer file.vob -ss 284 -frames 1000 \ # source and numer frames -vop pp=0x20000 \ # deinterlace images -vo png -nosound # output to png files ------------------------------------------------------------------------------- DVD video from files You might have a Video DVD stored as a series of normal files in your filesystem, perhaps from some DVD authoring software, and want to write this to a disc for usage in your DVD-player. To do this, we yet again turn to growisofs for help, which as usual provides an easy solution to our problem. In the example below, the disc-root refers to a directory containing any, or both of the AUDIO_TS/ and VIDEO_TS/ directories. The main difference from writing an ISO image is the -dvd-video option, that instructs growisofs that it should prepare the disc to be used as a DVD Video disc. growisofs -Z /dev/dvd -dvd-video /path/to/disc/root Below is a sample listing of what the filestructure of a Video DVD might look like: AUDIO_TS/ VIDEO_TS/ VIDEO_TS/VIDEO_TS.BUP VIDEO_TS/VIDEO_TS.IFO VIDEO_TS/VIDEO_TS.VOB VIDEO_TS/VTS_01_0.BUP VIDEO_TS/VTS_01_0.IFO VIDEO_TS/VTS_01_0.VOB VIDEO_TS/VTS_01_1.VOB ... ------------------------------------------------------------------------------- Video to AVI Handbreak is suposedally th best tool on all 3 platforms (windows, linux, MacOSX) http://handbreak.fr/ ------------------------------------------------------------------------------- Video files to (S)VCD GNU VCDImager software to convert MPEG to (Super) VideoCD recorded with CDRDAO vcdimager -t type --update-scan-offsets video.mpg The MPEG streams needs to be in somewhat appropriate formats to be used as (S)VCDs -------------------------------------------------------------------------------