Configure FFmpeg adeclip Filter Threshold and Method
The adeclip filter in FFmpeg is a powerful tool designed
to restore clipped audio by interpolating damaged samples that exceed a
specific digital amplitude limit. This article provides a quick guide on
how to configure the threshold and method
parameters within the adeclip filter to effectively clean
up distorted audio recordings.
Understanding the adeclip Filter Parameters
When audio is recorded too loudly, it “clips,” resulting in
flat-topped waveforms and harsh digital distortion. The
adeclip filter detects these flat peaks and reconstructs
them using mathematical interpolation.
To customize this process, you primarily configure two parameters: threshold and method.
1. Configuring the
Threshold (threshold or t)
The threshold parameter defines the amplitude level at
which a sample is considered clipped.
- Value Range: It accepts a double value between
0.001and1.0. - Default Value:
0.98(which represents 98% of the maximum digital scale). - Usage: If you set the threshold to
0.95, any audio sample reaching 95% of the maximum volume will be flagged as clipped and scheduled for interpolation.
Example Command:
ffmpeg -i input.wav -af "adeclip=threshold=0.95" output.wav(Alternatively, you can use the short alias
t):
ffmpeg -i input.wav -af "adeclip=t=0.90" output.wav2. Configuring the Method
(method or m)
The method parameter determines the mathematical
algorithm used to reconstruct the clipped peaks.
- Available Options:
double(default): Uses double-precision autoregressive interpolation. This is the recommended setting for most standard audio files as it offers highly accurate restoration.ortho: Uses orthogonalization. This method is computationally faster but may yield slightly different reconstruction results depending on the complexity of the audio.
Example Command:
ffmpeg -i input.wav -af "adeclip=method=ortho" output.wav(Using the short alias m):
ffmpeg -i input.wav -af "adeclip=m=double" output.wavCombining Threshold and Method
For optimal results, you will usually want to configure both parameters together based on the severity of your audio’s clipping.
To apply a threshold of 0.96 using the
double interpolation method, use the following command:
ffmpeg -i input.wav -af "adeclip=threshold=0.96:method=double" output.wavIf the clipping is severe, lowering the threshold (e.g., to
0.90 or 0.85) forces the filter to reconstruct
a larger portion of the wave peak, though setting it too low may
introduce unwanted smoothing artifacts.