How to Use FFmpeg avectorscope to Visualize Stereo Audio

This article provides a practical guide on how to use FFmpeg’s avectorscope filter to visualize the stereo field of an audio track. You will learn the basic commands required to convert an audio file into a video containing a vector scope visualization, as well as how to customize the visual output using various filter parameters like display modes, sizes, and colors.

What is avectorscope?

The avectorscope filter in FFmpeg is an audio visualization tool that displays the stereo field (L/X and R/Y coordinates) of an audio signal. It acts as an oscilloscope or goniometer, which is commonly used by audio engineers to monitor phase alignment, stereo width, and channel balance.

Basic Command Syntax

To generate a video visualization from an audio file, you must map the audio input through the avectorscope filter to create a video stream, and then combine that new video stream with the original audio stream into an output file.

Here is the basic command:

ffmpeg -i input.wav -filter_complex "[0:a]avectorscope=s=640x640[v]" -map "[v]" -map 0:a -c:v libx264 -pix_fmt yuv420p -c:a aac output.mp4

Explanation of the Parameters:

Customizing the Visualization

You can customize the appearance of the vector scope using several parameters inside the filter.

1. Visualization Modes (mode or m)

The filter supports different drawing modes: * lissajous (default): Standard oscilloscope Lissajous pattern. * lissajous_xy: Rotated Lissajous pattern where mono signals point straight up. * polar: Semi-circular polar plot representing stereo width and phase.

Example using lissajous_xy:

ffmpeg -i input.wav -filter_complex "[0:a]avectorscope=s=640x640:m=lissajous_xy[v]" -map "[v]" -map 0:a output.mp4

2. Changing Colors (rc, gc, bc)

You can adjust the Red, Green, and Blue contrast values (from 0 to 255) to change the color of the vector scope lines.

Example for a bright green visualization:

ffmpeg -i input.wav -filter_complex "[0:a]avectorscope=s=640x640:rc=0:gc=255:bc=0[v]" -map "[v]" -map 0:a output.mp4

Example for a hot pink/purple visualization:

ffmpeg -i input.wav -filter_complex "[0:a]avectorscope=s=640x640:rc=255:gc=0:bc=150[v]" -map "[v]" -map 0:a output.mp4

3. Adjusting Frame Rate (rate or r)

By default, the output video runs at 25 frames per second. You can increase this to 60 fps for smoother movement.

ffmpeg -i input.wav -filter_complex "[0:a]avectorscope=s=1280x720:r=60[v]" -map "[v]" -map 0:a output.mp4

4. Vector Zoom (zoom)

If the audio level is quiet and the visualization appears too small, you can apply digital amplification using the zoom parameter. The default value is 1.

ffmpeg -i input.wav -filter_complex "[0:a]avectorscope=s=640x640:zoom=2[v]" -map "[v]" -map 0:a output.mp4

5. Drawing Style (draw)

You can change how the points are drawn on the screen: * dot: Draws single dots. * line (default): Draws connected lines for a continuous waveform look.

ffmpeg -i input.wav -filter_complex "[0:a]avectorscope=s=640x640:draw=dot[v]" -map "[v]" -map 0:a output.mp4