Sound noise reduction

Problem

Reduce the noise of an audio file.

Solution

ffmpeg \
    -i input_file \
    -filter:a "afftdn=nr=10:nf=-25:tn=1" \
    -c:a pcm_s24le \
    output_file

General command

ffmpeg \
    -i input_file \
    -filter:a "afftdn=nr=noise_reduction:nf=noise_floor:tn=noise_tracking" \
    -c:a audio_codec \
    output_file

Command syntax

ffmpeg
starts the command
-i input_file
path, name and extension of the input file
-filter:a "afftdn=nr=noise_reduction:nf=noise_floor:tn=noise_tracking"
denoise audio samples with FFT
-c:a audio_codec
set the audio codec
output_file
path, name and extension of the output file

Discussion

The sound filter is specified by -filter:a. We advise to avoid the alias -afilter and its abbreviation -af as well. The sound filter afftdn is used. The quotation marks are not mandatory. There are many parameters for denoising audio samples with FFT (fast Fourier transform), including:

  • noise reduction: set the noise reduction from 0.01 to 97 dB (the default value is 12 dB)
  • noise floor: set the noise floor from -80 to -20 dB (the default value is -50 dB)
  • noise tracking: enable noise tracking that adjusts automatically the noise floor (by default is disabled)

The default audio codec is pcm_s16le. The output quantisation should not be higher than the input quantisation.


2023-03-08