MP3 bitrate detection through frequency spectrum analysis

eimiar picture eimiar · Aug 26, 2010 · Viewed 18.8k times · Source

Is there any program that detects the bitrate of an MP3? I'm not talking about the effective bitrate that the file has been encoded with, but the real bitrate that can be calculated only by frequency spectrum analysis.

For example, if I have an MP3 encoded in 128 kbps whose size is 1 MB, and then I transcode this MP3 to 320 kpbs whose size becomes 3 MB, I will have the same identical audio track, but with different sizes.

If I have a 320 kbps MP3 and I transcode it to 128 kbps I will lose some quality and therefore some file size.

But still, I have no way to verify that 320 kbps is my MP3's "real" bitrate.

Details are explained in this paper: http://www.fileden.com/files/2009/2/14/2321055/My%20Documents/MP3%20Bit%20Rate%20Quality%20Detection%20through%20Frequency.pdf

Answer

user719662 picture user719662 · May 12, 2014

Firstly, https://www.google.com/?q=mp3+cutoff+frequency can be quite enlightening.

Secondly, almost all MP3 are encoded using presets with quite standard polyphase lowpass filters. Since it is actually impossible to achieve lossless compression with MP3, what is lost is actually the higher harmonics of the base frequencies (see FFT, DCT, wavelet transforms etc); the filter is applied so that the results of later Fourier analysis of the spectrum is more coherent with human hearing range (ie unhearable/masked frequencies are eliminated from the analysis at all). It's actually impossible to achieve a high compression without cutting off/severly distorting higher frequencies, since it's actually them that occupy most of the space in the bit stream.

Of course, without the cutoff the frequency domain limiting would be less accurate - but it would still occur. The cutoff is applied, amongst other reasons, so that the compression artifacts are generated outside of the psychoacoustic hearing range.

As a point of reference - do a spectrum analysis of the stream (realtime SA with Winamp clone would suffice if the higher frequency ranges are saturated enough, you can also simply do a spectrogram if you have the tools), and find the cutoff point. In below example, the cutoff occurs @ 15 kHz, which informs me the stream was originally compressed @ 128 kbps ; I'd even go so far to say it's actually possible to distinguish <= 128 kpbs streams by ear with many kinds of music (drum'n'bass and other electronic music genres with lots of highs come to mind).

MP3 spectrum analysis

The most common cutoffs are: (note that they are "hard" in CBR and "soft" in ABR/VBR)

  • 128 kbps : 15-16 kHz (very audible on rock/electronic music! "loss of space" effect)
  • 192 kbps : ~19 kHz (barely audible in most cases, considered transparent by most)
  • 256-320 kbps : > ~20kHz (inaudible)

Yes, I'm aware that some people can hear above 20 kHz, but the masking effect appearing in music plus the actual response times from the speakers means that in actual music 20 kHz cutoff is irrelevant to sound quality.

source: own reasearch as an audio engineer plus https://web.archive.org/web/20150313010213/http://www.whatinterviewprep.com/prepare-for-the-interview/spectral-analysis/ as an additional reference