How to Apply Delay and Echo in FFmpeg

This article provides a practical guide on how to use the adelay and aecho audio filters in FFmpeg to create sophisticated delay effects with multiple decaying reflections. You will learn the exact syntax for each filter, how they control audio signals, and how to chain them together in a single command line to achieve professional-sounding echoes and spatial depth.

Understanding the adelay Filter

The adelay filter is used to delay the start of specific audio channels. It is highly useful for introducing an initial pause before an audio signal begins or for creating a basic Haas effect (stereo separation) by delaying one channel slightly more than the other.

The basic syntax for adelay is:

adelay=delays=delay_1|delay_2|...

Delays are specified in milliseconds by default. You must specify a delay time for each channel in the audio stream (e.g., left and right for stereo).

For example, to delay the start of a stereo audio file by 1.5 seconds (1500 milliseconds) on both the left and right channels, use:

ffmpeg -i input.wav -af "adelay=1500|1500" output.wav

Understanding the aecho Filter

The aecho filter creates more complex, repeating reflections (echoes) with volume decay over time. This filter allows you to define multiple reflections, each with its own time delay and decay factor.

The syntax for aecho is:

aecho=in_gain:out_gain:delays:decays

For example, to create an echo with two reflections—one after 400 milliseconds at 50% volume, and a second after 800 milliseconds at 25% volume—use:

ffmpeg -i input.wav -af "aecho=0.8:0.88:400|800:0.5|0.25" output.wav

Combining adelay and aecho for Complex Decay Reflections

To create a professional delay effect, you can chain these filters together using a comma-separated filtergraph. This allows you to insert an initial silent gap at the beginning of the audio track using adelay, and then pass that delayed signal into the aecho filter to generate multiple cascading, decaying reflections.

Here is the command to apply both filters:

ffmpeg -i input.wav -af "adelay=1000|1000,aecho=0.8:0.9:200|400|600:0.6|0.3|0.15" output.wav

How this command works:

  1. adelay=1000|1000: Pauses the entire stereo input for 1000ms (1 second) before any audio is heard.
  2. aecho=0.8:0.9:200|400|600:0.6|0.3|0.15: Takes the delayed signal and applies three distinct echo reflections:
    • First reflection occurs 200ms after the sound starts, at 60% (0.6) of the original volume.
    • Second reflection occurs at 400ms, at 30% (0.3) of the original volume.
    • Third reflection occurs at 600ms, at 15% (0.15) of the original volume.