Coding Horror

programming and human factors

Variable Bit Rate: Getting the Best Bang for Your Byte

I'll probably never buy music from iTunes, or any other online music store, because they all use constant bit rate audio encoding formats. Once I heard the incredible difference in fidelity between variable bit rate (VBR) and constant bit rate (CBR) encoding, I can never go back. And if I'm spending my own money to "own" this music, why pay for the crappy encoded version anyway? I'd rather buy the CD with the raw, uncompressed versions of the music and rip it myself.

Having perfect audio fidelity, however, is not my goal. If I wanted that, I'd go for a lossless audio compression format. They achieve 50 percent compression ratios, but that's still pushing 20 megabytes for the average song. Interesting for archival purposes, but way too big for every other possible use.

What I really want is the best bang for the byte: the smallest file size I can achieve while retaining cd quality. Of course, "cd quality" is in the ear of the beholder. Here's how I judge it: A/B listening tests between the raw WAV file and the encoded file on nice headphones. And to my ear, the best bang for the byte is variable bit rate MP3 files with an average bitrate of at least 160 kbps. Constant bit rate MP3s at 160 kbps do such a poor job of capturing the dynamic range of the music that it isn't even a contender. Sure, I could just encode everything at extremely high constant bit rates like 256 kbps or 320 kbps, but I can't hear the difference to justify the extra filesize. Remember, it's all about bang for the byte!

WinAmp displays the bitrate of a song in real time, which gives you a way to roughly correlate the encoder's decisions to the music. For areas of silence, it'll dip down to 32 kbps, and for areas of high energy, it'll peak up to 320 kbps.

There are some downsides to variable bit rate encoding, however. The encoder has to make complicated decisions about bitrate instead of mindlessly encoding everything at the same bitrate. That means the encoding uses complex algorithms that take quite a bit longer-- at least two times longer than constant bit rate encoding, possibly more. And you want a really smart, high quality encoder, too. Choice of encoder has always been a critical factor in how your music sounds. If you've got a lot of "unknown" MP3s, you may want to check them out with the EncSpot tool. It will tell you what encoder was used and estimate the resulting quality of the file:

EncSpot analysis tool showing a variable bit rate MP3 file

MP3 isn't the only audio encoding format in the world. But it is the most ubiquitous. The good news is that variable bit rate MP3 fares surprisingly well against the hottest new audio encoding formats. A recent multiformat 128 kbps listening test puts VBR MP3 on par with the newer AAC format, and squarely ahead of both ATRAC3 and WMA. Only the newest MPC and Vorbis formats statistically outperformed VBR MP3 in listening tests. Interestingly, both of these formats are natively variable bit rate.

I use the free Audiograbber GUI to rip CDs. It uses the well-respected LAME encoding engine under the hood. You can also use LAME at the command line. Here's LAME encoding a standard 128 kbps CBR MP3 file. It took 15 seconds:

LAME encoding a 128kbps CBR MP3 file

Here's LAME encoding a VBR MP3 at quality level five. It encoded a ~153 kbps average bitrate file in 20 seconds. Most of the frames are encoded at 160 kbps.

LAME encoding a VBR MP3 at quality level 5

Here's LAME encoding a VBR MP3 at quality level three. It encoded a ~218 kbps average bitrate file in 26 seconds. Most of the encoded frames are 224 kbps.

LAME encoding a VBR MP3 at quality level 3

One thing to keep in mind about variable bit rate encoding is that it's, well… variable. If you need predictable filesizes for every song you encode, VBR is definitely not for you. I happened to pick the outlying song on this particular CD; the average bitrates range from 129 kbps to 216 kbps:

bitrate filesize length
157 kbps 3.94 mb 3:30
178 kbps 5.11 mb 4:01
172 kbps 8.04 mb 6:30
185 kbps 9.81 mb 7:23
182 kbps 6.53 mb 5:00
216 kbps 7.23 mb 4:40
129 kbps 3.30 mb 3:34
197 kbps 8.03 mb 5:42
174 kbps 8.86 mb 7:07
196 kbps 5.11 mb 3:38
175 kbps 7.41 mb 5:54
175 kbps 9.33 mb 7:25

The goal is to achieve at least 160 kbps average. Some songs will need more, some might need less. There's something magical about that extra 32 kbps; the difference between a CBR MP3 at 128 kbps and 160 kbps has always been unusually large to my ear.

Written by Jeff Atwood

Indoor enthusiast. Co-founder of Stack Exchange and Discourse. Disclaimer: I have no idea what I'm talking about. Find me here: