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: Why does my mp3 Clip? (Read 17398 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Why does my mp3 Clip?

Hi!

I have encoded a 16Bit wav, which is at -0,1dB, to mp3.
When i import it to reaper (audio sequencing software) it shows, that there is clipping several times.
Both with foobar and lamedrop mp3s whether cbr 320 or v0, it is always.
It is not in the wav.

So i wonder, if that is ok, or should i feed lame with loudness lowerded audio?

Thanks!

Why does my mp3 Clip?

Reply #1
I believe the clipping is caused by the lossy nature of mp3 (it will happen with other lossy formats too). The mp3 is not exactly the same as the original, so some peaks might decrease while other peaks increase and cause clipping.
I don't think you can predict how much higher the peak of the mp3 will be compared to the original, so it will be hard to create an mp3 with a peak exactly at 0dB. You can go the trial & error way, just keep on tinkering with the volume of the original until the peak in mp3 will be 0dB.


In my collection of mp3s about 2/3 of them are clipping, so it's certainly not abnormal. However there is a solution. To avoid clipping you can use software that decodes the mp3 at a lower volume, like Foobar2000 with replaygain or preamp option. The result will be restored peaks and less clipping!

Check out this wave comparison. On the right the original mp3 decoded at normal level, you can see it's clipping. On the left is the same mp3 decoded at lower preamp with Foobar2000 and the peaks are somewhat "restored".

Why does my mp3 Clip?

Reply #2
Clipping is with lossy encoding is normal.  I've yet to see a compelling reason why it should be addressed if it isn't audible.  I've issued more than a few challenges for people to show me proof that they can identify clipping as a lossy artifact using settings that would otherwise be transparent with actual music.  So far there have been no positive responses.

Why does my mp3 Clip?

Reply #3
Decoding to floating point should prevent clipping. 24 integer PCM with Replay Gain adjustment should also work. In both cases you'll see that the tops are not really cut off but just overflow 16 bit integer samples.

Why does my mp3 Clip?

Reply #4
@googlebot: Your answer may add confusion. I'll try to avoid such situation.

Like Mark7 says, clipping with mp3 (and similar lossy encoders) can appear in quite a natural way (for more info, read how the sound is formed from sine waves and that lossy encoders can add and remove some of them)

To listen to the mp3 file, it has to be in integer mode in some place between the player's decoder and the soundcard's DAC. Saying that one can use floating point is a bit misleading.
Of course, if you have a digital volume that receives floating point audio, and you use it to reduce the volume (like Replaygain with negative values), it can prevent the clipping, but that's a side effect, not a prevention mechanism per se.

Also, I would like to add that 24bit integer has just a higher SNR than 16bit integer. It does NOT have a higher 0dBfs. Something that clips at 16bits, still clips at 24bits, if you want to keep the same volume. I mention this because a reader could get an incorrect impression from your sentence.

@Bobolith: Like others have said, this clipping is generally not audible (although there have been audible cases, and definitely a synthetic case can be made to be clearly audible).
There's the option to live with it, and the much more used solution of using Replaygain, like googlebot suggested.
Players that use replaygain can reduce the volume while decoding, which prevents the clipping (since the mp3 file is not clipped, just the decoded audio when decoded to integer).

Why does my mp3 Clip?

Reply #5
(although there have been audible cases, and definitely a synthetic case can be made to be clearly audible)

Do you have a link to a sample for a non-synthetic case?

Why does my mp3 Clip?

Reply #6
Dibrom, Oct 31 2002:
"Scale is not included in the vbr presets, because vbr in LAME doesn't have the horrible problems with clipping that abr does, especially as bitrate decreases."

http://www.hydrogenaudio.org/forums/index....ost&p=42141

Why does my mp3 Clip?

Reply #7
So it seems that it was an issue which was raised some eight years ago that did not appear to extend beyond ABR.  As we know, Lame has gone through considerable development over the last eight years.  Perhaps this hasn't been the case for ABR, though I think it's worth nothing that HA recommends VBR, not ABR.

I'd really like to get my hands on some non-synthetic samples, since after all,
Hydrogenaudio is supposed to be an objectively minded community that relies on double-blind testing and relevant methods of comparison in discussion about sound quality.

I've provided some samples that have been downloaded a dozen or so times by people, some of whom seemed quite determined to prove that clipping as an audible artifact during decoding is a legitimate issue.  The only response I've gotten so far has been the sound of crickets.

Why does my mp3 Clip?

Reply #8
thanks for all your answers!
i also made listening tests, and it is inaudible in my mp3.

Why does my mp3 Clip?

Reply #9
I hope you are not re-editing your MP3 encoded projects and you just opened the files in Reaper to check the clipping. Possibly you are aware of this, but the audio quality always suffers from a generation loss when MP3 is decoded to the uncompressed pcm format and re-encoded to MP3.

As already said, the MP3 clipping phenomenon is most likely inaudible, but other, probably quite a bit more audible, encoding artifacts are likely to appear when lossy files are opened and re-encoded in a lossy format.

EDIT

Regarding MP3 clipping, I did some experimenting with manufactured test samples a few months ago. I have not yet posted the samples and my findings here, but this thread triggered me to start creating a presentation. I intend to post it in a new thread soon. It will not prove anything about the audibility of MP3 clipping in natural audio tracks, but it is possible to ABX test the samples and they also show interesting things when the waveform and frequency spectrum graphs are viewed with an audio editor.

 

Why does my mp3 Clip?

Reply #10
I decided to post my presentation here instead of creating a new thread. This reply is on topic here.


The sample I used is from Garbage's "Bleed like Me" from the similarly named album. The whole album is very loud and compressed and this track has a replay gain peak of 1.705888 (= about 4.65 dB over 0 dBFS) when a LAME -V5 encoded MP3 version is analyzed with foobar. A loud cymbal crash seems to be causing the highest peak in the MP3 encoded version.

Here is the wavefrom of 7-second passage from lossless source file (it includes about 3.5 seconds before and after the cymbal crash):



Its spectrum looks like this:



I encoded the complete track to MP3 (LAME 3.98.4 -V5) and decoded two versions of it with foobar2000 1.03 -- a 16-bit wave file (peaks truncated) and a 32-bit float wave file (peaks preserved).

Then I adjusted the volume levels of all three files (lossless and two decoded MP3 files) -5 db to preserve the peaks when the files are saved in the 16-bit format. In order to isolate the most clipped passage I decided to cut 6000 samples from the midle of the files. These 6000 samples include the highest peaking part of the above mentioned cymbal crash.

Here are the waveforms of the three 6000-sample files (animated gif):
1. Lossless. Converted to 32-bit float and the volume level adjusted -5 dB
2. MP3, peaks truncated. Decoded to 16-bit int, converted to 32-bit float and the volume level adjusted -5 dB
3. MP3, peaks preserved. Decoded to 32-float and the volume level adjusted -5 dB





The waveform of the loudest peak looks like this:





...and the spectrums of the same files. Notice how truncating has generated visible content (distortion, noise, whatever) to the 16-22 Khz frequency range. Though, this additional content is relatively quiet (about 50 dB below 0 dBFS) and propably would not be audible even in an audio track with a long passage of it. It is also interesting to see how the spectrum contains some additional high frequency content in the very begining and end of the sample. That stuff was generated simply by cutting the 32-bit files in Audition. I didn't change anything else. It wasn't visible before the cut.





Since 6000 samples is not long enough for ABX testing (about 0.136 seconds) I looped the sample 15 times and created files that contain 90000 samples (about 2 seconds). I saved the looped samples to 16-bit wave files (with dithering)

Here are the waveforms of the looped samples:


... and the spectrums:



My actual findings in last May when I created the samples were that I could easily hear differences in the looped samples. All three were different. No ABX testing was necessary. Since the sample was not anymore anything like music I didn't have a preference between the MP3 samples. Both were quite different from the lossless source file.


However, on yesterday I decided to create three new samples that would not be artificial. I cut the above mentioned seven second passage from the three complete decoded tracks and did the same adjustments. (-5dB, dither, save to 16-bit)

After that I ABX tested the two MP3 sourced versions. It wasn't exactly easy, but the result was clear. The files are audibly different:

Code: [Select]
foo_abx 1.3.4 report
foobar2000 v1.0.3
2010/07/12 20:51:55

File A: F:\Test\clipping\Bleed like me\a 7 sec. sample, cymbal crash at 3.5 s\LAME -V5 decoded to 16-bit int (peaks truncated), adjusted -5dB, dithered, 16-bit.flac
File B: F:\Test\clipping\Bleed like me\a 7 sec. sample, cymbal crash at 3.5 s\LAME -V5 decoded to 32-bit float (peaks preserved), adjusted -5dB, dithered, 16-bit.flac

20:51:55 : Test started.
20:52:34 : 01/01  50.0%
20:52:38 : 02/02  25.0%
20:52:44 : 03/03  12.5%
20:52:50 : 04/04  6.3%
20:52:56 : 05/05  3.1%
20:54:25 : 06/06  1.6%
20:54:45 : 07/07  0.8%
20:55:03 : 08/08  0.4%
20:55:46 : 09/09  0.2%
20:56:03 : 10/10  0.1%
20:57:11 : 11/11  0.0%
20:57:48 : 12/12  0.0%
20:58:00 : Test finished.

----------
Total: 12/12 (0.0%)


I will still need to do additional tests and decide which one is more transparent.


I'll upload a sample package and add a link here soon.

EDIT

The link: http://www.hydrogenaudio.org/forums/index....st&p=713729

Why does my mp3 Clip?

Reply #11
LAME -V5

I realize that your test was not necessary intended to answer my repeated challenge, but why did you choose -V5?

My challenge has always been to use a setting that would otherwise deliver transparent results.  NB my idea of "transparent" is black and white; something is either transparent or it isn't.  If it turns out that one of your samples is transparent to the lossless source, then I think you're on to something, though I object to the looping since it also does not meet my other criteria that the samples be non-synthetic.

EDIT: One more question, are you encoding before or after looping?

Why does my mp3 Clip?

Reply #12
It was just an attempt to evaluate how MP3 clipping affects the sound and also how a file with preserved clips differs from the lossless source.

Actually, -V5 is not far from transparent with this sample (I mean the 7-second "natural" version). In the "preserved" sample the cymbal crash is slightly louder and higher i.e. the highest frequencies appear to be slightly pronounced during a very short period. In the "truncated" file the crash might be a bit distorted, but not similarly louder. I'll try to further evaluate the differences in a proper test. I am not sure at all that the "preserved" sample is more transparent to me.

In general, the extended peaks in MP3 files look clearly different when compared with the original waveform. AFAIK, no one has tried to explain how the sound of such extended peaks should theoretically differ from the original sound. Should they be just loader or also noisier, are some frequencies likely to be more distorted than others and so on. Probably the nature of the source audio signal can affect the nature of the extended peaks greatly. Unfortunately, as we know, practical listening tests are close to impossible.

EDIT

Quote
One more question, are you encoding before or after looping?

I have only one MP3 file. I encoded it directly from the complete unaltered 4-minute source track. The only LAME switch was -V5.
From that MP3 file I created two decoded full length wave versions with foobar. 32-bit float and 16-bit int.
I did the volume adjustments and sample accurate cutting & looping in Audition (in the 32-bit mode).


... and fixed several typos. Argh...

Why does my mp3 Clip?

Reply #13
I have only one MP3 file. I encoded it directly from the complete unaltered 4-minute source track. The only LAME switch was -V5.
From that MP3 file I created two decoded full length wave versions with foobar. 32-bit float and 16-bit int.
I did the volume adjustment and sample accurate cutting in Audition (in the 32-bit mode).

While it might not matter much, I would be interested to know if the results would be any different if you encoded after looping.  Perhaps it isn't justified, but my impression is that encoding after looping would be less synthetic.

Regardless of the differences between my challenge and your tests, I'm glad to see that time is being spent on this issue.  For far too long we've been reading about how people feel unsettled knowing that their mp3s (or hyper-compressed remasters, but that's a different story) are clipped with little, if any, real objective support as to how this clipping is affecting audible sound quality.

Thanks Alex!

Why does my mp3 Clip?

Reply #14
MP3 and other perceptual codecs change the audio data in the original file when they apply a psychoacoustic model and apply a lowpass filter. It is possible for this filtering to make a non-clipping waveform into a clipping one (i.e. with a sample louder than '1' or '-1'). The file doesn't actually 'clip' until it is decoded from the internal floating point representation back to integer.

For example, lets say that there is a 2000Hz waveform and a 15000kHz waveform (both transient) both present and combined in an audio file. At a particular point in the original waveform, the loud 2000Hz wave by itself might have clipped, but the added 15000kHz waveform was out-of-phase at that time, and the sample at that point is now below clipping due to phase cancellation. However, if the lossy codec lowpass-filters out the 15000kHz information, the 2000Hz wave now will go above 0dB.

Since modern CDs are mastered to be as 'hot' as possible, they often are cranked up and are digitally limited to just hit maximum sample volume using the harshest of dynamic compression. When these waveforms are encoded by a lossy codec, they are sure to go above 0db.

LAME has the --clipdetect option; it will encode the file with simultaneous decoding/analysis in the background, and give you a warning if the decoded audio clipped, with the amount of --scale factor you need to apply to be sure the decoded integer PCM waveform does not clip.

With MP3 files already encoded, you can alter the 'scale factor' in the file losslessly in increments of 1.5dB to lower the decode volume. For example, I might open an MP3 in Adobe Audition and find that Audition's built-in MP3 decoder clipped the signal (now unrecoverable). Then I use mp3directcut and adjust the mp3 file's gain -1.5dB. The same file is now decoded -1.5dB quieter and doesn't clip when re-opened with Audition.

If a peak audio sample should have a value of 43829 when decoded, but the sample is limited to 16 bit integer's max value of 32767, then then 'clipping' has degraded the representation of the sound. Whether A/B-able or not, it would be best to avoid.

Dedicated MP3 players could/may have 'clip protection' or extra headroom. If I was designing an MP3 player, it might have a 24 bit DAC and all mp3s could be decoded at -6dB gain. That would give 6dB extra headroom so that mp3s that do go over '1' are decoded without being digitally clipped.

Why does my mp3 Clip?

Reply #15
If a peak audio sample should have a value of 43829 when decoded, but the sample is limited to 16 bit integer's max value of 32767, then then 'clipping' has degraded the representation of the sound. Whether A/B-able or not, it would be best to avoid.

Is this not a subjective statement that really has no bearing in discussion of lossy codecs, especially on a forum such as HA where the entire basis of lossy compression discussion is whether something can be ABX-ed? The whole point of lossy compression is to degrade audio quality in such a way that it can be stored in a smaller file, but it doesn't sound worse than the original. As long as transparency is achieved, the kinds of artifacts that are present in the file don't matter - the goal of sounding like the original is all that does, and the only authoritative way to measure if an MP3 sounds like the original is to ABX it. All MP3 files are going to have "artifacts" due to the degredation that invariably occurs from lossy compression, but as long as you can't hear the pre-echo, clipping, or whatever else is there, it's not important. It seems to me that this still falls within greynol's usual challenge that somebody needs to produce ABX results which demonstrate clipping being the only deciding factor in a MP3 failing to be transparent compared to the original.

Why does my mp3 Clip?

Reply #16
You can argue that point either way.

Problem is, the mp3 psychoacoustic model isn't "listening" to the clipping - so it's just hope / assumption / result of experience that makes people believe the clipping is probably inaudible.

This is fundamentally different from the intentionally lossy parts of the coding (primarily quantisation noise, but also joint stereo, low pass filter, choice of block size etc etc etc), which are (hopefully!) all checked by the psychoacoustic model to be inaudible (at transparent settings), or "least bad on balance" (at non-transparent settings).

Cheers,
David.

Why does my mp3 Clip?

Reply #17
The key difference is that clipping is an artifact of decoding.  I might not go so far as to say that it's an unnecessary artifact, though it can be completely prevented by decoding to 32-bit float (as has been demonstrated).

Why does my mp3 Clip?

Reply #18
...but as we both know, to avoid it at decode time (if the user believes that it "needs" to be avoided) you do need to scale the output before sending it to a DAC.

This can introduce an audible change - the volume will be lower.

Cheers,
David.

Why does my mp3 Clip?

Reply #19
Is this not a subjective statement that really has no bearing in discussion of lossy codecs, especially on a forum such as HA where the entire basis of lossy compression discussion is whether something can be ABX-ed?


If I pee in your car's gas tank, could you A/B the difference? Similarly, why knowingly taint your audio encoding with clipping?

Why does my mp3 Clip?

Reply #20
Quote
If I pee in your car's gas tank, could you A/B the difference? Similarly, why knowingly taint your audio encoding with clipping?
MP3 is always lossy and if you don't want to "taint" your audio, you shouldn't use MP3 or any other lossy format.

Many HydrogenAudio members prefer to use FLAC (or other lossless formats).  But, if you do choose a lossy format it's kind-of silly to worry about "defects" that you can't hear!