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: Side effects of compression (Read 731 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Side effects of compression

Hi,

Could not find a topic on this, sorry if I have not searched enough. Apparently all encoded audio files are shifted, delayed ... whatever. Please see the attached picture and tell me if you noticed the same.

Thanks.


Re: Side effects of compression

Reply #1
It's normal for MP3 but I don't know if it happens with EVERY lossy format.

See the LAME FAQ.

Re: Side effects of compression

Reply #2
I was just trying to evaluate the "noise" produced by the encoding process. You probably know: load both the wav and the encoded file in Audacity, invert one, mix and render.

Mp3, aac, wma, ac3 ... ALL are delayed and (some of them) stretched. Aligning them is a tedious job, the result is not rigorous, and you don't know if the noise is really the encoding noise or the misalignment noise.

For video encoders there are psnr, ssim, vmaf measuring tools, but for audio you can't do a simple subtraction  :-\

Re: Side effects of compression

Reply #3
Quote
I was just trying to evaluate the "noise" produced by the encoding process. You probably know: load both the wav and the encoded file in Audacity, invert one, mix and render.
Actually, that time-shift somewhat demonstrates the ineffectiveness of this subtraction method.     If you get dead silence, yes that proves the files are identical.   But if you don't get silence that doesn't prove they sound different. 

i.e. Just time-shifting by a few milliseconds (without compression) doesn't change the sound at all but when you subtract it makes a HUGE-LOUD difference file!    ...Very misleading since they actually sound identical.

"The sound of the difference is NOT the same as the difference in the sound..."

With MP3 there are other small timing & phase changes that may, or may not, affect the actual sound, but they do create a "difference" when subtracted.

...Is the "noise" produced by encoding, or is this remaining good-sound from the original file that's removed by the lossy compression, creating a "difference"?   ;)

Re: Side effects of compression

Reply #4
The delay is one among several "round" numbers in samples (1024, 672, 576, 528, 512, 481, 256) and remains the same for a given encoder. Switch the timeline from seconds to samples. Most formats record and compensate for the delay, so it appears that there is none. With MP3, older audio editors do not take it into account.

If the delay is caused by an unknown process, just look for an irregular impulse to match. It can be seconds away from the start of the clip. Occasionally the shift is in fractional number of samples, and you can get a better match by upsampling. If the shift is modulated backward and forward, then it becomes audible.

Re: Side effects of compression

Reply #5
If you decode an MP3 file to WAV using LAME, it will counteract the delay (I don't know if the MP3 file has to be encoded with LAME in order for this to work).

Re: Side effects of compression

Reply #6
Audacity decodes the mp3 anyway, before showing the waveform. And the delay is there. Please see the OP above.

Re: Side effects of compression

Reply #7
It's a madness: a 02:50.160 wav with 7504056 samples was coded by ffmpeg to a 02:50.130 log mp3 (that's what ffmpeg reported).
MediaInfo reports for the same file a length of 02:50.188 and 7505280 samples. 1224 more.

Decoded by Audacity, the same file lost somehow 529 of the excess samples remaining with only 695 more than the original.
577 were at the beginning, 118 at the end. I cut them out so the original wav and the converted to mp3 files were in absolute sync.

Invert->Mix->Render...The result is a very attenuated version of the original song. Most of the figures are captured in the attached screenshot.

I'll repeat the steps above for lower quality encoded mp3 of the same original but even if the method proves to be perfect (which I doubt) it is too much work to evaluate a codec and his various parameters.

(Later Edit: encoding in Audacity itself makes things look much better. There are still extra samples but Audacity wipes them off when importing the mp3 back and the original and the "copy" are in perfect sync. see the second screenshot. However the question remains)

Do you know a better objective way to evaluate the quality of a "copy"?. I know, flac produces a flat-line, I've already tested, but my boomblaster wants aac, wma or mp3.  8)

Re: Side effects of compression

Reply #8
Quote
Do you know a better objective way to evaluate the quality of a "copy"?
MP3 is a lossy "perceptual" algorithm so the only meaningful way to judge quality is by listening.

Re: Side effects of compression

Reply #9
Quote
Do you know a better objective way to evaluate the quality of a "copy"?
MP3 is a lossy "perceptual" algorithm so the only meaningful way to judge quality is by listening.
by blind listening tests, that is. Such as ABX or ABC/HR.

Re: Side effects of compression

Reply #10
Quote
Do you know a better objective way to evaluate the quality of a "copy"?
MP3 is a lossy "perceptual" algorithm so the only meaningful way to judge quality is by listening.

I expected this answer because it is true. However, H.264 AVC and H.265 HEVC are also lossy and make heavy use of human eye perception. And there are rigorous tools to test them.

Re: Side effects of compression

Reply #11
There are algorithms that make an educated guess of perceived quality compared to the original. Perceptual Evaluation of Audio Quality (PEAQ) is one such algorithm. Both the basic and advanced version of it are known to have some inaccuracies when compared to real subjective ABC/Hr listening tests. You can check ITU-R BS.1387-1 for the technical details.

There are several open source implementations of the basic version available. You can download the source code and compile them. I'm not aware of any freely available implementations of the advanced version.

 

Re: Side effects of compression

Reply #12

See the LAME FAQ.

This part was really useful:

More technical details on very short ENCDELAY:
Here is an example:


                    granule 1         granule 2 
                    576 samples       576 samples
                | 192 | 192 | 192 | 192 | 192 | 192 |
data:           <    all zeros'   >< real  data     >
short block   <--------->
                    <--------->
                           <--------->
end block                       <---------------------->

output:                           | 192 | 192 | 192 |

Subtracted 576 (I was damn close with my "perceptive" 577 but, never mind) and everything came into place. I think I am done with .mp3 ... moving to .mp4/aac. Thanks, DVDdoug!