How to Configure FFmpeg dcshift Filter Shift Value

The dcshift filter in FFmpeg is a useful tool for modifying the DC offset of an audio stream. This article provides a straightforward guide on how to configure the shift value within this filter, explaining its syntax, parameter limits, and practical command-line examples to help you adjust your audio’s DC level effectively.

Understanding the dcshift Filter Syntax

The dcshift filter alters the DC offset of an audio signal by adding a specific constant value to all audio samples. The basic syntax for configuring this filter in FFmpeg is:

dcshift=shift=<value>:limitergain=<value>

Alternatively, you can use the shorthand notation by specifying the parameters in order:

dcshift=<shift_value>:<limitergain_value>

The shift Parameter

The shift parameter is the core setting of this filter. It dictates the amount of DC shift applied to the audio waveform.

The limitergain Parameter (Optional)

When you apply a DC shift, the audio signal might exceed the maximum amplitude limits, resulting in digital clipping. To prevent this, you can configure the limitergain parameter.


Practical Examples

Here are common ways to apply and configure the shift value in FFmpeg command lines.

Example 1: Applying a Simple Positive Shift

To apply a positive DC shift of 0.1 to an input audio file, use the following command:

ffmpeg -i input.wav -af "dcshift=shift=0.1" output.wav

Example 2: Applying a Negative Shift Using Shorthand

To apply a negative shift of -0.05 without explicitly typing the parameter name, use the shorthand format:

ffmpeg -i input.wav -af "dcshift=-0.05" output.wav

Example 3: Configuring Shift with Limiter Gain

To apply a shift of 0.15 and enable a limiter gain of 0.05 to prevent clipping on peak signals, run:

ffmpeg -i input.wav -af "dcshift=shift=0.15:limitergain=0.05" output.wav