|
Linux MP3 CD Burning mini-HOWTOGreg Wierzchowski2001-05-29
1. IntroductionThis mini-HOWTO was created because of my experience with burning music CDs and lack of some specific information about sound normalization on the Internet. I usually burn music CDs as a mix - different songs from different sources.Very often volume level between songs varies greatly. This is the first obstacle. Second, many of the files on the Internet are not CD-compatible (16 bit, stereo, 44.1 kHz) and have to be converted. There are many programs to burn music CDs from MP3 files, and many of them do the conversion transparently. But I haven't seen a single tool that also normalizes the volume, so that's why I worked out my own CD-burning recipe. If you you just want to make a CD filled with music, and not be bothered with all of the details, I have good news for you: Kees Cook (<kees@outflux.net>) put together a tool based on this HOWTO, which automates all of the tasks outlined here. His program can be obtained from http://outflux.net/unix/software/mp3cd/. Thanks, Kees! This HOWTO is just about one thing - putting MP3 music on a CD, so that you can listen to it. For in-depth information about MP3 files, please look at The Linux MP3 HOWTO by Phil Kerr, located at http://www.tldp.org/HOWTO/MP3-HOWTO.html. For information about CD creation in general as well as CD burners, refer to CD-Writing-HOWTO by Winfried Trümper, available at http://www.tldp.org/HOWTO/CD-Writing-HOWTO.html. I'm assuming you wish to burn a CD with the collection of songs you obtained from different sources, all varying quality, but you want to get the best-sounding CD possible. This mini-HOWTO outlines the steps that may help you. 1.1. Copyright and LicenseThis document is copyright 2001 by Greg Wierzchowski and is released under the terms of the GNU Free Documentation License, which is hereby incorporated by reference. Send feedback to greg@draxen.org. 2. Audio CDs2.1. Preparing the Tracks
2.1.1. Filename Cleanup
2.1.2. ConversionThe CD Audio specification requires wave files that are 16 bit, stereo, 44.1 kHz. MP3 files often have different parameters, but we need to convert them to WAV first, anyway. We have several choices for the conversion process. 2.1.2.1. mpg123 and mpg321Originally, there was only mpg123. However, it's license is not free, and now there's an open source replacement - mpg321. Both commands use the same syntax:
When decoding 22khz MP3 files the output of mpg123 may be distorted. I don't know how well mpg321 deals with this problem. If you're converting with mpg123, use:
Mpg123 can be obtained from http://www.mpg123.de/. Mpg321 is available from http://mpg321.sourceforge.net/. NOTE I noticed that with some MP3 files mpg123 output was distorted. At first I thought that MP3's were bad, but then I checked with another player and they sounded OK. So mpg123 is not my converter of choice. 2.1.2.2. MADAnother MP3 player/decoder, and the one I prefer, is madplay. It's available from http://www.mars.org/home/rob/proj/mpeg/. With madplayer, the command line is:
Unfortunately, madplay also had problems with some of MP3 files I had. I don't think there's a problem with the decoder, but rather with it handling broken MP3 files. 2.1.2.3. LameThe lame encoder, which has a decoding mode, seems to handle difficult cases very well (lame can be found at http://www.mp3dev.org/mp3/) :
2.1.3. COnversion NotesNOTE: The `basename $i .mp3`.wav command replaces MP3 extensions with WAV. There are 101 ways to do that, here's the alternative: `echo "$1" | sed 's/\.mp3$/.wav/'` After the conversion, run "file *.wav" and check the output for any files that differ from 16 bit, stereo 44100 Hz. If there are files with different characteristics, convert them to the above specs. For example, to convert file track01.wav to obtain sample rate 44.1 kHz, you could use:
or, if the above introduces static when converting mono files:
Sox is so popular, that it's probably installed by default with any Linux distribution, and can be obtained from http://www.spies.com/Sox/. However, the command-line options are somewhat cryptic for the casual user (me). Look at http://www.spies.com/Sox/sox.tips.html for some tips on usage. 2.2. NormalisationNormalisation is a process during which all the sound files are brought to the same relative loudness level. I use a program by Chris Vaill (<cvaill@cs.columbia.edu>), called normalize - it can be obtained from http://www.cs.columbia.edu/~cvaill/normalize/ I use the following syntax (-m is for mix mode, where all files should be as loud as possible):
3. Burning Your CDThere are many programs to create CDs from WAV files. I use cdrecord for command-line burning and XCDROAST for gui. For cdrecord, you have to know what SCSI device your CD-writer is. If you're using ATAPI writer, use SCSI emulation (kernel module ide-scsi). Let's assume, that your ATAPI cdwriter is on the second IDE bus as a master. Thus, it will have /dev/hdc device file. To instruct the kernel that you want to treat it as a SCSI device, add the following line to /etc/lilo.conf:
Also, if your kernel doesn't automatically load ide-scsi module, add insmod ide-scsi into your rc.local (or equivalent) file. Once you have our CD-writer recognized as a SCSI device, run cdrecord --scanbus to find out what's the "dev" parameter to cdrecord. On my system, the output looks like the following:
So, the cdrecord command line will contain dev=1,1,0 to specify the device. Here is the complete command on my system:
4. Burning a DAO CDDAO, Disc-At-Once, is as of now the only method for burning a CD without a 2-second pause between the tracks. It's useful for burning party mixes. The program for burning CDs in DAO mode is cdrdao, available from SourceForge, http://sourceforge.net/projects/cdrdao/. The cdrdao program uses description files called TOC (Table Of Contents, of course). There are two ways to create such file. First is to use a shell script, distributed with cdrdao source (in contrib directory, called generate_toc.sh. It takes a list of .wav files as an argument and produces a cd.toc file. Second way is to simply create such file yourself in a text editor of your choice. Here is a self-explanatory example:
The 0 (zero) after the wave filename means start from the beginning of the file. There can be a second number providing the length (time) of file to record. The xcdroast creates similar TOC files, there are also examples in testtocs directory of cdrdao source. The cdrdao by default uses the device /dev/cdrecorder, which should be a link to the cdwriter device. Assuming your cd recorder device file is /dev/scd0, create the link (as root) as follows:
Then, assuming that the TOC file is named cd.toc the command to burn the cd is simply:
5. SoftwareThere are some programs available, that can automate the process of creating CDs from MP3 files. Here is arbitrarily selected list:
6. Data CDs
With increasing popularity of CD/MP3 players burning data CDs for listening purposes become practical. The advantage is definitely being able to squeeze ten times more music onto one CD (a very approximate figure). First I would recommend the filename cleanup steps outlined at the beginning of this document. Conversion to WAV is, obviously, not needed here. To normalize MP3 files without losing quality by conversions, use mp3gain. This program is available from http://www.maazl.de/project/mp3/mp3gain.html. You'd need to issue the command:
As far as burning is concerned, MP3 data CD-s are just a standard data CD's (ISO9660) with MP3 files on it. All MP3-CD players I know accept CD-s with directories in them, and I usually burn CD with Joliet extension and they work just fine. So to burn such a CD under linux, you first need to create an ISO image an then burn it on the CD as in the example below:
That's it! 7. CreditsSpecial thanks to all the people who contribute to the Linux community and who made this HOWTO possible. 7.1. Translations
7.2. Other CreditsI have had a great response to the previous releases of this HOWTO. So many people contributed, that I decided to change this section slightly in order to list all of the names. So, I'd like to thank: Greg Ferguson, Rob Russell, Terry Davis, Chris Vaill, Jamie Kellogg, Tom Panning, Adam Buckley, Ilia Lobsanov, Giuseppe "Cowo" Corbelli, Florent Fievez, Piero Ottuzzi, Kees Cook, Andrew Newman, David DeVault. And, most of all, I'd like to thank my lovely wife, Marta, for her love, support and understanding |