Create Circular Waveform Video with FFmpeg

This guide explains how to generate a circular waveform visualization from an audio track using FFmpeg. By utilizing the built-in avectorscope filter in polar mode, you can quickly convert any stereo audio file into a dynamic, circular video visualization perfect for music platforms and social media.

The Basic Command

To create a square-format (1080x1080) video with a circular, green waveform from an audio file, run the following command in your terminal:

ffmpeg -i input.mp3 -filter_complex "[0:a]avectorscope=s=1080x1080:t=polar:m=line:rc=0:gc=255:bc=128[v]" -map "[v]" -map 0:a -c:v libx264 -pix_fmt yuv420p -c:a copy output.mp4

Parameter Breakdown

  • -i input.mp3: Specifies your input audio file (works with MP3, WAV, FLAC, etc.).
  • -filter_complex: Calls FFmpeg's complex filtergraph to process both audio and video streams.
  • avectorscope: The audio vectorscope filter.
    • s=1080x1080: Sets the output video resolution. A 1:1 aspect ratio ensures the polar visualization remains a perfect circle.
    • t=polar: Changes the display type to polar coordinates, which creates the circular shape.
    • m=line: Sets the drawing mode to continuous lines. You can change this to dot for a retro, scattered look.
    • rc=0:gc=255:bc=128: Controls the Red, Green, and Blue color channels (RGB) of the waveform. Adjust these values (0-255) to customize the color.
  • -map "[v]": Maps the generated video stream to the output file.
  • -map 0:a: Maps the original audio from the input file to the output video.
  • -c:v libx264: Encodes the video using the H.264 codec for wide compatibility.
  • -pix_fmt yuv420p: Sets the pixel format to YUV 4:2:0, ensuring the video plays back correctly on standard media players and web browsers.
  • -c:a copy: Copies the audio stream directly without re-encoding to preserve original quality and save processing time.

Customizing the Visualization

You can modify the appearance of the circular waveform by tweaking the avectorscope parameters:

  • Change Colors: Modify the rc (red), gc (green), and bc (blue) values. For example, for a neon pink waveform, use rc=255:gc=0:bc=255.
  • Change Drawing Modes: Replace m=line with m=dot for a matrix-style particle circle, or m=clump for a denser, filled-in visual.
  • Adjust Scale: Add the scale parameter (e.g., scale=sqrt or scale=log) to change how the visualizer responds to audio volume dynamics.