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

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.png

Changing 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.png

Hex Color Example (e.g., #3498db Blue)

ffmpeg -i input.mp3 -filter_complex "showwavespic=s=1024x300:colors=#3498db" -frames:v 1 output.png

Multi-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.png

Adjusting 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.png

Amplitude 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