How to Apply Allpass Filter with FFmpeg

This article provides a quick, practical guide on how to apply an allpass filter to an audio track using FFmpeg. You will learn the essential command-line syntax, the primary parameters used to configure the filter, and a few concrete examples to help you alter the phase of your audio without affecting its overall frequency amplitude.

To apply an allpass filter in FFmpeg, you use the -af (audio filter) flag followed by the allpass filter name and its parameters. The allpass filter changes the phase relationship of various frequencies in your audio signal while keeping the frequency response flat.

Basic Syntax

The basic structure of the command is as follows:

ffmpeg -i input.mp3 -af "allpass=f=frequency:w=width" output.mp3

Key Parameters

The allpass filter accepts several parameters to customize how the phase shift is applied:

  • frequency (or f): Sets the filter's center frequency in Hz. The default value is 3000 Hz.
  • width_type (or t): Defines how the filter bandwidth is measured. Options include:
    • h (Hz)
    • q (Q-factor, default)
    • o (octave)
  • width (or w): Sets the band-width of the filter. If you use Q-factor as your width type, a higher value results in a sharper phase transition around the center frequency.
  • channels (or c): Specifies which audio channels the filter should be applied to (by default, it applies to all channels).

Practical Examples

Example 1: Standard Allpass Filter To apply an allpass filter at a center frequency of 1000 Hz with a Q-factor of 2.0:

ffmpeg -i input.wav -af "allpass=f=1000:w=2.0" output.wav

Example 2: Specifying Width Type in Octaves To apply the filter at 500 Hz using an octave-based width of 1.5 octaves:

ffmpeg -i input.wav -af "allpass=f=500:t=o:w=1.5" output.wav

Example 3: Processing Specific Channels To apply the filter exclusively to the first channel (usually the left channel in stereo):

ffmpeg -i input.wav -af "allpass=f=2000:w=1.0:c=1" output.wav