13

To be more precise than in the title, suppose I have a MP3 file that is 320 kbps. If I decompress it, then logically, all the data except for roughly 320 kilobits out of each second of audio should be redundant data, able to be compressed away. So, when I encode the decompressed file to FLAC, or any other lossless codec, why is it so much larger?

On a related note, is it theoretically possible to losslessly recover the source mp3 audio from a decompressed wav? (I know the mp3 itself is lossy. I'm asking if it's possible to re-encode without any further loss.)

EDIT: Let me clarify the related question, and the rationale behind it. Suppose I have a wav that was decompressed from an MP3 file (and assume I don't have the mp3 itself for some reason). If I don't want to lose any more quality, I can re-encode it with FLAC or any other lossless encoder and get a larger file just to maintain the same quality. Or, I can re-encode it to mp3 again and get the same size as the original but lose more data. Obviously, neither of these cases is ideal. I can either have the original size or the original quality, but not both (I mean the quality of the original mp3, not the original lossless source). My question is: Can we get both? Is it theoretically possible to recover the lossy compressed data from the lossy decompressed data, without losing even more?

If it is possible, I could imagine a lossless compression algorithm that compresses the audio with FLAC. Then it also scans the audio for any signs of previous lossy compression, and if detected, recompresses it losslessly to the original lossy file. Then it keeps whichever file is smaller.

4
  • here's my favorite guide to ripping and encoding audio. enjoy, it's an excellent read: mp3.radified.com
    – Molly7244
    Commented Oct 30, 2009 at 6:23
  • 2
    The decoder does not simply pad the 320kb up to 1411kb with meaningless bits, the bitrate of a PCM file is given by the bit-per-sample value, the number of channels and the sampling rate. For standard CD audio this is (2 channels)*(44.1KHz sample rate)*(16 bits-per-sample) = 1411kbps.
    – skelly
    Commented Oct 30, 2009 at 7:22
  • Simple, MP3 is compressed, FLAC is uncompressed. When you convert, it Uncompresses the MP3 data.
    – Moab
    Commented Jun 2, 2012 at 16:12
  • 2
    That is wrong. FLAC is an audio compression format. Commented Jun 3, 2012 at 15:12

4 Answers 4

32

The reason the FLAC is larger than the MP3 of the same data is because they encode differently. :) MP3 just encodes perceptual information, while FLAC stores every single speck of data, just in a more compact format.

  • Converting a WAV to a FLAC is like converting a BMP to a PNG.
    • Same exact pixels, but compressed losslessly like a ZIP file into a smaller size.
  • Converting a WAV to an MP3 is like converting a BMP to a JPEG.
    • Instead of storing exact pixels, it's really storing instructions for generating squares with ripples of color that look kind of like the original.

Similarly, MP3 just stores instructions for generating ripples that, when added together, sound kind of like the original. But the difference between the true signal and the generated signal (the error signal) consists of random noisy artifacts, like JPEG jaggies. When you then store this in a perfectionist format like FLAC, it needs to store all those jaggies, and random noise is harder to compress losslessly, so it increases the size of the file. (Truly random noise is incompressible. When you compress a file losslessly, you're eliminating redundant repeating patterns and making it look more like random noise.)

I bet if you convert the JPEG to PNG you will see the same kind of increase in size as you see when converting MP3 to FLAC, since the perfectionist lossless codec needs to remember every little jaggy and artifact that wasn't in the original bmp.

This analogy isn't perfect, since audio is more like a photo than a line-art diagram, but it helps get the idea across:

Original BMP size: 29 kB

Blue dots in PNG form

PNG size: 629 B

Blue dots in JPEG form with jaggies

JPEG size: 1.7 kB

Blue dots with jaggies re-encoded to PNG

PNG created from JPEG: 6.2 kB

10
  • 3
    But of course once a file is converted to JPG, data is lost, and can't be recovered by converting to PNG. If there's more data in the FLAC/PNG much of it will be fictitious.
    – pavium
    Commented Oct 30, 2009 at 6:38
  • 1
    Yes. Meaningful data is lost, and erroneous data is created.
    – endolith
    Commented Oct 30, 2009 at 16:34
  • 1
    That is clearly illustrated in endolith's example diagrams.
    – hplbsh
    Commented Oct 30, 2009 at 17:17
  • 1
    This is an amazingly thorough answer. Nice job!
    – cowgod
    Commented Oct 30, 2009 at 20:47
  • 1
    You are right. I don't know what I was thinking. Commented Apr 27, 2010 at 22:58
3

When you decode an MP3, no matter what bitrate, you get standard 1411kbps/44100Hz 16bit (or whatever the source was) PCM audio that has all the noticeable and un-noticeable effects of the lossy encode process, this format is required for playback and encoding/re-encoding, any file of any codec is being decompressed when you play it on your computer, MP3 player, etc.

The FLAC encoder doesn't care if the audio it's compressing came from a decoded MP3 or a brand new CD, it will simply reduce the size of the source file without any change to the audio data, making a full recovery of the source possible, a lossless process.

A FLAC file made from an MP3 will sound exactly like the MP3, a FLAC file made from a CD track will sound exactly like the CD.

0

To answer part two, if you convert back to a WAV from the MP3, then pick a lossless encoder, you should have an identical-quality file when you're done.

As to why the FLAC is bigger than the MP3, you're taking one of the more-compressed formats, decompressing it, then recompressing it in a less-efficient compression tool (though with a higher-quality of playback).

It's kind of like asking why converting a JPG to a PNG makes it bigger - you're [partially] decompressing the file, then recompressing in a lossless way. FLAC, like PNG, isn't optimized for space, but for quality.

3
  • FLAC (and PNG) are lossless, so saying that those are optimized for quality don't make sense. Commented Oct 30, 2009 at 17:01
  • 3
    @Joakim: lossless == max quality, so lossless formats are optimized for quality by definition. Commented Oct 30, 2009 at 19:43
  • 2
    that's my point, by definition so there is no optimization. if the defintion is max quality, then there is nothing to optimize Commented Oct 31, 2009 at 0:34
0

mp3 reqiures a decoder to be playable, the result of the decoder is an approximation of the original track (usually from a CD), so the decoder adds data to make it playable (and this is not nonsense data). The resulting approximation got the same bitrate as the original track. Without decoding the mp3 the information makes no sense, so can not be converted to anything else (unless very similar encodeing, like stereo-mp3 to 2X mono-mp3). And FLAC and mp3 is not even close to similar. When decodig a FLAC the result is not an approximation of the orignal data encoded into FLAC, but it is the exactly same.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .