How to Use FFmpeg Compand as a Noise Gate

This article explains how to configure the FFmpeg compand (compressor/expander) filter to function as a noise gate. You will learn the exact command-line syntax and parameter settings required to suppress unwanted background noise from your audio files by silencing signals that fall below a defined volume threshold.

Understanding the Compand Filter as a Noise Gate

A noise gate is an audio processor that allows signals above a certain threshold to pass through, while attenuating (silencing) signals below that threshold. While FFmpeg has a dedicated agate filter, the compand filter offers highly customizable downward expansion, making it an exceptionally flexible tool for gating noise.

To act as a noise gate, compand must be configured to heavily reduce the volume of quiet sounds (the noise floor) while leaving louder sounds (like speech or music) untouched.

The FFmpeg Noise Gate Command

Here is the standard FFmpeg command to apply a noise gate using the compand filter:

ffmpeg -i input.mp4 -af "compand=attacks=0.01:decays=0.2:points=-80/-900|-40/-900|-39/-39|0/0" output.mp4

Parameter Breakdown

How to Fine-Tune the Gate

To adapt this filter to your specific audio file, you may need to adjust the threshold points:

  1. Identify the Noise Floor: Listen to a quiet section of your audio to estimate the volume of the background noise. If the noise is around -45dB, set your threshold point to -45.
  2. Adjust the Points String: If your noise floor is at -45dB, modify the points parameter to: points=-80/-900|-45/-900|-44/-44|0/0
  3. Smooth the Transition: If the gate sounds too harsh or “choppy” when opening and closing, increase the decay time (e.g., decays=0.5) to allow for a smoother fade-out.