Configure Delay Time in FFmpeg Haas Filter

This article explains how to configure the delay time in the FFmpeg haas audio filter to create a stereo widening effect. It covers the specific parameters used to adjust the delay of the left and right audio channels and provides practical command-line examples to help you implement this effect in your audio processing pipeline.

The Haas effect (or precedence effect) is an acoustic phenomenon where listeners perceive the spatial direction of a sound based on the first arriving wavefront, even if a slightly delayed version of the same sound comes from a different direction. In FFmpeg, the haas filter simulates this by allowing you to apply independent millisecond delays to the left and right audio channels.

Delay Parameters in the Haas Filter

To configure the delay times, you need to use the following two primary parameters within the haas filter:

To create the spatial Haas effect, you typically apply a delay of between 10 and 30 milliseconds to one channel while keeping the other channel at zero delay (or a significantly lower delay). Delays longer than 40 milliseconds are not supported by this filter as they would be perceived as a distinct echo rather than a single widened sound source.

Example Commands

Here is a basic command that applies a 20 ms delay to the right channel while keeping the left channel at 0 ms:

ffmpeg -i input.mp3 -af "haas=left_delay=0:right_delay=20" output.mp3

In this example: * -af specifies the audio filtergraph. * haas=left_delay=0:right_delay=20 configures the haas filter, ensuring the left signal plays instantly, and the right signal is delayed by 20 milliseconds.

You can also use the abbreviated parameter names to achieve the same result:

ffmpeg -i input.mp3 -af "haas=ldel=0:rdel=20" output.mp3

If you want to fine-tune the output further, you can combine delay settings with gain adjustments to balance the perceived volume, as delayed channels can sometimes sound quieter:

ffmpeg -i input.mp3 -af "haas=left_delay=15:right_delay=0:left_gain=0.8:right_gain=1.0" output.mp3

This command delays the left channel by 15 ms and slightly reduces its gain to balance the stereo image against the immediate right channel.