Linux Notes: CD Ripping, Recording, and Mastering

Last modified: 05/11/2008

Contents

Audio CDs
Ripping
Warning!
General Hints
Media Write Speeds
Burning a Data CD
Burning a Data DVD
Reading non-iso9660 CDs
Downloading and Burning ISO images from RedHat
Burning an Audio CD
On-The-Fly Copying
Burning a Mixed-mode CD
Burning an Enhanced CD (A.K.A CD-Plus, or CD-ROM XA mode 2)
Recording Live Audio
Converting to MP3
Troubleshooting
cdrecord: (CHECK CONDITION)
Drive light on, but nobody's home

Audio CDs

Ripping

"Ripping" means transfering an audio track from an audio CD to the hard drive. This is challenging because the OS cannot receive the audio data in real time, and repositioning the laser accurately is difficult. The CD format was designed for real time streaming access, not random access.

To rip audio tracks, use cdparanoia

Reading the cdparanoia animated output: spaces and happy faces are good, a dash is acceptable.

To rip an entire ISO filesystem from a CD-ROM:

dd if=/dev/cdrom of=my_cdrom.iso

Warning!

When burning a multi-session audio or data CD, disable auto-mounting. If enabled, the OS will try to both read and write to the CD at the same time, and will cause either a miswrite or will deadlock the kernel. See: Nautilus > Peripherals > CD Properties > (Audio CD > Auto-play) and (Data CD > Auto-mount).

General Hints

Media Write Speeds

Media speeds for my CD writer, Plextor 16/10/40A:

Imation CD-R 24x speed=16
Memorex CD-RW 4x speed=4

Burning a Data CD

Gnome Desktop, xcdroast, and other provide a handy means to create data CDs. Gnome's is the easiest to use though provides the least control -- perfect for a quick job. In the Gnome File Browser, select Go > CD/DVD Creator.
  1. Assemble data into a single directory tree.
  2. Create an ISO image with:
       mkisofs -o cd.iso -R -J -r dir
    Other options:
       -f   Follow symbolic links
  3. Verify/browse ISO image with:
       isoinfo -i cd.iso -f -R -J  | less
    Or mount as a read-only file system with:
       mount cd.iso /mnt/dir -t iso9660 -o ro,loop
    (if you get a complaint about "loop unknown" or "mount: could not find any device /dev/loop#", try running modprobe loop; see Gentoo Kernel, Block Devices).
  4. Write CD with:
       /dev/hdc:  cdrecord -v speed=16 dev=ATAPI:0,0,0 -data cd.iso
       /dev/hdd:  cdrecord -v speed=16 dev=ATAPI:0,1,0 -data cd.iso

Use:

A script fragment to help manage ISO contents (where "cd" is the directory with the contents):
if [ ! -e mixed_mode.iso -o -n "`find cd -newer mixed_mode.iso`" ]; then
echo "Cleaning..."
find cd \( -name '*~' -o -name '*.bak' -o -type d -name '.*' -prune \) \
-print -exec rm -rf '{}' \;
echo
echo "Link check..."
html_link_check -start cd/READ-ME.html
echo
echo "Building ISO image..."
mkisofs -o mixed_mode.iso -R -J -r cd
echo
echo "Contents:"
isoinfo -i mixed_mode.iso -f -R -J
echo
fi

Burning a Data DVD

Similar procedure as for data CD:

  1. Assemble data into a single directory tree.
  2. Create an ISO image and write to DVD media with:
        growisofs -Z /dev/hdc [-speed=8] -R -J dir
    where -Z specifies your DVD burner.

For DVD video, see Video, DVD Production Flow.

Reading non-iso9660 CDs

Sometimes well-meaning friends send non-iso9660 data CDs. Linux can't read them. For example, a friend created a data CD on a Macintosh with the HFS file system rather than iso9660. To read the data anyway:
  1. Copy the raw CD contents to the hard disk:
        dd if=/dev/cdrom of=cd.iso
  2. Mount as a loopback  device:
        mount cd.iso /mnt/dir -t hfs -o ro,loop
(Maybe this is excessive. Experiment with mounting the CD as HFS rather than the default ISO9660 file system.)

Downloading and Burning ISO images from RedHat

Red Hat Logo RedHat distributes OS as ISO images that can be directly written to CD-R.

  1. Download the ISO images. These are available from one of the RedHat mirror sites. Use NcFTP for best results.
  2. Verify the integrity of each image with md5sum iso-image and compare with the MD5 sum posted on the FTP site.
  3. Write each CD with:
        cdrecord -v speed=16 dev=ATAPI:0,0,0 -data iso-image

Burning an Audio CD

Additional cdrecord options:

Also see gcdmaster for tracks.

On-The-Fly Copying

On-the-fly copying means that the two CD drives are operating at the same time: the first one reads the source, and the second one writes onto the blank.
Copy an audio CD with this command. It operates in two phases: first copying the audio to a disk file, and then writing to the CD blank.
cdrdao copy --device 0,0,0 --source-device 0,1,0 \
--source-driver generic-mmc \
--eject --reload -v 1 -n \
--datafile /media/tmp/cdrdao.bin

Burning a Mixed-mode CD

A mixed-mode CD has both data and audio. It is a single session CD. The data is visible as a file system to a computer, and the audio is visible to CD players. The drawback to mixed mode is that the data track is visible to CD players, and some will even try to play it, and of course it does not sound good.

To create a mixed-mode CD, create an ISO image as for Burning a Data CD, and collect the audio tracks. Run cdrecord with the like this:

cdrecord "$@" speed=$SPEED dev=ATAPI:0,0,0 driveropts=burnproof -eject \
-data \
mixed_mode.iso \
-pad -audio \
song1.wav \
song2.wav \
(etc.)

Burning an Enhanced CD (A.K.A CD-Plus, or CD-ROM XA mode 2)

Similar to a mixed-mode CD, an enhanced CD also has both data and audio, and is a multi-session CD. The audio is written in the first session, and the data is written in the second session. Most CD players can only see tracks in the first session, effectively hiding the data track. The drawback to enhanced format is that some CD players cannot read multi-session CDs at all. See this entry in the CD-Writing HOW-TO on creating multi-session CDs.

To create an enhanced CD, arrange the data for an ISO image as for Burning a Data CD, and collect the audio tracks.

1. Write the audio tracks. Be sure to specify the -multi flag:

cdrecord "$@" speed=$SPEED dev=ATAPI:0,0,0 driveropts=burnproof \
-multi -audio -pad \
song1.wav \
song2.wav

2. Determine where the free space on the CD begins with:

NEXT_TRACK=`cdrecord -msinfo`

3. Create an ISO image using the two numbers returned in step 2:

mkisofs -o cd_plus.iso -R -J -C $NEXT_TRACK -r cd

4. Verify the ISO image with:

isoinfo -i cd_plus.iso -f -R -J -N ${NEXT_TRACK/*,}

5. Write the data track:

cdrecord "$@" speed=$SPEED dev=ATAPI:0,0,0 driveropts=burnproof -eject \
-data -pad \
cd_plus.iso

Here is a script to help manage ISO contents (where "cd" is the directory with the contents):

# Default speed
SPEED=10

# Process arguments. Identify speed and "blank" directives.
SESSION_1_ARGS=
SESSION_2_ARGS=
for A in "$@"; do
if [ "blank=" = "${A:0:6}" ]; then
# Erase only before first session.
SESSION_1_ARGS="$SESSION_1_ARGS $A"
elif [ "speed=" = "${A:0:6}" ]; then
SPEED=${A#speed=}
else
SESSION_1_ARGS="$SESSION_1_ARGS $A"
SESSION_2_ARGS="$SESSION_2_ARGS $A"
fi
done

# Audio session.
cdrecord $SESSION_1_ARGS speed=$SPEED dev=ATAPI:0,0,0 driveropts=burnproof \
-multi -audio -pad \
cd/song1.wav \
cd/song2.wav


# Figure out if the ISO image should be remade.
# Note that audio files are stored inside the 'cd' directory.
if [ ! -e cd_plus.iso -o -n "`find cd -newer cd_plus.iso`" ]; then
echo "Cleaning..."
find cd \( -name '*~' -o -name '*.bak' -o -type d -name '.*' -prune \) \
-print -exec rm -rf '{}' \;
echo
echo "Link check..."
html_link_check -start cd/READ-ME.html
echo
echo "Building ISO image..."
NEXT_TRACK=`cdrecord -msinfo`
echo $NEXT_TRACK > cd_plus_msinfo
mkisofs -o cd_plus.iso -R -J -C $NEXT_TRACK -r cd
echo
echo "Contents:"
isoinfo -i cd_plus.iso -f -R -J -N ${NEXT_TRACK/*,}
echo
fi


# Data session.
cdrecord $SESSION_2_ARGS speed=$SPEED dev=ATAPI:0,0,0 driveropts=burnproof -eject \
-data -pad \
cd_plus.iso

Recording Live Audio

Converting to MP3

Use lame to convert to mp3 format with:

lame -h --vbr-new -p --strictly-enforce-ISO  \
--tt 'track title' --tn <track-number> \
--ta 'author' \
--tl 'album title' \
--ty <year-of-issue> --tc <comment> \
file.wav file.mp3

Where:

Also see grip.

Troubleshooting

cdrecord: (CHECK CONDITION)

A complete failure of cdrecord of the form:

cdrecord: Input/output error. read track info: scsi sendcmd: no error
CDB:  52 01 00 00 00 FF 00 00 1C 00
status: 0x2 (CHECK CONDITION)
Sense Bytes: 70 00 05 00 00 00 00 0A 00 00 00 00 24 00 00 00
Sense Key: 0x5 Illegal Request, Segment 0
Sense Code: 0x24 Qual 0x00 (invalid field in cdb) Fru 0x0
Sense flags: Blk 0 (not valid)
cmd finished after 0.000s timeout 240s
Writing  time:    0.009s

may indicate damaged media. Try a new CD blank. I had a repeated failure which was caused by attempting to record with GnomeToaster which for some reason had bad settings (really bad, apparently). The trouble maker was the "tsize" option was not compatible with cdrecord 2.0: remove it! Further bugs prevented the operation from completing. (Dummy recording mode is a great way to start.)

Drive light on, but nobody's home

Here's a checklist:

  1. Look in /var/log/messages -- was the drive recognized during boot?
    If not, check your jumpers or BIOS.

  2. As root, run cdrecord dev=/dev/hdc -inq (replace /dev/hdc with your device). Expect to see the same identification the kernel received.
    No such file or directory -- Are you sure you have the correct device (see /var/log/messages again)? Maybe udev did not create the device for you.

  3. As root, run cdrecord dev=/dev/hdc -prcap
    Expect to see a long list of device capabilities.

  4. Insert a data CD into the drive (blank or used, doesn't matter). As root, run cdrecord dev=/dev/hdc -atip
    Expect to see data about the medium.
    medium not present -- that's not good. Maybe your drive is broken, or may it's confused. Try shutting down system and powering off. Shut off power supply or remove power cable for 5 seconds -- "reboot" will not do.

  5. With data CD in drive, as root run mount -r iso9660 /dev/hdc /mnt/cdrom (replace /mnt/cdrom as appropriate).
    Expect file system to mount. Try ls -l /mnt/cdrom
    mount: no medium -- that's not good. If you already powered off, I'm not sure what else you can do.

  6. As non-root user, try the commands shown above.
    Permission denied -- check device permissions. You may not be in the correct access group. Check with the groups command. Add yourself and login again.
    udev may have assigned incorrect permissions.

  7. cdrecord-ProDVD terminates with the mysterious message:
    Last chance to quit, starting real write    8 seconds.Alarm clock
    Either your license key is out of date, or the built-in one year expiration has been exceeded.  emerge app-cdr/cdrecord-prodvd-2.01.01_p03 or greater (see this Gentoo discussion topic) or use growisofs from the dvd+rw-tools package.

Copyright © 2004-2007 Craig Lawson
Index no-thank-you-spam-i-am@i-hate-spam.spam.spam Document made with Nvu