|
Communicating with the CD Burner
The first difficulty in using cdrecord involves
communicating with the CD burner. For an internal CD-RW or Combo drive
on the Mac, you won't need to indicate driver, but for other Cd
burners, you might. Enter the following
command to determine what burners are supported by cdrecord:
cdrecord
driver=help
Then to use the driver with cdrecord, include the following with your command-line arguments:
cdrecord
driver=[name of driver] ...
Whether your burner requires the driver argument or not, it will require a target argument. To get
it to work, you have to add "dev=[name of device]." The
following command, which erases a CD rewritable disc, works on flat panel iMac with a built in CD-RW
drive:
cdrecord
blank=fast dev=IOCompactDiscServices
For the combo drive, use the following command:
cdrecord blank=fast dev=IODVDServices
Superdrives
usually don't work with cdrecord.
For other burners, try the following command:
cdrecord
dev=help
On
my flat-panel iMac, the terminal spits out the following information
with I run the above command:
Cdrecord
1.11a40 (powerpc-apple-macosx6.2)
Copyright (C) 1995-2002 Jorg Schilling
Supported SCSI transports for this platform:
Transport name:
SCSITaskDeviceInterface
Transport descr.: Apple SCSI
Transp. layer ind.:
Target specifier: Mac Prom device
name
Target example:
IOCompactDiscServices/0
SCSI Bus scanning: not supported
Open via UNIX device: not supported
Transport name: RSCSI
Transport descr.: Remote SCSI
Transp. layer ind.: REMOTE:
Target specifier:
rscsi@host:bus,target,lun
Target example:
REMOTE:rscsi@host:1,2,0
SCSI Bus scanning: supported
Open via UNIX device: not supported
The first
line beginning with "Target example" usually provides the information
needed. In the case of my computer, it is
IOCompactDiscServices/0. The "/0 can be ignored.
Burning iso multi-session cds
Although
theoretically you can burn multi-session data CDs in Mac OS X using Disc
Copy, the resulting CDs will appear as multiple discs on
your desktop — not an ideal situation, to be sure. The Open
Source unix program cdrecord is a much better choice — provided
you have an internal burner. (The following is partially based on
a hint
published anonymously at macosxhints.com.)
When you
install cdrecord (via fink),
several other programs come with it, including mkisofs, which
we will need to burn a multi-session ISO data CD. First, create a
folder on your Desktop entitled "DataCD." Place all the files you
wish to burn to the CD in this file. Change the working directory
of your terminal to your Desktop (i.e., enter cd Desktop).
Now enter
the following command:
mkisofs
-J
-R -V DataCD1 -o session1.iso DataCD
This will
create an ISO image file of the DataCD directory entitled,
appropriately enough, "DataCD1." When it's done, you can test the
image by mounting it on your desktop. Mount it using Disk Copy
and then look inside to make sure it has all the files you want to burn
on your CD. Also, check to make sure that the image is entitled
"DataCD1."
Once this is accomplished, you can burn the first session of
your data CD with the following command:
cdrecord
-v driveropts=burnfree -multi -data -speed=4
-immed dev=IOCompactDiscServices session1.iso
This
command, with all its arguments, needs to entered as one line! If you
have a Combo drive, you will need to use "dev=IODVDServices." You may
also want to record at a higher speed, though lower speeds are safer.
The "driveropts=burnfree" option provides buffer underrun protection on
supported burners. The -immed option helps prevent your system from
freezing while fixating or blanking a CD.
Yet
one other issue must be kept in mind: the Mac hfs+ file system and its
concomitant nuissance, resource forks.
Many files on Mac systems's, as is well known, have an addition "fork." Although
cdrecord supports the Mac file system, you still
may run into problems, especially if
you're trying to make a disc that will be readable on Windows or Linux
based-PCs. You can even run into problems saving certain kinds of Mac
files. I've had trouble, for instance, with package files and
carbon-based installers. There are all sorts of complex strategies that
you can use to try to get around this (see the cdrecord man
pages for more info), but these are beyond the scope of this modest
tutorial. There are a few tricks you can use, however, to secure the
integrity of your files. It's a good idea, whenever burning any kind of
installers or carbon-based applications to
disc, to tar and compress them with an application like DropStuff.
Having files in this form usually does the trick. Otherwise, if you
save, for example, the installer to a Carbon Application, it will be
rendered useless, just a heap of pointless files.
When
the time comes to burn a second session on your disc, things get a bit
more complicated. In the first place, cdrecord
cannot access non-blank discs on its own. These discs are controlled by
the Mac GUI. To disengage the CD from the Mac GUI, you have to dismount
it, either using Disk Utility or the terminal. With the terminal, you
need the disktool command and the bsdname of the mounted CD-Rom. To get the bsdname, try the df command and look for the line /dev/disk[?]0 in the output. The disk[?] will
be the bsdname, i.e., /dev/disk2s0 would provide a bsdname of "disk2." Unmount the disk as follows:
disktool
-u disk2 0
Any time you
want to access a non-blank disc using either cdrecord or one of
its sister tools, you will need to use this disktool command to
disengage the disk from Mac OS X and unmount its image from the
desktop.
Now to burn the second session on the disc. When making your ISO image, the mkisofs
program will need to read your data CD in order to know where to add the next session. This is done with the following
command (make sure you unmount the CD first!):
cdrecord
-msinfo dev=IOCompactDiscServices [or dev=IODVDService]
If
you have burned only one session, you will get a zero and another,
fairly large number — e.g.," 0,6789." If you have burned three or
more sessions, you'll get two large numbers separated by a comma.
You take these strings of number and place them in the following
command:
mkisofs
-J
-R -o session2.iso -V [Volume Title]-M
IO[burner]Services -C [number string] [filename]
Again, this is entered all on one line. Let
us suppose we ran the "cdrecord -msinfo" command and the output was
"0,63734." I can make an ISO image of the directory DataCDs2
which I can append to my CD-R with the following command:
mkisofs
-J
-R -o -V SessionTwo session2.iso -M
IOCompactDiscServices -C 0,63734 DataCDs2
Once this
point is reached, it is very simple to burn the appendage. The
following command will work with any of Apple's built-in CD-RWs:
cdrecord
-v driveropts=burnfree -multi -data -speed=4 -immed
dev=IOCompactDiscServices session2.iso
Given the
complexity of the command-line syntax, some may conclude that it is
more bother to use cdrecord and mkisofs to burn
multi-session CDs than is worth the trouble. For this reason, I
have put together a crude gui for cdrecord
that works like a normal OS X program. You can download it here.
Erasing with cdrecord
Why would
anyone want to use cdrecord to erase CD-RWs when it can be done so much
easier with Disk Utility? Well, there are few things you can do
with the cdrecord erase capabilities that you cannot do with Disk
Utility. For example, suppose you want to transfer 50 MB worth of
mp3 files to a friends computer. You have in your possession a
multi-session CD-RW with 100 MB of free space. You append the 50
MB of mp3 files to your disc and take it over to your friend's house.
He copies the files to his computer and gives you back the disc.
Later you decide you don't want that extra 50 MB of mp3 files on
your disc. Is there any way you get rid of them? Yes, using
cdrecord, you can erase the last session. Once you have
disengaged your disc from OS X, you can blank the last session with the
following command:
cdrecord blank=session -immed
dev=IOCompactDiscServices
In fact,
using this method, you can blank all your sessions, starting from the
most recent session until you work your way back to the first session.
This is something you will never accomplish with Disk Utility
or
or even a commercial program like Roxio's Toast. Only cdrecord
can pull off this trick.
If all you
want to do is erase a CD-RW, the following command will work:
cdrecord
blank=fast -immed dev=IOCompactDiscServices
This is only
"minimally" erases the disc (although it should work fine). If
you want a "complete" erase, try this command:
cdrecord
blank=all -immed dev=IOCompactDiscServices
A word of
warning about this blank=all version of the command.
Whenever I've used it, it has caused cdrecord to more or
less take over my entire computer for over 15 minutes, meaning I can't
use it to do something else. So it is best to run it when you
plan to be off doing something else.
Extracting audio with cdda2wav
Although iTunes
is perfectly capable of fulfilling most your audio CD extraction needs,
there are few little tricks that cdrecord's companion utility, cdda2wav,
has up its sleeve that make it worth occasionally using it. Suppose you
want to extract several tracks into a single audio file. Here iTunes
will be of little use to you. But cdda2wav will get the job if you do
as follows.
I have a
disc
that cuts up a single musical piece into 24 tracks. If I want to
create
a disc that contains the entire work on a single track, the only way to
do
is to extract all 24 tracks as a single audio file and burn that to
another
disc. Here's how it's done. First, enter the CD.
Disengage
it with the disktool command. (If this doesn't work, you
may
have to quit iTunes, which sometimes won't let go of the disc.)
Run the following commands:
cd ~
cd Desktop/Audio
These
commands cause the Audio folder to become your working directory.
Now any files you extract will wind up in the Audio folder, which
is where you want them. Now, to extract tracks 1 through 24 into
a single file, run the following command:
cdda2wav
-t 1+24 -Oaiff dev=IOCompactDiscServices
The key to
this command is the option "-t 1+24." This is the part of the
command that can be changed to make it fit your needs. If you
want to only extract tracks 1 and 2 into a single file, run "-t 1+2";
tracks 3 through 7 can be extracted with "-t 3+7," etc. etc.
You can also
extract in terms of seconds from start of CD. Suppose for
whatever reason, you want to extract the first five minutes of a CD
into a single
file. Just run the following string of enigmatic syntax:
cdda2wav
-d 300 -Oaiff dev=IOCompactDiscServices
When
you run these commands, a file entitled "audio.aiff" will appear in
your working directory. It is probably a good idea to change the
name of this file when its finished extracting. Otherwise, if you
run in extraction command in the same directory, your file will be
overwritten. Unix always overwrites files with the same name,
usually without giving so much as a shred of warning.
When
you're finished, go ahead and burn the files with iTunes. If you
want to use cdrecord, you will have to translate the aiff files
into wav files. This can be done either with sox or by
changing the "-Oaiff" option in the cdda2wav command to
"-Owav." Then, to record at 4 speed, run the following command
from the working directory of your wav files:
cdrecord -v driveropts=burnfree -immed -speed=4
dev=IOCompactDiscServices -audio *.wav
Incidentally,
all audio CDs should burn at the slowest speed possible. Faster speeds
can make them unplayable in certain players.
Copying complete CDs and CD-ROMs
There is nothing easier than
to make a copy of a CD-ROM using Disk Copy. First, start Disk
Copy and go to the "File" menu. Select from the "New"
contextual menu "Image from Device." A window will emerge
giving you several options: "disk0" "disk1" etc. Click on the
arrow pointing at "disk1." You'll probably getting something like
"disk1s1 CD_ROM_Mode _1" Select this line and press
enter. This will make you an image of the CD-ROM. You can
burn
the image unto a disc using either Disc Copy or cdrecord.
Then enter the following command:
cdrecord -speed=12
dev=IOCompactDiscServices [imagefile.dmg]
If you want to make an exact
copy of an audio CD, the following commands will do the job.
First, extract the audio into the "audio" directory with this
command:
cdda2wav -B -Owav dev=IOCompactDiscServices
cdrecord -v driveropts=burnfree -immed -audio -dao
dev=IOCompactDiscServices -useinfo *.wav
The key to this command is
the "-dao" option, which stands for disc-at-once, a command useful if
you don't want little gaps to appear between tracks. If you have
an audio CD that features track splices during the middle of a piece of
music (not uncommon with classical CDs), recording in disc-at-once
means
that a gap won't appear when the music is copied and recorded on a CD-R.
Using X-CD-Roast
Recently, a GUI front-end
for cdrecord, called X-CD-Roast, has appeared in the
fink unstable archive. Although a so-called "unstable" and even "alpha"
product, I have tested it and it appears to work fine. As of June,
2003, it
even has
the ability to communicate directly with your burner. Unlike with cdrecord,
you don't have to keep dismounted discs from the desktop in order to
use
it! When X-CD-Roast opens, it confronts you with a little
dialogue
box, giving you the choice to stop the autodkismount-daemon (i.e., the
background process that prevents cdrecord from accessing discs
in your cd-rw
drive):
If you decide to go ahead
and kill the little autodiskmount-daemon, the following dialogue box
will plaster itself on your screen, demanding your password:
Remove any CDs from your
drive, enter your password, and let the program do its thing. Now X-CD-Roast
has complete control of your CD-RW! The cdrecord
engine that works behind X-CD-Roast's appallingly inaesthetic
facade can
now do what it damn pleases with the CD-Rs and CD-RWs you feed into its
maw.
Are there any drawbacks in
snuffing out the poor hapless autodiskmount-daemon? Well yes, there
are. Your other programs, including your desktop, won't be able to
access any discs you
place in your drive. You may even have trouble opening your CD-RW tray
—
although your eject key on your keyboard should work. But if it
doesn't,
simply go to either the "Duplicate CD" or "Create CD" menus. There you
will
see, towards the upper right-hand corner, two buttons, an eject button
and
a load button. These buttons will enable you to controlyour CD-RW's
loading
tray.
After you have entered your
password, X-CD-Roast will want you to set some critical preferences,
so the program will know how
you want it to behave. So go on over to the "Setup" menu, where you
will
see something along the lines as the following screenshot:
Under
the various tabs, you will enter the proper settings for you CD-RW
drive and select where X-CD-Roast
will place the iso image files it creates. You will notice
that it gives you a lot of options, including a "Use paranoia mode for
audio" under the "CD Settings" tab and a "disc-at-once" mode under the
"Options" tab. Of particular importance are the temporary image storage
directory settings under the "HD Settings" tab and the "Tooltip help"
button under the "Options" tab. Unless you set at least one temporary
image storage directory, X-CD-Roast
will not make iso images. The help option is also very
useful in understanding what everything does and recommending how to
use the various functions of the program. It enables pop-up windows
whenever you put the cursor over a
button or tab or other GUI functionality. When you're finished adding
the
settings you want, don't forget to click the "Save configuration"
button
before returning to the main menu.
After setting X-CD-Roast
up, we can begin making our first data CD. At first, it
might
seem a little difficult, especially in comparison with OS X programs,
which are somewhat more unintuitive. (X-CD-Roast may not
be particularly intuitive, but at least it's free!)
In the main X-CD-Roast
window, click on the "Create CD" button and, in the new menu, click on
the "Master Tracks" button. Click on the
"ISO9660 options" tab. You should see something like this:
Select the "Rock Ridge
+ Joliet" image type as show above. CD-R's burned using this
configuration should be readable in computers afflicted with the
Windows OS. Next, in OS X Finder, create a folder containing
the files you wish to burn to a CD-R. Next, click on the "Master
source" tab. You should see something like this:
Simply choose whichever
folders you wish to burn onto disc in the "File/Directory view"
window and click the "add" button. You will be greeted with the
following dialogue box:
Choose the "Add with last path component" selection (otherwise, X-CD-Roast
will duplicate the absolute path to the file on the CD-R
that it burns, which I find extremely annoying). Then click
on the "Create session/image" tab. You will be greeted with a window
looking something like this:
Wait until it finishes
calculating the size of your projected image. Then click the "Master to
image file" button. X-CD-Roast will greet you with a
dialogue box telling you when it has mastered successfully. After this
task is
completed, click on the "Write Tracks" button on the left side of X-CD-Roast
window. Then click on the "Layout tracks" tab in the "Create CD" menu.
Here's what you'll see on the screen:
Click
on "track1-01.img" (or whatever your image is called) and click the
"Add" button and the "Accept track layout" button. X-CD-Roast
will confront you with the following menu:
The settings you want to
check before you click the "Write tracks" button are, first of all,
"CD-R/RW Type," secondly, "Write Mode" (use "Track-At-Once" for all
data CDs), and thirdly, the "Create multi session CD" button. Then
insert a blank CD-R/RW and let the program do its thing.
Using
the cdda2wav paranoia library
Occassionally you want to
extract audio from a CD that has somehow become damaged. You may have
heard that in Linux, there is a progam called cdparanoia which
helps the computers cd-rom make sense of corrupted data on the surface
of a CD. Although cdparanoia has not been ported to Mac OS X,
the extraction progam cdda2wav does have its own paranoia
library which can easily be accessed through the X-CD-Roast
interface. I've used it on a number of occassions
to rip CDs borrowed from the Library and have found it to work
remarkably
well. Even when it can't take all the pops out, it minimizes them to
such
a degree that sometimes I have been able to remove them in an audio
editing
program such as SparkMe. As evidence, consider the
following
visual representations of two identical tracks, one extracted with iTunes,
the other with X-CD-Roast. The iTunes one looks like
this:
As you
can see toward the middle of the file, there are all kinds of nasty
pops and clicks. This is what the same files looks like when extracted
using the
paranoia libs:
This is much better. Not a
single pop or click. Here we have a demonstration of why using Unix
applications really can be worth the hassle.
Open the progam and go to
the setup panel and click on the "CD Settings" tab. Go to the bottom
entry
that reads "Paranoia retries per sector" and move the slider all the
way
to the right. Make sure the "Use paranoia mode for audio" button is
activated,
as shown in the screenshot proved below:
Now insert the CD you wish to rip. Go to the "Create CD" panel
and click on the "Read Tracks" button. Select the tracks you want to
extract, then press the "Read selected tracks" button in the lower
right-hand corner. X-CD-Roast will began extracting the
selected tracks. You
will find your tracks wherever you told X-CD-Roast to put them
when
you set up the program for the first time. You will also find two info
files
for every track you extract. Unless you plan to use X-CD-Roast
or cdrecord to burn your extracted files on a CD, you don't
need
these info files and can destroy them in the terminal by first going to
directory they have infested and then running the following command:
rm *inf
The rm command
completely obliterates files (so be careful with it). The asterisk is a
wildcard that stands for any sequence of zero or more files, so that
all files in the
terminal's working directory ending with the letters inf will be
dispatched
to the land of nothingness.
Using X-CD-Roast to
burn Multi-session CDs
Now,
to burn an additional session in X-CD-Roast. Insert your cd
then go to the "Create CD/Master Track" menu, disengage your CD and
click on the "Update Session view." Add the files you wish to burn on
the CD and click on the "Create session/image." Let the program
calculate the size
of session, then click the "Master to image to file" button. You should
get a dialogue box asking whether you are creating a first session or
an
additional session. Choose, obviously, the "Additional session" button
and go to the "Write Tracks" menu. Add your image to the "Tracks to
write" window, accept the track layout and click on the "Write tracks"
button. You will
probably get the following dialogue box:
Normally,
you shouldn't worry about this warning. X-CD-Roast is very
fussy about multi-session burning. Any little change, however trivial,
will cause it to emit this little yelp of protest. As long as it tells
says you are trying to write a multi-session CD, you should be fine.
Once more disengage your CD and click "Continue anyway." Hopefully, it
will work. But just
in case, you should probably do a few test runs on a CD-RW to make sure
that your system does as well with the program as mine has.
If you play around with X-CD-Roast, you will soon appreciate
how powerful an application it is. You can erase CD-RWs, delete CD-RW
tracks, and pretty much inflict anything upon a poor hapless CD-R/RW
that you
desire to be inflicted.
One other feature that you may find useful. I prefer to give my CDs
names. This is easily done in
the
"Create CD/ISO 9660" window, as shown below:
Just
enter whatever title you like in the "Volume Id" text box before you
master
your image. That will give your CD the title of your choosing.
Automating cdrecord with shell scripts
We will start with a modest
script that can be used to very easily erase CD-RW's. Go to
the terminal and enter:
pico
cderase
Now paste the following into
the terminal, press <control-x>, <y>, and <enter>:
#!/bin/sh
disktool -u disk1 0
cdrecord blank=fast dev=IOCompactDiscServices
Obviously, if you have a
combo drive, the last line will be <dev=IODVDServices. Once
finished with the script, make it an executable file by entering the
following command:
chmod +x cderase
Now
you
can test the script by placing a CD-RW in your drive and entering:
./cderase
If it works, you can install
it in one your "bin" directories, where it can be accessed by your
terminal. This will usually require administrative privileges.
For example, the following command will move the script into your
/sw/bin directory:
sudo
mv cderase /sw/bin
Now it should work simply by
entering <cderase>. Using the same procedure, we can
automate a number of cdrecord procedures and save ourselves the
trouble of writing out the difficult and confusing syntax.
Next we will create a script
that will erase the last recorded track on a cd-rw. Enter:
pico
erase1
Now paste in the following
simple script, press <control-x>, <y>, and <enter>:
#!/bin/sh
disktool -u disk1 0
cdrecord blank=session dev=IOCompactDiscServices
Make the file executable
with
the chmod command. Then save the damn thing and move it to
/sw/bin directory.
To automate some of the other functions of cdrecord, we will
have to come up with somewhat more complicated scripts. But that
will have to wait for another day.
Automating CD disengagement
What if you're nervous about
temporarily snuffing out OS X's precious little autodiskmount-daemon?
Well, then if
you wish to use X-CD-Roast, your going to have to find another
way
to disengage your disc. There are, fortunately, at least a couple
tricks
that you can use to make your life a little easier if you choose to
take
this path. The first one, which you should use if Apple's X11
is
your XWindows environment of choice, involves making an applescript
application.
Open the Applescript script editor and enter the line:
do
shell script "disktool -u disk1 0"
Save
the applescript as an application and leave it on your desktop. Anytime
you want to disengage a CD from OS X, merely click on the icon. Do keep
in mind, however, that there may exist occassions when the script won't
work, because, for some reason or another, your CD mounts, not as
"disk1," but
as "disk2" or "disk3." On those occassions, you will have to return to
the
terminal to wrest control of your CD from Mac OS X's voracious desktop.
There's an even more efficient method if you're using XDarwin
and the Windowmaker window manager. Using the keyboard shortcut
functionality of Windowmaker enables you to perform the
disktool command with a single keystroke. If you haven't yet accessed
this feature in Windowmaker, it's tremendously easy. Just open
up the Window
Maker Preferences Utility (simply click on the little GNUstep icon with
the green background along the leftside of the screen below). Go to the
Applications Menu Definition window and enter something like the
following:
Just drag "Run Program" bar from the left side of the "Applications
Menu" window into the "Utils" menu. Click on it and enter "Disk
Release" (or whatever you please) and press enter. Then enter the
appropriate
command in the "Execute Program" text box and capture it as shown,
preferably with F8. Save your changes and restart Windowmaker
to make your changes functional. Now any time you want to disengage a
disk, all you have to
do is hit the F8 key. It's still a nuisance, but at least it's a
manageable one.
Note on Installation
It has been brought to my
attention that some of the readers of the site are not clear on how to
install the programs discussed herein. I briefly discussed the
installation on the homepage, and will info on it soon. All the Unix
programs discussed on these webpages, unless otherwise noted, can be
installed using the program fink, which can be found here. This includes cdrecord, mkisofs,
and cdda2wav.
—Last updated February 19, 2004
|