How to Use FFmpeg showvolume to Overlay a Volume Meter

This article provides a step-by-step guide on how to use the FFmpeg showvolume filter to overlay a real-time audio volume meter onto a video. You will learn the exact command syntax, how the filter processing pipeline works, and how to customize the volume meter's size, orientation, colors, and positioning.

The Basic Command

To overlay a volume meter, you must use FFmpeg's complex filtergraph (-filter_complex). This is because the process requires taking the audio track, converting it into a visual volume meter stream, and then overlaying that stream back onto the original video track.

Here is the fundamental command to achieve this:

ffmpeg -i input.mp4 -filter_complex "[0:a]showvolume=w=400:h=30[volume];[0:v][volume]overlay=10:10[out]" -map "[out]" -map 0:a -c:a copy output.mp4

Command Breakdown

  • [0:a]showvolume=w=400:h=30[volume]: This takes the audio stream from the first input ([0:a]), sends it to the showvolume filter, and sets the meter width to 400 pixels and height to 30 pixels. The resulting video stream is labeled [volume].
  • [0:v][volume]overlay=10:10[out]: This takes the original video stream ([0:v]) and overlays the generated [volume] video stream on top of it. The coordinates 10:10 position the meter 10 pixels from the top-left corner. The output stream is labeled [out].
  • -map "[out]": Instructs FFmpeg to use the newly created video stream with the overlaid meter.
  • -map 0:a -c:a copy: Copies the original audio stream directly into the output file without re-encoding it.

Customizing the Volume Meter

The showvolume filter offers several parameters to change how the meter looks and behaves.

1. Change Orientation to Vertical

By default, the meter is horizontal. You can change it to vertical by setting the orientation option (o) to v and swapping the width and height values.

ffmpeg -i input.mp4 -filter_complex "[0:a]showvolume=w=40:h=300:o=v[volume];[0:v][volume]overlay=10:10[out]" -map "[out]" -map 0:a -c:a copy output.mp4

2. Position the Meter on the Screen

You can change the overlay coordinates to place the volume meter anywhere on the video player canvas:

  • Bottom-Right Corner: overlay=W-w-10:H-h-10
  • Top-Right Corner: overlay=W-w-10:10
  • Bottom Center: overlay=(W-w)/2:H-h-10

3. Adjust the Meter's Physics and Decay

You can control how fast the meter drops after a volume peak using the fade option (f). The value ranges from 0 to 1 (default is 0.95). A lower value makes the meter more responsive, while a higher value makes the falloff smoother.

ffmpeg -i input.mp4 -filter_complex "[0:a]showvolume=f=0.9[volume];[0:v][volume]overlay=10:10[out]" -map "[out]" -map 0:a -c:a copy output.mp4

4. Hide the Decibel (dB) Text

By default, the volume meter displays decibel numbers. You can disable this text overlay by setting t=0.

ffmpeg -i input.mp4 -filter_complex "[0:a]showvolume=t=0[volume];[0:v][volume]overlay=10:10[out]" -map "[out]" -map 0:a -c:a copy output.mp4