Configure Frequency and Offset in FFmpeg apulsator

This guide explains how to control the panning speed and stereo channel phase using the hz (frequency) and offset_l/offset_r (offset) parameters in the FFmpeg apulsator audio filter. By adjusting these values, you can customize the rate of the auto-pan effect and define how the modulation interacts across the left and right stereo channels.

Understanding the Parameters

The apulsator filter produces an auto-pan or tremolo effect by modulating the amplitude of audio channels using a low-frequency oscillator (LFO).

  • Frequency (hz): Sets the modulation frequency in Hertz (cycles per second). For example, hz=1 means the audio completes one full pan cycle every second. Alternatively, you can use bpm to set the frequency based on musical tempo.
  • Offset (offset_l and offset_r): Sets the starting phase offset of the LFO for the left and right channels, represented as a value from 0.0 to 1.0 (where 1.0 corresponds to a full 360° phase rotation).
    • A standard auto-pan effect requires the left and right channels to be 180° out of phase. This is achieved by setting a phase difference of 0.5 between channels (such as offset_l=0:offset_r=0.5).
    • If both offsets are identical (for example, offset_l=0:offset_r=0), the channels modulate together in phase, creating a tremolo (volume pulse) rather than a stereo pan.

Basic Command Syntax

The general syntax for configuring both options within an FFmpeg command is:

ffmpeg -i input.wav -af "apulsator=hz=0.5:offset_l=0:offset_r=0.5" output.wav

In this command:

  • hz=0.5 slows the pan down to one full cycle every two seconds (0.5 Hz).
  • offset_l=0 starts the left channel modulation at phase 0.
  • offset_r=0.5 offsets the right channel by half a cycle (180°), ensuring that as one side gets quieter, the other gets louder.

Adjusting Frequency Using BPM

If you prefer to lock the panning rate to a specific musical tempo, replace hz with the bpm option:

ffmpeg -i input.mp3 -af "apulsator=bpm=120:offset_l=0:offset_r=0.5" output.mp3

This synchronizes the full pan cycle to 120 beats per minute.

Customizing Offsets for Different Effects

  • Standard Auto-Pan (Left-Right Ping-Pong): Keep a difference of 0.5 between channels:

    -af "apulsator=hz=1:offset_l=0:offset_r=0.5"
  • In-Phase Tremolo (Mono Modulation): Set matching offsets to make the volume rise and fall simultaneously on both sides:

    -af "apulsator=hz=2:offset_l=0:offset_r=0"
  • Quarter-Phase Stereo Sweep (90-Degree Shift): Set a phase difference of 0.25 for a less extreme, rotary-like stereo movement:

    -af "apulsator=hz=0.75:offset_l=0:offset_r=0.25"