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.mp4

In 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:

  1. 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.
  2. 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.
  3. 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.mp4

Key Parameters of avectorscope

You can fine-tune the visualization using several optional parameters:

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.mp4

This command outputs a smooth, high-frame-rate video where the stereo movement leaves a glowing, aesthetic trail on the screen.