4

I have to 'adjust' some recordings of lessons I've attended. The professor was walking here and there but my recorder was in a fixed place; now I have audio tracks going from loud to whispers. How can I deal with it using ffmpeg?

7

There are a few possibilities:

  • Apply simple normalization (e.g. peak or RMS normalization). This will only change the gain throughout the entire file, so you'll still experience variations between loud and soft parts. Not really recommended for your use case.

  • Use dynamic compression with the compand filter. This will reduce the dynamic range (i.e. the difference between soft and loud parts) throughout the recording. You have to find a proper threshold at which the compression kicks in, and you will most likely get quite noisy signals for the soft parts.

  • Use the dynaudnorm filter, which “allows for applying extra gain to the ‘quiet’ sections of the audio while avoiding distortions or clipping the ‘loud’ sections.” In your case, that'd be the preferred option.

Basically, you just have to download a recent static build of ffmpeg from here and then run:

ffmpeg -i input.wav -filter:a "dynaudnorm" output.wav

You will most likely need to tweak the filter options for your particular use case. Use the examples given for the compand filter as a starting point:

Make music with both quiet and loud passages suitable for listening to in a noisy environment:

compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2

Another example for audio with whisper and explosion parts:

compand=0|0:1|1:-90/-900|-70/-70|-30/-9|0/-3:6:0:0:0

Here, the second example's options are, specifically:

attacks=0|0
decays=1|1
points=-90/-900|-70/-70|-30/-9|0/-3
soft-knee=6
gain=0
volume=0
delay=0

You may adjust the gain to keep the same dynamic processing but adjust it to your baseline input level.

Also, as a graphical alternative to ffmpeg, you can use Audacity and its built-in compressor, which achieves the same effect as the compand filter in ffmpeg. The wiki has a quite good explanation for the options, too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.