How to Use FFmpeg showvolume Filter
This guide explains how to use the showvolume filter in
FFmpeg to generate a real-time, visual volume meter overlay on top of
your video. You will learn the basic command syntax, how to customize
the meter’s appearance—including its size, orientation, and
responsiveness—and how to overlay this visual meter directly onto your
video stream.
The Basic Command Structure
The showvolume filter converts an audio stream into a
visual volume meter video stream. To display this meter on top of your
existing video, you must use FFmpeg’s filter_complex to
generate the meter and then overlay it on your video source.
Here is the standard template command:
ffmpeg -i input.mp4 -filter_complex "[0:a]showvolume=f=0.5:w=400:h=20[volume]; [0:v][volume]overlay=10:10[outv]" -map "[outv]" -map 0:a output.mp4How This Command Works
[0:a]showvolume...[volume]: This takes the audio from the input file (0:a), runs it through theshowvolumefilter, and saves the resulting visual meter stream as a temporary video label named[volume].[0:v][volume]overlay=10:10[outv]: This takes the original input video (0:v) and overlays the newly created[volume]video stream on top of it. The10:10parameters position the meter 10 pixels from the left and 10 pixels from the top of the video frame.-map "[outv]"and-map 0:a: These arguments tell FFmpeg to use the newly generated overlay video and the original unmodified audio for the final output file.
Customizing the Volume Meter
The showvolume filter offers several options to change
the behavior and look of the volume bar. You can add these options
inside the showvolume filter separated by colons (e.g.,
showvolume=option1=value1:option2=value2).
wandh(Width and Height): Sets the dimensions of the volume meter in pixels.- Example:
showvolume=w=600:h=30
- Example:
f(Fade/Decay): Controls how fast the volume meter bar falls back down when the audio gets quieter. The value ranges from0(instant drop) to1(no drop). The default is0.95. A value of0.5offers a highly responsive, fast-moving meter.- Example:
showvolume=f=0.5
- Example:
o(Orientation): Sets the direction of the meter. Usehfor horizontal (default) orvfor vertical.- Example:
showvolume=o=v:w=50:h=300
- Example:
t(Show dB Text): Displays the decibel (dB) text labels on the meter. Set to1to enable (default) or0to disable.- Example:
showvolume=t=0
- Example:
b(Border): Sets the thickness of the border around the meter in pixels. The default is1.- Example:
showvolume=b=3
- Example:
Advanced Example: Vertical Meter on the Right Side
To create a vertical volume meter located on the right side of a 1920x1080 video, you can adjust the orientation and the overlay coordinates:
ffmpeg -i input.mp4 -filter_complex "[0:a]showvolume=o=v:w=30:h=400:f=0.4[volume]; [0:v][volume]overlay=1850:100[outv]" -map "[outv]" -map 0:a output.mp4In this command, o=v changes the meter to a vertical
layout, and overlay=1850:100 positions it near the
top-right corner of a standard 1080p video frame.