Restore Clipped Audio Using FFmpeg adeclip Filter
This article provides a straightforward guide on how to restore
clipped audio using FFmpeg’s adeclip filter. You will learn
what audio clipping is, how the adeclip filter reconstructs
distorted waveform peaks, and the exact command-line syntax required to
clean up and recover your damaged audio files.
Understanding Audio Clipping and the adeclip Filter
Audio clipping occurs when an audio signal is over-amplified beyond the maximum limit of a digital system (0 dBFS). This slices off the tops and bottoms of the audio waveforms, resulting in flat peaks that cause harsh, digital distortion.
FFmpeg’s adeclip (audio declip) filter addresses this by
detecting these flattened peaks and using mathematical
interpolation—specifically, autoregressive modeling—to estimate and
reconstruct the missing waveform data.
Basic Usage Command
To run the filter with its default settings, use the following basic FFmpeg command:
ffmpeg -i input.wav -af adeclip output.wavThis command reads your input file, applies the declipping algorithm, and exports the restored audio to a new file.
Advanced Configuration and Parameters
For severely clipped audio, the default settings might not be enough.
You can fine-tune the adeclip filter using several key
parameters:
w(window size): Sets the window size in milliseconds. The default is 55. Larger windows can handle longer clipped segments but require more processing power.o(overlap): Sets the window overlap percentage. The default is 75. Higher overlap provides smoother transitions at the cost of processing speed.a(autoregressive order): Sets the order of the autoregressive model. The default is 8. Higher values can reconstruct more complex waveforms but may introduce unwanted artifacts if set too high.thresholdort(clipping threshold): Sets the threshold level for detecting clipped samples. The value ranges from 0.0 to 1.0 (default is 0.9). If your audio clipped at a lower level due to previous digital attenuation, lower this value to help the filter identify the flat peaks.
Example of an Advanced Command:
ffmpeg -i input.wav -af "adeclip=threshold=0.85:w=100:a=12" output.wavIn this example, the filter is instructed to detect clipping at a lower threshold (0.85), use a larger window size of 100 milliseconds, and apply a higher autoregressive order of 12 for a more aggressive restoration.
Preventing Post-Restoration Clipping
Reconstructing peaks increases the volume of the restored sections,
which can cause the output file to clip again at the output stage. To
prevent this, it is recommended to chain the volume filter
to reduce the overall gain before exporting:
ffmpeg -i input.wav -af "adeclip,volume=-3dB" output.wavThis ensures the newly reconstructed peaks have enough headroom to exist without inducing new digital distortion.