How to Use the Haas Filter in FFmpeg

This article provides a quick guide on how to use the haas audio filter in FFmpeg to create a wider, more spatial stereo field from mono or narrow stereo audio. You will learn the basic command syntax, understand the key parameters of the filter, and see practical examples of how to apply the Haas effect to your audio files.

The Haas effect (also known as the precedence effect) is a psychoacoustic phenomenon where a listener perceives the spatial direction of a sound based on the channel that arrives first, even if the delayed channel is slightly louder. In FFmpeg, the haas filter simulates this effect by introducing a millisecond-level delay and phase adjustments between the left and right channels, transforming flat audio into a wide, spatial stereo mix.

Basic Command Syntax

To apply the Haas filter with its default settings, use the following FFmpeg command:

ffmpeg -i input.mp3 -af "haas" output.mp3

Key Parameters of the Haas Filter

You can customize the stereo widening effect by passing specific parameters to the haas filter using the format haas=parameter=value. The most commonly used options include:

Practical Examples

1. Customizing the Delay and Volume

To create a more subtle widening effect, you can decrease the delay to 15 milliseconds and slightly reduce the output level to avoid digital clipping:

ffmpeg -i input.wav -af "haas=delay=15:level_out=0.9" output.wav

2. Keeping Channels in Phase

Inverting the phase of one of the channels dramatically increases the perceived width, but it can cause phase cancellation when the audio is played back on mono systems. If you want to keep both channels in phase (normal):

ffmpeg -i input.wav -af "haas=phase_r=normal" output.wav

3. Adjusting Stereo Balance

If the spatial effect makes the audio sound off-center, you can balance the left and right channel levels individually to center the soundstage:

ffmpeg -i input.wav -af "haas=balance_l=0.8:balance_r=1.0" output.wav