Visualize Stereo Field with FFmpeg avectorscope
This article provides a practical guide on how to use the FFmpeg
avectorscope filter to visualize the stereo field of an
audio file. You will learn how to convert stereo audio into a visual
Lissajous or polar plot video, understand the key parameters of the
filter, and run command-line examples to analyze your audio’s phase and
stereo width.
The avectorscope filter in FFmpeg is a visual tool used
for audio analysis. It plots the left and right channels of a stereo
audio signal against each other, creating a goniometer or vectorscope
display. This visualization helps audio engineers and video editors
identify phase issues, monitor stereo balance, and observe the overall
width of the stereo field.
Basic Command to Create a Video
To convert an audio file into a video showcasing its stereo field, use the following basic command:
ffmpeg -i input.mp3 -filter_complex "[0:a]avectorscope=s=640x640:m=lissajous[v]" -map "[v]" -map 0:a output.mp4In this command: - -i input.mp3 specifies your input
audio file. - -filter_complex applies the
avectorscope filter to the audio input [0:a].
- s=640x640 sets the output video resolution to 640x640
pixels. - m=lissajous sets the visualization mode. -
-map "[v]" and -map 0:a map both the generated
video and the original audio to the output file
output.mp4.
Customizing the Visualization Modes
The avectorscope filter supports different drawing modes
via the mode (or m) parameter:
- Lissajous (
m=lissajous): The classic oscilloscope view where mono signals appear as a vertical line, and out-of-phase signals appear horizontally. This is the default mode. - Lissajous XY (
m=lissajous_xy): Similar to the Lissajous mode, but rotated 45 degrees. Mono signals appear as a diagonal line from bottom-left to top-right. - Polar (
m=polar): Plots the stereo signal in polar coordinates, displaying the angle (representing stereo balance) and radius (representing amplitude).
To use the polar mode, run:
ffmpeg -i input.wav -filter_complex "[0:a]avectorscope=s=800x800:m=polar[v]" -map "[v]" -map 0:a output.mp4Key Parameters of avectorscope
You can fine-tune the visualization using several optional parameters:
size/s: Sets the video size (e.g.,1280x720).rate/r: Adjusts the frame rate of the output video. The default is 25 fps.zoom/z: Multiplies the input signal amplitude to zoom in on quieter audio (default is 1).rc,gc,bc: Control the red, green, and blue contrast decay factors to create a phosphor-like trailing effect. Lower values (e.g.,10) create longer trails, while higher values (e.g.,255) eliminate trails.
Here is an example that increases the frame rate to 60 fps and adds a persistent trail effect:
ffmpeg -i input.wav -filter_complex "[0:a]avectorscope=s=1280x720:m=lissajous_xy:r=60:rc=15:gc=15:bc=20[v]" -map "[v]" -map 0:a output.mp4This command outputs a smooth, high-frame-rate video where the stereo movement leaves a glowing, aesthetic trail on the screen.