Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Decoding mp3 Creates different sized wav (Read 2616 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Decoding mp3 Creates different sized wav

Hi everyone. This is my first post, so go easy on me and please let me know if I am posting in the wrong place.  While I have been home recovering from knee surgery this week, I have been palying around with audio compression and trying to learn about the different encodings and see if I can hear the differences.

The Background
Since my ear is not that good, I wanted to hear the difference between a compressed audio file and the original wav.  I encoded the original wav using oggenc and then decoded it back to wav using ogg123 and then inverted the waveform of the new file and mixed it back with the original using soxmix.  The result is quite amazing, to be able to hear what was removed in the encoding process.  I wanted to do the same with an mp3 and perhaps diff the ogg and mp3 to see the differences between the two compression formats, but I am having trouble because the mp3's are decoding to different sizes.

The Details:
I ripped a song to wav from a CD and I ended up with a file size of 28877900 blocks.  When I encode that wav as an Ogg and then decode it back to wav, I get a consistent file size of 28877900, but when I encode the original wav to mp3 and back, I get a wav file size of 28882988.  5088 blocks bigger.  Does anyone know what is happening and how I can work around it?  I'm using vorbis-tools 1.0.1 and lame 3.95 on Linux.

TIA for any insight.

Decoding mp3 Creates different sized wav

Reply #1
Rather than trying to re-invent the wheel, why don't you do a search of this forum for previous listening tests of different formats?   
Nov schmoz kapop.

Decoding mp3 Creates different sized wav

Reply #2
Which mp3 encoder are you using? If you are using LAME you should not have this problem.
The problem is that mp3 encoders fill the last frame with silence to complete it. Only the LAME encoder saves the real length and is therefore able to decode it correctly (so-called gaplessly).

Decoding mp3 Creates different sized wav

Reply #3
Quote
Rather than trying to re-invent the wheel, why don't you do a search of this forum for previous listening tests of different formats?   

Because I wanted to hear the differences and because of the learning experience.  There's nothing like doing it yourself to aid retention.

I have been googling for two days before making this post and I have not found any discussion of this particular problem.

 

Decoding mp3 Creates different sized wav

Reply #4
Quote
Which mp3 encoder are you using? If you are using LAME you should not have this problem.

I am using LAME for both the encoding and the decoding.

Quote
The problem is that mp3 encoders fill the last frame with silence to complete it. Only the LAME encoder saves the real length and is therefore able to decode it correctly (so-called gaplessly).

So the wav should be lined up from the beginning and the extra will be at the end, this sounds like a reasonable explanation.  But this does not appear so, because if I go ahead and invert the decoded mp3 and mix it back in, I get a result that sounds like the original song but with some echo, so instead of the amplitudes canceling each other out, they are offset slightly and creating an echo effect.  I can infer from this phenomena that some of the extra is actually at the beginning of the track.

Decoding mp3 Creates different sized wav

Reply #5
Try decoding with foobar2k.

But I would also like to say that your approach to comparing and judging the quality of codecs is not so good. One crucial part of lossy coding is to remove sounds that are conceiled by other louder sounds. So what you are doing is trying to hear things that cannot be heard when listening to the original file. A good codec only removes sounds that really cannot be herad in the original, and a not so good codec might remove some sounds that could be heard. But with your approach you will be comparing all that has been removed, of which most probably isn't hearable in the original.

A better approach to comparing codecs is trough blind ABX testing against the original. There should be lots of info about this either in the FAQ, wiki or by using the search function... BTW, foobar2k has a good ABX comparator built in. Just enqueue the original and the encoded version. Select both, right-click and chose ABX something... (I think you need the special installer to get the ABX component)

Decoding mp3 Creates different sized wav

Reply #6
Quote
But I would also like to say that your approach to comparing and judging the quality of codecs is not so good. One crucial part of lossy coding is to remove sounds that are conceiled by other louder sounds. So what you are doing is trying to hear things that cannot be heard when listening to the original file.

I understand that.  I was just using this approach out of curiosity to hear what the encoder removed.  For instance, with a Q4 Vorbis file, I cannot tell the difference between that, the 192 vbr mp3 or the original, it is all transparent.  But using my approach, I hear that a lot was taken out by the encoder, even though I cannot hear what was removed when listened to the encoded file.  I was just curious.

I am in the process of setting myself up to do some training for the purpose of doing the blind testing, so we'll see what happens and if I can get better at it.

Decoding mp3 Creates different sized wav

Reply #7
Have you seen...
http://www.ff123.net/training/training.html

Also, I'd second the use of foobar2k to (more often than not) make sure the decoded file is time-aligned with the original.

Or do the time aligning yourself in whatever audio editor you're using to subtract the waves. Most codecs add silence at the beginning and/or end - some trim it when decoding. You do have to check though - never assume!

Cheers,
David.

 
SimplePortal 1.0.0 RC1 © 2008-2021