The FFmpeg documentation for the afftdn audio filter says for the -sn flag:

sample_noise, sn
Start or stop measuring noise profile. Syntax for the command is : "start" or "stop" string. After measuring noise profile is stopped it will be automatically applied in filtering.

It's a little unclear as to the basic implementation of the start/stop values in the sample_noise -sn flag. I tried:

ffmpeg -i inputfile.wav -af afftdn=nt=c:bn=sn=start=0=stop=1 noiseout.wav

as an attempt to sample the first second of sound as a noise profile, which errors with

[afftdn @ 0x7fefbb800000] Custom band noise must be integer.

So the questions are:

  1. What's the correct input format for sample_noise?

  2. Is there a way to sample the noise from a noise reference .wav file that I have, e.g. noiseprofile.wav?


Commands are instructions sent from an interface external to the filter, usually an external program using a ZMQ protocol. There is a filter that can execute commands which is what I'll use here.

Base syntax is

ffmpeg -i in -af "asendcmd=c='0.0 afftdn@n sn start; 1.0 afftdn@n sn stop',afftdn@n" noiseout.wav

To use another source for noise profile, you'll have to append it, measure noise, and then remove it.

ffmpeg -i in -i profile -filter_complex "[1][0]concat=n=2:v=0:a=1,asendcmd=c='0.0 afftdn@n sn start; 1.0 afftdn@n sn stop',afftdn@n,atrim=1,asetpts=PTS-STARTPTS" noiseout.wav

Above, I assume the profile is 1 second long, which is removed with atrim after denoising.

  • That's absolutely perfect. Thanks! – BreadEagles Jan 13 '20 at 7:23
  • @Gyan can we use this filter when we are recording windows desktop? Like how to use this filter in this command ffmpeg.exe -threads 4 -rtbufsize 2048m -f dshow -i audio="Microphone (Realtek Audio)" -f gdigrab -offset_x 1 -offset_y 1 -video_size 768x432 -probesize 4096M -i desktop -pix_fmt yuv420p -c:v libx264 -crf 28 -preset ultrafast -tune zerolatency -movflags +faststart -r 15 "test.mp4 – Riz Jul 15 '20 at 8:04

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.