[FFmpeg-user] Set audio level in aevalsrc audio filter
Moritz Barsnick
barsnick at gmx.net
Tue Jul 1 12:12:56 CEST 2014
On Tue, Jul 01, 2014 at 11:52:35 +0200, Massimo Battistel wrote:
> I should obtain ~0.12589 for -18dB
You do and you don't. :-)
You must understand that the average level of a sine signal is -3.0dB:
http://en.wikipedia.org/wiki/Crest_factor#Examples
You can confirm this thus:
# ffmpeg -f lavfi -i 'aevalsrc=sin(1000*2*PI*t)' -af volumedetect -t 00:01:00 -f null -
[...]
[Parsed_volumedetect_0 @ 0xb9da6a0] n_samples: 2647040
[Parsed_volumedetect_0 @ 0xb9da6a0] mean_volume: -3.0 dB
[Parsed_volumedetect_0 @ 0xb9da6a0] max_volume: 0.0 dB
[Parsed_volumedetect_0 @ 0xb9da6a0] histogram_0db: 792312
The aevalsrc uses the full maximum aplitude, but the resulting
mathematical (and measured, as by volumedetect) "average" is -3.0.
Your example with the (correctly) calculated -18 dB factor gives this result:
# ffmpeg -f lavfi -i 'aevalsrc=0.12589*sin(1000*2*PI*t)' -af volumedetect -t 00:01:00 -f null -
[...]
[Parsed_volumedetect_0 @ 0x9c656a0] n_samples: 2647040
[Parsed_volumedetect_0 @ 0x9c656a0] mean_volume: -21.0 dB
[Parsed_volumedetect_0 @ 0x9c656a0] max_volume: -18.0 dB
[Parsed_volumedetect_0 @ 0x9c656a0] histogram_18db: 792312
Thus exactly what is to be expected.
By the way, the factor you are looking for, i.e. for -15dB, is
0.1778279. Using the same math that you quoted. :-) You only need to
know what exactly you desire; one of the two is correct for you.
Instead, you could probably also use the volume filter
("-af volume=-15dB"), but I'd have to think about whether that gives
the same result or could introduce quantification errors (other than
aevalsrc would do). Perhaps the latter are not even your concern. I'm
being extremely picky with this note.
Cheers,
MB, eh, Moritz
More information about the ffmpeg-user
mailing list