Monday, 23 December 2013

Ubuntu Audio CD Burning Fun

Burning an audio CD in Ubuntu takes way more effort than I would have imagined.

Say someone gives you a USB stick with a bunch of .m4a files and a .m3u playlist, and a stack of blank CDs to be turned into lovely thoughtful gift CDs for Christmastime for relatives to play in their cars as they drive to work.  In some operating systems, you'd just open the playlist and then burn it to the blank CD and everything would be fairy dust and unicorns.  In Ubuntu, you do the following steps, amid Googling lots of things.

1. Convert the .m4a files to .wav as described here:

http://smartcoding.wordpress.com/2012/08/18/unix-convert-m4a-to-mp3/

#!/bin/bash
# 
# m4a2wav
# 
for i in *.m4a; do
    mplayer -ao pcm "$i" -ao pcm:file="${i%.m4a}.wav"
done
Ubuntu doesn't really handle .m4a files out of the box, and ultimately you'll need .wav files anyways for a standard audio CD that plays in a normal CD player, so might as well go straight there instead of to .mp3 as an intermediate step.

2. Install K3B KDE Burning tool for burning audio CDs

$ sudo apt-get install k3b 
(or, open Ubuntu Software Center, search for K3B and install)

3. Install normalize-audio for normalizing the audio in your files for uniform playback

$ sudo apt-get install normalize-audio
(or, open Ubuntu Software Center, search for normalize-audio and install)

Otherwise, when you go to burn the CD in K3B and select the "Normalize volume levels" checkbox, it will tell you to go install it.

4. Apply hack to fix this bug, open since 2006, still outstanding:

https://bugs.launchpad.net/ubuntu/+source/k3b/+bug/45026

Workaround helpfully provided by kimus and Vanessa Ezekowitz:

Workaround for Maverick:
In Bug #44524, comment #11, a user posted a script he used to fix this issue in Feisty. With some tweaks, this script works in Maverick also. K3B doesn't like normalize-audio including a version number on the first line. The sheer audacity - how dare it do what it was asked. :-)
The fix is to move the version string to somewhere else in the output:
sudo mv /usr/bin/normalize-audio /usr/bin/normalize
sudo nano /usr/bin/normalize-audio
###
#/bin/bash
case "$1" in
        --version)
                normalize --version | sed -e 's/normalize 0.7.7/normalize-audio/g'
                echo "normalize-audio 0.7.7"
                ;;
        *)
                normalize $*
                ;;
esac
###
sudo chmod 755 /usr/bin/normalize-audio
Restart K3B - it should work fine now.

Otherwise, even after installing normalize-audio, you'll still get the same message in K3B about not having it installed.  Now you can open K3B and prepare to burn your CD.

5. Open K3B.



6. Create a New Audio CD Project.


7. Add your .wav files to your project, manually order them.

Put them in the order originally intended by your playlist file that can't be opened in K3B but can be opened in something like Clementine audio player or your audio player of choice.

8. Manually input artist and title info for all tracks.

The artist and title info will be lost in your .wav files.  Put them back in manually in K3B so if you play your CD in a fancy CD player the track info will display properly. I guess if we'd converted to .mp3 instead of .wav initially then this info would still be encoded, and then K3B would do the conversion from .mp3 to .wav.



Now you have your set of audio files ready to go.

9. Click on burn to open the CD burning dialog.


10. On the CD-text tab, put a name for your CD.

For fancy CD players or whatever.

11. Normalize volume levels

On the Advanced tab, now you should be able to check the "Normalize volume levels" checkbox.  It will warn you that you can't burn on-the-fly if you want to use normalize-audio.  That's ok, click 'Disable on-the-fly burning' and let it check the checkboxes about creating and removing a temp image before it burns on the Writing tab.




12. Insert your blank recordable CD and select it from the Burn Medium dropdown selector.


13. Now, you may burn your audio CD! Burn it!

That, to me, feels like too many steps (even ignoring the self-evident ones like opening the application and adding your files). I miss iTunes terribly sometimes -- still no support for Linux. Maybe there's a better way to do some of these steps, but this is the path that worked for me as I Googled around for solutions to all the bits I needed.



p.s. sorry for neglecting this blog for 3 months.  Maybe I'll post stuff here sometimes.

No comments:

Post a Comment