by August 10, 2001 0 comments

Ever gotten tired of changing Audio CDs ever so often? If only you knew how to make them smaller so that more could fit onto a CD. The most common form of compressed audio is the MP3 format. MP3 stands for MPEG 1 (Layer III), which uses an encoding algorithm to compress data to get smaller file sizes. Other formats like RealAudio, WMA, mp3PRO(the next step in MP3 technology) and the Open Source OggVorbis format are also capable of compressing audio, but then some are more efficient than others at different bitrates. By far MP3 is the most popular format forpersonal audio playback. Other reasons are that some encoders like RealAudio are commercial products . However, there are a number commercial and non-commercial encoders available for the MP3 format. This article focuses on creating MP3s on Linux.

What needs to be done

  • The audio has to be extracted from the source (digital/analog media) and saved into a file.
  • The file is then encoded into the required format using the appropriate encoder.

Tools Audio rippers

The source for an MP3 can either be digital or analog. The most common form is from CompactDisc Audio or CDDA. Now many encoders can encode from various sources like raw PCM input, WAV files or even from MP3s. The best way to create music for personal listening to extract the digital audio into WAV files and encode using your favourite encoder. To extract audio from CompactDisc Audio on Linux, we can use either of the two tools, cdda2wav or cdparanoia. Most people prefer cdparanoia. If they are not already installed, they can be found on the PCQ Linux 7.1 CD 1.

Mount the CD-ROM and as root
# cd /mnt/cdrom/Redhat/RPMS/
# rpm -ivh cdparanoia* or # rpm -ivh cdda2wav*

Audio encoders

For encoding we will use lame. As there are certain regulations againstdistributing encoders as binaries, you can find the lame source code in RPM format on the CD-ROM with this issue.

To compile from the source rpm:
# cd /mnt/cdrom/linux/audio/ lame/# rpm –rebuild lame-3.86-1.src.rpmm

This will compile the source and create a lame binary file in /usr/src/redhat/RPMS/. To install it
# rpm -ivh /usr/src/redhat/RPMS/ i386/lame-3.86-1.i386.rpm


Cdparanoia, cdda2wav and lame are all command line applications. They have to be invoked individually to perform their specific tasks. But there are a number of front ends, both graphical and command line based to make things simpler and faster.

One of the best, is Grip. To install it off this month’s CD
# rpm -ivh /mnt/cdrom/linux/

Grip is just a GUI based front-end utility which lets you rip and encode MP3s using mostly any tool you prefer. It is very configurable and can also get CD and track listings from CDDB servers, which makes naming your tracks a whole lot simpler.

Putting it all together

Now you’re all set to start creating your personal MP3 collection. Just plop an Audio CD in and fire up grip, by typing grip at a command prompt. It should automatically start getting the CDDB info for your CD (provided you are online).

The config tab

First, we will take a look at the config tab. In the Rip options, you can choose the ripper of your choice. Grip comes in built with its own version of cdparanoia, but you can use either the cdparanoia or cdda2wav that’s already installed on the system. Plus, there are other options like, auto-rip on insert, auto-eject after rip. 

In the MP3 options tab, choose the encoder of your choice, assuming you have it installed. Lame is installed, so choose lame from the list box.

Lame has a variety of command line options. To get a list of all the options, type ‘lame -?’ at the command prompt. By default, lame encodes in joint stereo, which is fine, but if you want full stereo, you will have to specify it. In addition to Constant Bit Rate (CBR), it also supports Average Bit Rate (ABR) and Variable Bit Rate (VBR) encoding. For most purposes, CBR at 128 kilobits will produce an MP3 which is of good quality with a low file size. But for the discerning audiophile who likes to hook up his soundcard to his Hi-Fi system, you will have to encode at higher bitrates which means larger file sizes.

CBR at 128 kbps means that it allocates 128 kb whether it’s needed or not. Since music is dynamic, the bitrate which is needed to accurately encode all the sounds without loss varies with the way the song progresses. On relatively silent parts, 128 kb may be more than needed, and on others it may not be enough. That’s why ABR and VBR are more efficient with respect to file size vs quality. The drawback is that the file size cannot be calculated accurately, because the bitrate varies depending on the content. In ABR, an average bitrate is specified, while in VBR, a minimum and maximum bitrate has to be specified.

In the track options tab, you can edit the names of the tracks/artists and select the songs you want to make MP3s out of by right clicking on each track.

There are also tabs for specifying your proxy server(if you have one), CDDB server and others, which are self-explanatory.

Once the tracks have been selected, you can start ripping and encoding by pressing the ‘Rip+Encode’ button in the Rip Tab. The ‘Rip Only’ button can be used for just ripping the tracks onto hard disk without encoding. You can also extract and encode certain parts of a track by supplying the start and end sectors.

Recommended settings

The best way to find out what’s good for you is to spend some time looking at the options in lame and trying them out. Use cdparanoia to extract an audio track of your choice:
cdparanoia -v 1

“1” is track 1 on the CD. This will extract the audio into a file called “cdda.wav”. Now you can try out various bitrates and decide on the one you would like to use. Once that is done, just add the options in the MP3 Command Line Box in the Config Tab of Grip if you want to use those settings. For example, for CBR:
lame –add-id3v2 -m s -h -p -b 160 cdda.wav cdda.mp33
–add-id3v2 enables the addition of ID3 Version 2 Tags. ID3v1 tags only support a maximum of 30 characters in the song title, so if the song title is longer than that, this option will use id3v2 tags to add the rest of the title name.
-m s : forces it to encode in full stereo
-h : high quality setting. To use this setting in Grip, just add “–add-id3v2 -m s -h” into the “mp33 command-line box”.

For VBR:

lame –add-id3v2 -v –nohist –vbr-new -V 0 -q 0 -B 320 -p -b 112 cdda.wav cdda.mp3mp3
To use this setting in Grip, just add “–add-id3v2 -v –nohist –vbr-new -V 0V 0-q 0 -B 320” into the mp3 command-line box and don’t forget to change the minimum bitrate value (-b) in the “Encoding Bitrate(kbits/sec)” box in the Encoder Tab.

This setting uses VBR encoding with a minimum bitrate of 112 kbps and a maximum of 320 Kbps using the new VBR algorithm at the highest quality.

There are also presets available. To get a list of the presets and the equivalent settings:
lame –preset helpp
“lame –preset cd cdda.wav cdda.mp3” is the same as “lame -h -m s -bb 192 cdda.wav cdda.mp3”

Now, you’re all set to start ripping your CDDA music collection into an MP3 collection. If you have a CD-writer handy, then you can cut your own MP3 CDs as and when you need to.


Lame homepage
Grip homepage

Sony Philip is a technology research consultant with Exocore Consulting

No Comments so far

Jump into a conversation

No Comments Yet!

You can be the one to start a conversation.