How to Use FFmpeg showvolume for Audio Visualization

This guide covers how to use the FFmpeg showvolume filter to render dynamic visual audio meters directly from an audio source. You will learn the core command structure to generate standalone meter videos, how to superimpose meters onto existing video tracks, and how to modify display parameters such as orientation, color modes, fade speeds, and decibel values.

Basic Usage: Standalone Volume Meter

The showvolume filter is an audio-to-video filter. To turn an audio file into a standalone video featuring a volume bar, use -filter_complex:

ffmpeg -i input.mp3 -filter_complex "[0:a]showvolume=w=600:h=40[v]" -map "[v]" -map 0:a -c:v libx264 -c:a aac output.mp4

In this command:

  • [0:a]showvolume=w=600:h=40[v] takes the primary audio stream, generates a volume bar 600 pixels wide and 40 pixels high, and labels the resulting video stream as [v].
  • -map "[v]" and -map 0:a bundle the newly created visualization with the original audio track.

Overlaying the Volume Meter onto a Video

To place the volume meter on top of a video stream (such as a podcast recording or gameplay footage), combine showvolume with the overlay filter:

ffmpeg -i input.mp4 -filter_complex "[0:a]showvolume=w=400:h=30:b=4[meter];[0:v][meter]overlay=x=20:y=20[v]" -map "[v]" -map 0:a -c:a copy output.mp4

This pipeline generates the meter, applies a 4-pixel border (b=4), and positions it 20 pixels from the top-left corner of the input video (overlay=x=20:y=20).

Key Configuration Parameters

The showvolume filter includes multiple options to refine the look and behavior of the meter:

  • Orientation (o): Accepts h (horizontal, default) or v (vertical).
  • Dimensions (w and h): Sets width and height in pixels. For vertical meters, w controls thickness while h controls height.
  • Fade (f): Adjusts the decay/fall-off speed of the meter. Values range between 0.0 and 1.0. A lower value (such as 0.1) makes the bar fall faster, while higher values make the decay smoother.
  • Color Mode (c): Defines the color scheme. Common options include:
    • channel: Assigns different default colors to each audio channel.
    • A custom color expression (e.g., c=PEAK or custom RGBA hex values).
  • Text / dB Scale (t): Displays decibel labels and scale markers. Set to 1 (or true) to show text labels, or 0 to disable them.
  • Display Mode (dm): Configures what the meter tracks:
    • p: Peak volume (default).
    • r: RMS (Root Mean Square) volume.

Advanced Customization Example

To create a transparent, vertical stereo meter with custom colors and decibel text enabled:

ffmpeg -i input.mp4 -filter_complex \
"[0:a]showvolume=o=v:w=30:h=400:f=0.8:t=1:c=volume:b=2[meter]; \
 [0:v][meter]overlay=W-w-20:H-h-20[outv]" \
-map "[outv]" -map 0:a -c:a copy output.mp4
  • o=v: Sets the orientation to vertical.
  • w=30:h=400: Creates a tall, narrow bar suitable for vertical display.
  • f=0.8: Gives the meters a gradual decay rate.
  • t=1: Displays numerical decibel indicators along the meter.
  • c=volume: Colors the meter green at safe levels, changing to yellow and red near peak levels.
  • overlay=W-w-20:H-h-20: Positions the meter 20 pixels away from the bottom-right corner of the video frame.