Burn Audio CD in Linux
Here's one way to burn an audio CD in Linux.
Get the music
First, gets some tunes. Mount the NAS. Create the playlist in CMUS, export it, and we'll start from there.
Copy Playlist Files to Single Location
Let's get all the music you want on the CD into one location. Let's start with a plaintext playlist file, where each line is a file path to an audio track.
I'm going to copy each one of those tracks to a ~/Downloads/myexport
location:
cd Downloads
mkdir ~/Downloads/myexport
And nvim copy.sh
:
#!/bin/sh
File="/home/jaketrent/Downloads/myplaylist.txt"
DestDir="/home/jaketrent/Downloads/myexport"
while IFS= read line
do
cp "$line" "$DestDir"
done <"$File"
And run: sh copy.sh
. Now all your tracks should be in ~/Downloads/myexport
Format Files
Get some tools:
sudo apt install ffmpeg sox normalize-audio
To prep the audio files to be burnable to a CD, they need formatted in (too) many ways:
Remove spaces in the name (replace with _
):
for f in *; do mv "$f" `echo $f | tr ' ' '_'`; done
Make them all wav files (from .flac, .mp3, or whatever):
for i in $( ls ); do ffmpeg -i $i $i.wav; done
Optionally, if you want all the songs to be at the same volume level, track to track, (which is nice for a mixtape), normalize the audio:
normalize-audio -m *.wav
If you have problems burning, wodim
will tell you, and you can come back to this step as a remedial action:
If you see the wodim error inappropriate audio coding
, make sure all the .wav
files are at 44100Hz sampling rate and stereo channelled. I
sox file.wav -c 2 -r 44100 file_v2.wav
I ran into a sox error of premature eof on wav input file
. I didn't resolve this at the time. If you have a tip, please let me know. I had to remove this .wav
s from the playlist.
Burn the Disc
The great tool you'll want for this is wodim
:
sudo apt install wodim
To see the device name is for your CD-ROM (don't you love that word!), run:
wodim --devices
That'll output something like:
wodim: Overview of accessible drives (1 found) :
--------------------------------------------------
0 dev='/dev/sg0' rwrw-- : 'ASUS' 'SDRW-08D1S-U'
--------------------------------------------------
Now for the burninating command:
wodim -v -eject dev=/dev/sg0' -audio -pad *.wav
-v
- shows progress-eject
- opens CD drawer when complete-audio
- burn as an audio CD (not data)
Play the Disk
My general media player is mpv
, and it's awesome. Fire up the CD Player:
mpv cdda://
If you're on a laptop, put it on your shoulder, and take it to the streets.