How to Use FFmpeg apulsator for Audio Auto-Pan
This guide explains how to use the FFmpeg apulsator
filter to create a dynamic auto-pan effect that automatically sweeps
audio back and forth between the left and right channels. You will learn
the basic syntax of the filter, understand its key parameters like
frequency and depth, and see practical command-line examples to apply
this spatial audio effect to your audio or video files.
Understanding the apulsator Filter
The apulsator filter is an audio modulation tool in
FFmpeg that uses a Low-Frequency Oscillator (LFO) to modulate the volume
of the left and right channels out of phase. This phase offset creates
the psychoacoustic perception of the sound physically moving from left
to right and back again.
Key Parameters
To customize the auto-pan effect, you can adjust several parameters within the filter:
hz: Defines the frequency of the panning oscillation in Hertz (Hz). This controls the speed of the sweep. For example, a value of0.5means one full cycle (left to right and back) takes 2 seconds. The default is2.amount: Controls the modulation depth, ranging from0.0(no panning) to1.0(maximum panning, shifting completely to one side). The default is1.0.offset_landoffset_r: Sets the left and right channel phase offsets (from0.0to1.0). By default,offset_lis0.0andoffset_ris0.5, which keeps them perfectly out of phase to create the stereo panning motion.timing: Defines the shape of the LFO waveform. Options includesine,triangle,square,sawup, orsawdown. The default issine, which provides a smooth, natural transition.triangleprovides a linear sweep.width: Specifies the stereo width of the output signal (from0.0to1.0). The default is1.0.
Practical Examples
To apply the filter, use the -af (audio filter) flag in
your FFmpeg command.
1. Basic Auto-Pan Effect
This command applies a standard auto-pan effect using the default settings (a smooth sine wave at a speed of 2 Hz):
ffmpeg -i input.mp3 -af "apulsator" output.mp32. Slow and Subtle Panning
For a slower, gentler transition that does not fully mute either
channel, lower the frequency (hz) and decrease the
modulation depth (amount):
ffmpeg -i input.mp3 -af "apulsator=hz=0.5:amount=0.7" output.mp3In this example, the sound takes 2 seconds to pan from one side to the other, and the depth is capped at 70% to prevent hard-panning.
3. Linear “Ping-Pong” Panning
To make the audio sweep back and forth at a constant, linear speed
rather than a smooth curve, change the LFO wave shape to
triangle:
ffmpeg -i input.mp3 -af "apulsator=hz=1:timing=triangle" output.mp34. Applying to Video Files
You can also apply this effect directly to the audio track of a video file while keeping the original video stream intact without re-encoding it:
ffmpeg -i input.mp4 -af "apulsator=hz=1" -c:v copy output.mp4