问题
I've always used Audacity's Dynamic Range Compressor if I wanted to crank up the volume of an audio file. Today I was looking at whether I could do the same with FFmpeg's acompressor filter.
I've found "how to user "compressor" with ffmpeg" and Gyan's answer, which was really helpful, but not satisfying enough.
Right now I'm actually trying to mimic Audacity's procedure.
If I understand the acompressor
correctly, then I can't apply the makeup gain in one pass. So I need to do a volumedetect
first.
Let's say I have the follow "Audacity options" I'd like to use:
Threshold: -30dB
Noise Floor: -40dB
Ratio: 2:1
Attack Time: 0,2s
Release Time: 1,0s
[x] Make-up gain for 0 dB after compressing
[x] Compress based on Peaks
If I'm correct this translates to:
threshold=0.031623 # 10^(-30/20) = 10^(-1.5) = 0.031623.
ratio=2 # 2 is the default, so no need to specify.
attack=200 # 0.2*1000 = 200ms.
release=1000 # 1.0*1000 = 1000ms.
detection=0 # peak based.
What I don't understand is where I can specify the "Noise Floor". Does acompressor
even have an option for that?
Alright, volumedetect
...
ffmpeg -i input.wav -lavfi acompressor=threshold=0.031623:attack=200:release=1000:detection=0
,volumedetect -f null -
or
ffmpeg -i input.wav -lavfi acompressor=threshold=10^^(-30/20):attack=200:release=1000:detecti
on=0,volumedetect -f null -
(10^^(-30/20)
(Windows), 10^\(-30/20\)
(Unix). pow(10,-30/20)
doesn't appear to work)
...in my case leads to...
n_samples: 23838888
mean_volume: -27.7 dB
max_volume: -7.7 dB
histogram_7db: 3
histogram_8db: 21
histogram_9db: 126
histogram_10db: 458
histogram_11db: 1727
histogram_12db: 5021
histogram_13db: 11816
histogram_14db: 24831
For the 2nd pass I apply a makeup gain of 10^(7.7/20)
or 2.4266
:
ffmpeg -i input.wav -lavfi acompressor=threshold=10^^(-30/20):attack=200:release=1000:detecti
on=0:makeup=10^^(7.7/20) -f wav output.wav
Btw, I noticed that -lavfi acompressor=[...],volume=7.7dB
produces the same output.
So far so good. This is the waveform of output.wav
:
ffmpeg -i input.wav -lavfi acompressor=threshold=10^^(-30/20):attack=200:release=1000:detecti
on=0:makeup=10^^(7.7/20),showwavespic=s=888x295:split_channels=1 output.png
Where as this is the waveform for the same input.wav
processed by Audacity (with the above settings):
I'm no expert in this field, but is the lower overall volume of FFmpeg's output due to the "Noise floor" missing?
If so, how to specify? And if not with acompressor
, what other filter then?
[edit]
ffmpeg -i input.wav -lavfi acompressor=threshold=10^^(-30/20):attack=200:release=1000:detecti
on=0:makeup=10^^(7.7/20),volumedetect -f null NUL
n_samples: 23838888
mean_volume: -20.0 dB
max_volume: -0.0 dB
histogram_0db: 16
histogram_1db: 76
histogram_2db: 329
histogram_3db: 1158
histogram_4db: 3678
histogram_5db: 9473
histogram_6db: 19933
ffmpeg -i input-audacity_drc-peak.wav -af volumedetect -f null NUL
n_samples: 23838888
mean_volume: -16.9 dB
max_volume: -0.0 dB
histogram_0db: 77
histogram_1db: 683
histogram_2db: 4291
histogram_3db: 14065
histogram_4db: 35403
mean_volume: -20.0 dB
vs. mean_volume: -16.9 dB
. So Audacity's output is quite a bit louder. Also having used a noise floor results in very different histogram_xdb
values.
I've had a closer look at other of acompressor
's options and started fiddling with level_in
("Set input gain. Default is 1. Range is between 0.015625 and 64.")
I have no idea what the range stands for, but I figured a value of 2
would mean, make the input twice as loud.
ffmpeg -i input.wav -lavfi acompressor=level_in=2:threshold=10^^(-30/20):attack=200:release=1
000:detection=0:makeup=10^^(7.7/20),volumedetect -f null NUL
n_samples: 23838888
mean_volume: -16.9 dB
max_volume: 0.0 dB
histogram_0db: 1611
histogram_1db: 3779
histogram_2db: 9619
histogram_3db: 20263
And the waveform:
Wow! That's strange. The same mean_volume
as Audacity's output and a very similar waveform.
Do note that is with a make up gain of 7.7dB
for a level_in=1
!
I guess this answers my question about the "Noise Floor". It wasn't causing the lower volume.
Maybe some Audacity experts could explain to me why Audacity is making the audio twice as loud with its DRC filter, while it's not even an option.
Or is my research on the matter completely wrong?
[/edit]
来源:https://stackoverflow.com/questions/57190018/how-to-specify-the-noise-floor-in-ffmpegs-acompressor-filter