08 January 2013

307. Burning audio CDs from the command line in debian testing/wheezy

I've got a CD burner on a headless box, so burning audio CDs from the command line is a necessity.

I also normally end up burning flash videos that I've converted to mp3s, so I'll show that too. This post is essentially covered (although not very well) already here: http://verahill.blogspot.com.au/2012/01/debian-testing-64-wheezy-small-fixes.html

First install the necessary programmes
sudo apt-get install ffmpeg wodim mpg123


Converting flv to mp3
To batch-convert flv files to mp3, do
ls *.flv|xargs -I {}  ffmpeg -i {} -ar 44100 -ab 160k -ac 2 {}.mp3


Preparing the files
Rename your files to 01.mp3, 02.mp3 etc. to make the songs burn in that order (since you're using *wav below).

Convert the mp3s to wav files (you could've gone straight from flv to wav above)
for i in *.mp3; do mpg123 --rate 44100 --stereo --buffer 3072 --resync -w "`basename "$i" .mp3`".wav "$i"; done

Burn
Burn with
wodim -v -pad speed=1 dev=/dev/cdrw1 -dao -swab *.wav

assuming that cdrw1 is the correct device.

Eject your cd when done.
eject cdrom1

Done.
[There's also no shortage of terminal music players, such as cplay.]

PS. You can burn anything you want from the command line using burn, e.g. an .iso file
sudo apt-get install burn
sudo burn -I -n myiso.iso

If the device you want to burn on is /dev/cdrom1 instead of /dev/cdrom, you can edit that in /etc/burn.conf

No comments:

Post a Comment