How to Denoise Audio with FFmpeg afftdn Filter
This article provides a practical guide on how to use the
afftdn (Audio FFT De-noise) filter in FFmpeg to clean up
noisy audio tracks. You will learn the basic command structure, the key
parameters available for fine-tuning the noise reduction, and
step-by-step examples of how to apply these settings to your audio and
video files.
The afftdn filter in FFmpeg is a powerful audio denoiser
that uses Fast Fourier Transform (FFT) to reduce constant background
noise, such as hiss, hum, or computer fan noise, from an audio
track.
Basic Usage
To apply the default noise reduction settings to an audio file, use the following basic command:
ffmpeg -i input.mp3 -af "afftdn" output.mp3In this command, -af specifies that you are applying an
audio filter, and "afftdn" invokes the denoiser with its
default configuration.
Key Parameters for Fine-Tuning
While the default settings work well for general noise, you can
customize the behavior of afftdn using specific parameters.
The most commonly used options include:
- noise_reduction (nr): Sets the amount of noise
reduction in decibels (dB). The default value is 12 dB. The allowed
range is 0.01 to 97 dB. Increasing this value removes more noise but may
introduce digital artifacts to the remaining audio.
- Example:
afftdn=nr=18(increases noise reduction to 18 dB)
- Example:
- noise_floor (nf): Sets the noise floor in decibels
(dB). The default is -50 dB. The allowed range is -120 to -20 dB. If
your background noise is quiet, lower this value; if it is loud, raise
it.
- Example:
afftdn=nf=-40
- Example:
- noise_type (nt): Specifies the type of noise to
target. Options include
w(white noise),p(pink noise),b(brownian noise),v(vinyl noise), oru(custom/user-defined). The default is white noise.- Example:
afftdn=nt=p(targets pink noise)
- Example:
Practical Examples
1. Moderate Noise Reduction
For a balanced output that reduces moderate background hiss without
distorting human speech:
ffmpeg -i input.wav -af "afftdn=nr=15:nf=-45" output.wav2. Removing Loud Background Hum from a Video
If you are dealing with a loud hum or fan noise in a video file, you can
increase the reduction level while copying the video stream without
re-encoding:
ffmpeg -i input.mp4 -c:v copy -af "afftdn=nr=20:nf=-35" output.mp43. Targeting Pink Noise
If the background noise is deeper and resembles pink noise rather than a
high-pitched hiss:
ffmpeg -i input.mp3 -af "afftdn=nt=p:nr=12" output.mp3By adjusting these three core parameters (nr,
nf, and nt), you can clean up most constant
background noises from your audio recordings using FFmpeg.