How to create Audio CDs from MP3 under Linux
From ArticleWorld
There are many ways to create Audio CDs. Virtually every operating system that supports CD-ROMs allows you to do this. What we will show here though is only one method, which we prefer because:
- It is very easy to use inside a shell script
- It is very portable (you will be able to use it under almost any Unix environment)
- It bypasses some patent problems, since it uses only free tools.
Steps
You will need the LAME MP3 encoder for this and a CD burning application. We have chosen cdrdao for this example, but anything should do in general, as long as it can create Audio CDs. You may want to try K3B if you find it too hard to use the console.
1. Install LAME and the CD burning application you have chosen. You should resort to your distribution's packages for this.
2. Now we will convert the MP3s to raw WAV data. To do so, open a console (Konsole under KDE, Terminal or gnome-terminal under Gnome, or xterm, whatever you wish). Create a new folder:
mkdir tracks
3. For each MP3 file you wish to convert, execute:
lame --decode [file] "wav/[name].wav
replacing file with the filename (including the .mp3 extension) and [name] with the name you wish to give. Alternatively, copy all the MP3 files you wish to convert to a folder, enter that folder and run:
for files in *.[mM][pP]3 ; do
lame --decode "$files" "wav/$file.wav"
done
4. We will now create a so-called ToC (table of contents) file. This is used by cdrdao and most CD burning applications should be able to cope as well. We can completely automate this, but if you wish to execute everything manually, the commands are below. Note that these are to be executed in the tracks directory we created above.
{
echo "CD_DA"
for filename in *.wav ; do
echo "TRACK AUDIO"
# echo "PREGAP 00:03:00"
echo "FILE \"$filename\" 0"
done
} > toc
You should change PREGAP from 00:03:00 to whatever value you wish. In our example, the gap between the songs is of 3 seconds.
5. Burn the toc file. With cdrdao, you would use:
<pre>cdrdao write toc
Notes
This assumes that cdrdao is already configured on your system. If you have not done so yet, refer to the cdrdao documentation for details.