Home/News | About | Download | Documentation | Forum | Bug Reports | Contact | Donations | Consulting | Projects | Legal | Security | FATE


This forum has not been maintained for a long time and will probably get deleted in the near future.
For faster responses to your questions, please use StackOverflow instead and tag your questions with "FFmpeg".
If you need a backup of the posts from this forum, please contact me directly.

FFmpeg vs MP3 audio input = severe clipping

Discussions about problems encountered using ffmpeg.
Forum rules
FFmpeg is in a state of perpetual development and we do not currently have the person power to backport fixes to official releases. As such, if you wish to query or report a bug, you must try with the latest development branch revision of FFmpeg to confirm the issue still exists. The latest FFmpeg can be downloaded from here: http://www.ffmpeg.org/download.html

FFmpeg vs MP3 audio input = severe clipping

Postby Fin » Wed Mar 08, 2017 11:39 pm

It appears that MP3 files can contain audio that is over-scale, or in other words, audio with an amplitude greater than 1x.

When transcoding such an MP3 file with FFmpeg, the output has severe hard clipping in the waveform. Using "-af volume" or "-af loudnorm" does not correct this problem, since these filters only operate on the output.

So my question is, how can I get FFmpeg to properly handle these MP3 files so that their audio doesn't get clipped? Is there a setting for the input that would allow for correcting the gain on these MP3 files?

Here's a screenshot of an over-scale file. If I import an over-scale type MP3 file into Audacity, it correctly handles it, and you can see that the waveform is above the 1x scale line.

Image

And here's a screenshot of what FFmpeg does to that file if I transcode it to WAV format, using "-af volume=0.5". You can see that it did change the output level to half, but it still clipped the waveform, resulting in square waveform tops for anything that exceeds 1x amplitude in the source file.

Image
Fin
 
Posts: 7
Joined: Wed Mar 08, 2017 10:58 pm

Re: FFmpeg vs MP3 audio input = severe clipping

Postby llogan » Wed Mar 08, 2017 11:46 pm

Please provide a link to a sample MP3 input file if possible.
Get an answer more quickly by providing your actual ffmpeg command and the complete console output. Use the code button to format your command and output or your question will be ignored.
llogan
 
Posts: 2341
Joined: Fri Jan 25, 2013 9:47 pm
Location: Alaska

Re: FFmpeg vs MP3 audio input = severe clipping

Postby Fin » Thu Mar 09, 2017 12:07 am

Here's a sample MP3 file that has over-scale audio.

https://dl.dropbox.com/s/47jmjgpdn6vg2xt/FFMpeg%20MP3%20Sample.mp3

And forgot to mention, Audacity can import an MP3 file in two ways, a native method, and via FFmpeg. Using the native method results in proper audio, but using the FFmpeg method results in clipped audio.
Fin
 
Posts: 7
Joined: Wed Mar 08, 2017 10:58 pm

Re: FFmpeg vs MP3 audio input = severe clipping

Postby mulvya » Thu Mar 09, 2017 5:37 am

Code: Select all
Replay gain                              : -11.29 dB
Replay gain peak                         : 1.677088


Your MP3 has a Replaygain tag, so you can try the volume filter with RG info taken into account.

Code: Select all
-af volume=0.5:replaygain=track
mulvya
 
Posts: 566
Joined: Mon Oct 26, 2015 6:58 am

Re: FFmpeg vs MP3 audio input = severe clipping

Postby Fin » Thu Mar 09, 2017 6:32 am

mulvya wrote:Your MP3 has a Replaygain tag, so you can try the volume filter with RG info taken into account.


Thanks, I'd tried that, but given that the filters only modify the output, the clipping still happens. It seems that the clipping is happening on the input side of things.
Fin
 
Posts: 7
Joined: Wed Mar 08, 2017 10:58 pm

Re: FFmpeg vs MP3 audio input = severe clipping

Postby Fin » Thu Mar 23, 2017 7:07 pm

llogan wrote:Please provide a link to a sample MP3 input file if possible.

Were you able to duplicate the issue?

Btw, I realized that AC3 tracks can also have over-scale audio, and transcoding it to WAV format using "-af volume=0.5" works correctly and no clipping happens. So it looks like FFmpeg can handle over-scale input, but maybe not for MP3 audio?
Fin
 
Posts: 7
Joined: Wed Mar 08, 2017 10:58 pm

Re: FFmpeg vs MP3 audio input = severe clipping

Postby llogan » Fri Mar 24, 2017 12:54 am

Fin wrote:Were you able to duplicate the issue?

Sorry, I forgot. I will try to look at it over the weekend.
Get an answer more quickly by providing your actual ffmpeg command and the complete console output. Use the code button to format your command and output or your question will be ignored.
llogan
 
Posts: 2341
Joined: Fri Jan 25, 2013 9:47 pm
Location: Alaska

Re: FFmpeg vs MP3 audio input = severe clipping

Postby Fin » Mon Apr 17, 2017 10:53 pm

Hi, any news on this issue?
Fin
 
Posts: 7
Joined: Wed Mar 08, 2017 10:58 pm


Return to ffmpeg

Who is online

Users browsing this forum: No registered users and 5 guests