8
$\begingroup$

Using ffmpeg, I'm recording a talk, its audio with a semi-distant microphone. It makes sense to somewhat enhance the speech clarity, reduce background static and environmental noise, etc., in the most generic terms.

What combination of ffmpeg audio filters am I best advised to use to enhance recorded speech?

I'm currently using

highpass-frequency=300,
lowpass-frequency=4000,

as that is the range speaking voice is most prominent in,

bass=frequency=100:gain=-50,
bandreject=frequency=200:width_type=h:width=200,

to additionally attenuate the bass frequencies, and

compand=attacks=.05:decays=.05:points=-90/-90 -70/-90 -15/-15 0/-10:soft-knee=6:volume=-70:gain=10

to apply dynamic range compression and supposedly make the softer passages (above -70dB) louder and the louder ones more even.

I understand digital filters are not magic, but I'm looking for something more from ffmpeg's (or LADSPA's) repertoire to enhance the sound more, make it more resilient to noise, sporadic coughs, perhaps lose the acquired metallic aftersound ...

The Linux command line I'm using to test:

filters='
...above filter lines, in sequence...
'

arecord -q -r 11025 -f s32_le -c 1 -t wav - |
    ffmpeg -f wav -i - -af "$filters" -f wav - |
    aplay
$\endgroup$
1
  • 1
    $\begingroup$ Excellent question; I eagerly await an answer. Of course, this may be off topic "There is no single correct answer", but I'll hold off on flagging for now :-) $\endgroup$ Jun 17, 2016 at 20:40

3 Answers 3

2
$\begingroup$

I just came across one article related to the compand command that might be useful (just in case someone looking for help sees this article).

From the article:

To test this, and my understanding of compand, I added a very simple filter to remove the quiet section of the audio by decreasing their volume dramatically:

ffmpeg -i in.mp3  -filter_complex \
  "compand=attacks=0:points=-30/-900|-20/-20|0/0|20/20" \
  out.wav

attacks=0 means that I wanted to measure absolute volume, not averaging the sound over a short (or long period of time). When the speaker suddenly yells, or talks back and forth with someone off mic, I want the volume adjustment to be immediate. The downside is that you may hear the volume being clamped.

points is the actual volume mapping function, and I’ll walk through it:

I added a mapping of -30/-900, which means that volume below -30db in the original input track gets converted to -900db (completely silent).

enter image description here

$\endgroup$
2
$\begingroup$

The 1st mentioned tutorial https://medium.com/@jud.dagnall/dynamic-range-compression-for-audio-with-ffmpeg-and-compand-621fe2b1a892 is a great introduction and the filter documentation also adds a few examples.

http://www.ffmpeg.org/ffmpeg-filters.html#toc-compand

Its very dependent on situation if your set up for near field or far field but generally its common for the voice command to be the predominant range and just to reduce background noise to a minimum without giving too much effect to the voice signal of interest.

So a simple noise gate to drop low level noise where above that its given gain to normalise is probably all that is needed.

The above 2 are great sources of info as is the ffmpeg filter chain but its likely you will get better effects by modifying and testing the settings yourself.

$\endgroup$
1
$\begingroup$

In man ffmpeg-filters, there are several examples that may be of interest:

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 

and many others.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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