Burning Gapless CDs from mp3 in Linux
11 June 2009 at 4:36 pm | In Linux | Leave a CommentTags: burn, CD, cdrdao, gapless, lame, Linux, mp3
Adapted from the archlinux wiki page.
This is a guide for burning gapless audio CDs from mp3s using Linux.
First, make sure you have lame and cdrdao installed. Both packages should be included in your distro’s repositories. In Ubuntu, you can install them with:
sudo apt-get install lame cdrdao
Now, copy and paste the following script into a text editor, and give it a meaningful name, such as “burngapless”:
#!/bin/bash
if [ -d wav ]
then
echo "wav folder already exists; using existing wavs."
else
echo "Decoding mp3s..."
mkdir wav
for file in *.mp3 ; do
lame --decode -S "$file" "wav/$file.wav"
done
echo "Done."
fi
echo "Creating table of contents..."
cd wav
{
echo "CD_DA"
for file in *.wav ; do
echo "TRACK AUDIO"
echo "FILE \"$file\" 0"
done
} > toc
echo "Done."
echo "Burning CD..."
cdrdao write --eject -n -v 0 toc
if [ $? ]
then
echo "Error burning CD. Try running the script again."
exit 1
else
echo "Done."
cd ..
echo "Deleting temporary files..."
rm -r wav
echo "Done."
fi
exit 0
Make the script executable, and move to a location in the path:
chmod a+x burngapless
sudo mv burngapless /usr/bin
Usage
cd to the directory where your mp3s are located and run the script:
cd ~/Music/mp3/As\ I\ Lay\ Dying/Shadows\ Are\ Security/
burngapless
Tweaks & Shortcomings
- For more detailed progress information, remove the “-S” flag from the lame command, and remove the “-v 0″ flag from the cdrdao command. If you don’t want to eject the CD after burning, remove the “–eject” flag from the cdrdao command.
- If there is no writeable CD in the drive when the script reaches the cdrdao command, it will output “WARNING: Unit not ready, still trying…” for a while before giving up. If you insert a CD right away, it should go through with the burn process. Otherwise, just run the script again (after inserting a CD) and it will resume at the burning phase.
- If you have multiple CD drives, you may need to specify the correct drive to cdrdao using the “–device” flag. For more info, see the cdrdao man page.
- Note: if the burn is unsuccessful, the wav files will be left intact in case you want to try burning the CD again. If you don’t want to try burning again, you must manually remove the wav folder.
No Comments Yet »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.