Construct Your MP3s

Use command-line tools to encode your MP3 files as well as to build customized MP3 files on the fly.

The MPEG-1 Audio Layer 3 format (MP3 for short) is a lossy compression format for audio. This means the sound going in will have elements removed to pack it into a smaller output size. The process of building an MP3 file from an input sound file is called encoding. The software that does this encoding is called an encoder.

MP3 first became popular around 1995. The first encoders did a poor job, so if you wanted an MP3 that was indistinguishable from a CD, you needed a bit rate of 256. (The bit rate relates to the amount of data stored per second in the file. The more bits, the better the sound.) Modern encoders, such as the latest version of the free LAME encoder (http://lame.sf.net/), produce CD-quality sound at a bit rate of 192.

Deciding what to remove from a recording to create the compressed file is fairly tricky. Modern encoders use a psychoacoustic model of our hearing to decide what to give the most bits to in the recording. Most of the time this will be the dominant frequencies in the segment being encoded. However, encoders are free to use whatever mechanism they think will produce the best sound for the given bit rate.

It follows that for less complex signals, such as a single human voice, we could spend fewer bits and still get a quality sound. This is why spoken-word podcasts encoded at 64 bits or even 32 bits still sound reasonably well. If you have ...

Get Podcasting Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.