SubscribeMainXMLTagsEditHistoryDiscussion

  1. Introduction
  2. Install required software
    1. To make a Debian package for lame
      1. Install the fakeroot package
      2. Download and patch Lame
      3. Create the package
  3. Create the ripping script
  4. Run the almighty script
  5. Set the tags

Introduction

This guide explains an effective way to encode audio CDs as MP3 files from a command line in Debian (or, with some modifications, any GNU/Linux distribution).

We use the following tools: cdparanoia (extracts the audio from the CD and stores it as wave files), normalize-audio (modifies wave files to adjust their volume) and lame (encodes audio in MP3 format).

Install required software

apt-get install cdparanoia normalize-audio

Lame is not part of Debian due to patent issues. You'll need to download it and install it manually. It is a good idea to make sure you're always using the latest version.

To make a Debian package for lame

The following instructions will let you create a package for Debian for Lame.

Install the fakeroot package

apt-get install fakeroot

Download and patch Lame

You can find the latest version at:

Uncompress it.

Create the package

 $ cd lame-X.YY
 $ fakeroot debian/rules clean
 $ fakeroot debian/rules build 
 $ fakeroot debian/rules binary
   (lots of output)
   dpkg-deb: building package `lame' in `../lame_3.97-8_i386.deb'.
   dpkg-deb: building package `libmp3lame0' in `../libmp3lame0_3.97-8_i386.deb'.
   dpkg-deb: building package `libmp3lame0-dev' in `../libmp3lame0-dev_3.97-8_i386.deb'.
 $ cd ..
 $ su -c "dpkg -i libmp3lame0* lame_X.YY-Z_i386.deb"
 

You can optimize the binary. For instance, I optimized for a pentium D CPU:

 $ MAKE="make -j2" fakeroot debian/rules build CFLAGS="-O2 -march=pentium4"

Create the ripping script

#!/bin/sh
# See <http://wiki.freaks-unidos.net/mp3-encode> for details.

# Set here the parameters you want to pass to lame.  If you don't want
# to spend hours tweaking lame, just use the ones we use, which lean
# towards the high-quality/big-size end of scale, averaging about
# 180 kbps (although the actual bitrate varies since VBR is used):

LAME_PARAMS=-h -V2 -b32 -mj -q1

cdparanoia -B 1-
normalize-audio -vb track*.cdda.wav
for file in track*.cdda.wav;
do
  lame $LAME_PARAMS $file \
    $(echo $file | sed 's/track\(..\).cdda.wav/\1.mp3/') &&
  rm $file;
done

Run the almighty script

Now insert an album in your CD reader; run cdparanoia -vsQ and make sure it can see it; create a directory to leave your files on; and run the almighty script.

There is a parallel version for the almighty script. It will be useful if you have more than one CPU. You can also tweak it to execute remote instances of LAME to use more that one computer to encode the MP3s.

http://svn.arhuaco.org/svn/src/junk/trunk/music-scripts/threaded-encode.py

Set the tags

We have an experimental script to set the tags. Before using it you need to install the requiered libraries.

 # apt-get install libcddb-get-perl libmp3-tag-perl

Then you can download the following file:

 $ wget http://svn.arhuaco.org/svn/src/junk/trunk/music-scripts/download-tags.pl
 $ chmod +x download-tags.pl

In the same directory you ran the almighty script, do:

 $ ./download-tags.pl

Check the MP3 files. If you like the result, then you can rename the mp3 files.

 $ chmod +x rename.sh ; ./rename.sh

Then you should create a directory for the artist, and then one for the album. Like this:

 $ mkdir Sergio_Garcia
 $ mkdir Sergio_Garcia/La_Balada_del_Robot

Finally, place the mp3 there.

 $ mv *mp3 Sergio_Garcia/La_Balada_del_Robot

And then, keep the mp3s for yourself. :)

Last update: 2007-10-16 (Rev 13001)

svnwiki $Rev: 14721 $