[FFmpeg-user] how to maximize the volume without distorting the sound using ffmpeg?

littlebat dashing.meng at gmail.com
Thu May 19 04:04:24 CEST 2011


On Wed, 18 May 2011 15:15:33 +0200
Nicolas George <nicolas.george at normalesup.org> wrote:

> L'octidi 28 floréal, an CCXIX, littlebat a écrit :
> > Is there a way to maximize the volume without distorting the sound
> > using Ffmpeg? just like the "-af volnorm" filter in Mencoder?
> 
> Your message is self-contradictory: -af volnorm does not do what you
> think, it adjusts the gain to keep the volume mostly uniform, this is
> very much a distortion.
> 
> Maximizing the volume without distortion requires a constant gain
> (because a variable gain is a distortion) and finding the greatest
> gain that will avoid clipping.
> 
> The latest operation can only be done by decoding the whole stream
> once first, obviously. I think ffmpeg does not have a tool to compute
> the maximum value of a sample; mplayer does, it's -af stats.

Thanks for your reply.

This is documented in mplayer(mencoder) man page:
( http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.html#AUDIO%20FILTERS )
<quote>
****************************************
volnorm[=method:target]
	

Maximizes the volume without distorting the sound.
	

<method>
	

Sets the used method.
	

1: Use a single sample to smooth the variations via the standard
weighted mean over past samples (default). 2: Use several samples to
smooth the variations via the standard weighted mean over past samples. 

<target>
	

Sets the target amplitude as a fraction of the maximum for the sample
type (default: 0.25).
****************************
 </quote>

And I found "mencoder -af volnorm" is really useful after some tests. I
attach two Audaity(audio editor) audio track screenshots, one is orginal
(orig.png) and another is "-af volnorm" by mencoder(volnorm.png). But,
there are still some places is clipped in volnormed file(red part).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: orig.png
Type: image/png
Size: 20309 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20110519/b1792013/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: volnorm.png
Type: image/png
Size: 20620 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20110519/b1792013/attachment-0001.png>


More information about the ffmpeg-user mailing list