Generate Audio Waveform PNG with FFmpeg showwavespic
This article provides a quick, step-by-step guide on how to use the
FFmpeg showwavespic filter to convert any audio file into a
static PNG waveform image. You will learn the basic command line syntax,
how to customize the output image dimensions, and how to change the
waveform’s colors and visual style to suit your project needs.
The Basic Command
To generate a simple waveform image from an audio file, use the
showwavespic filter. This filter analyzes the entire audio
file and outputs a single image frame.
Run the following command in your terminal:
ffmpeg -i input.mp3 -filter_complex "showwavespic" -frames:v 1 output.png-i input.mp3: Specifies your input audio file (supports MP3, WAV, FLAC, M4A, etc.).-filter_complex "showwavespic": Calls the waveform generator filter.-frames:v 1: Tells FFmpeg to output only a single video frame as an image.output.png: The path and name of the resulting PNG image.
Customizing Size and Resolution
By default, FFmpeg outputs a predefined image size. You can specify
custom dimensions using the s (size) option. The format is
widthxheight.
To generate a waveform that is 1200 pixels wide and 400 pixels high, use:
ffmpeg -i input.mp3 -filter_complex "showwavespic=s=1200x400" -frames:v 1 output.pngChanging Waveform Colors
You can customize the color of the waveform using hex color codes or
standard web color names. The colors parameter accepts
single colors or multiple colors separated by a pipe (|)
character for multi-channel audio.
Single Color Example (Green)
ffmpeg -i input.mp3 -filter_complex "showwavespic=s=1024x300:colors=green" -frames:v 1 output.pngHex Color Example (e.g.,
#3498db Blue)
ffmpeg -i input.mp3 -filter_complex "showwavespic=s=1024x300:colors=#3498db" -frames:v 1 output.pngMulti-Channel / Stereo Colors (Left channel Red, Right channel Blue)
ffmpeg -i input.mp3 -filter_complex "showwavespic=s=1024x300:colors=red|blue" -frames:v 1 output.pngAdjusting Waveform Appearance
The showwavespic filter offers additional options to
change how the audio waves are drawn and scaled.
Draw Mode (draw)
You can change the drawing style using the draw option.
The available values are: * scale: Draws
symmetric waves (default). * filled: Draws
solid, filled-in blocks.
ffmpeg -i input.mp3 -filter_complex "showwavespic=s=1024x300:draw=filled" -frames:v 1 output.pngAmplitude Scaling
(scale)
To change how the audio amplitude is scaled visually, use the
scale option. This is helpful for quiet audio tracks. *
lin: Linear scale (default). *
log: Logarithmic scale (amplifies quieter
parts of the audio visually).
ffmpeg -i input.mp3 -filter_complex "showwavespic=s=1024x300:scale=log" -frames:v 1 output.png