Hack39.Burn Audio CDs from the Command Line


Hack 39. Burn Audio CDs from the Command Line

Use cdrecord directly from the command line to create your own audio CDs.

There are a lot of advanced GUI programs for Linux that make it easy to burn your own audio CDs from files you have on your computer. Almost all of these programs, however, still function as a frontend for cdrecordthe command-line CD-burning Swiss Army knife. While GUIs are nice, for basic audio CDs, you'll find that it's almost as easy to burn the CD directly from the command line. This hack walks you through the process of preparing and burning your own audio CD from standard audio files you might have on your system.

The first step to burn an audio CD is to prepare the audio files. In the past audio files had to be converted to CDDA format for cdrecord to recognize them, but nowadays cdrecord works equally well with WAV files. Depending on the format of your audio files, you will use different tools to convert them to WAV files. Converting from autio format to another is discussed in [Hack #35].

Once your audio files are ready, the next step is to discover which CD-ROM device cdrecord will use. Run cdrecord with the -scanbus argument and cdrecord will probe and detect any CD burners on your system and which device entry to use. The exact method to use will vary depending on whether you use the 2.4 or 2.6 kernel series. The 2.4 kernel series required that CD burners use SCSI emulation with the ide-scsi module, so your IDE CD burner on /dev/hdc might be accessed through /dev/scd0 instead. Most modern distributions that still use 2.4 will turn on SCSI emulation for you so you shouldn't have to worry about setting it up. In the 2.6 kernel series you no longer have to use SCSI emulation and can write directly to the IDE device, but you have to tell cdrecord about this fact. To scan for IDE CD burners with 2.4 kernels (or if you use SCSI CD burners), run this:

 $ cdrecord -scanbus  

If you use the 2.6 kernel, add the dev=ATA: option:

 $ cdrecord dev=ATA: -scanbus  

In either case, you will see output much like the following:

 scsibus1: 1,0,0 100) 'MATSHITA' 'DVD-RAM UJ-822S ' '1.01' Removable CD-ROM 1,1,0 101) * 1,2,0 102) * 1,3,0 103) * 1,4,0 104) * 1,5,0 105) * 1,6,0 106) * 1,7,0 107) * 

In my case, my DVD writer is listed with the device number 1,0,0. If you had more than one CD-ROM drive installed, you would need to choose which one you wish to use by the extra device descriptions cdrecord outputs. Once your device number is identified, change to the directory containing the WAV or CDDA files you want to burn. If you use a 2.4 kernel, run:

 $ cdrecord -v dev=1,0,0 -audio  track01.wav track02.wav track03.wav  

If you use a 2.6 kernel, modify the dev argument slightly:

 $ cdrecord -v dev=ATA:1,0,0 -audio  track01.wav track02.wav track03.wav  

If you have converted files from some other audio format into WAV, add the -pad option to cdrecord so that it will ensure the WAV is padded to be a multiple of 2,352 bytesa cdrecord requirement.

In both examples, replace the dev argument with the device number for your CD drive. This command tells cdrecord to burn track01.wav, track02.wav, and track03.wav to an audio CD. If your WAV or CDDA files are already in order in the directory, you can also use a shell glob (like *.wav) instead of typing out each file manually. This example uses TAO (Track At Once) recording, which means that each audio track will be spaced by two seconds of silence. If you want more or less of a gap in between tracks you will need to resort to the more complicated DAO (Disk At Once) method if your drive supports it. Because of the many extra steps it involves, if you want to go the DAO route I recommend you use a graphical CD-burning tool as decribed in [Hack #40].

Some cdrecord examples list a speed option, which you can use to set the recording speed. By default cdrecord will attempt to use the fastest speed it can detect for your CD writer, but if you want to purposely slow it down (perhaps because of a slow system) add the speed=2 option, but replace 2 with the speed at which you wish to write.





Linux Multimedia Hacks
Linux Multimedia Hacks
ISBN: 596100760
EAN: N/A
Year: 2005
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net