FFmpeg Showwaves: Create Video from Audio
This guide explains how to convert an audio file into a video
waveform using FFmpeg's built-in showwaves filter. You will
learn the basic command structure, the key parameters available for
customizing the visual style (including dimensions, rendering modes,
colors, and framerates), and practical examples for generating
standalone visualizers or overlaying waveforms on background images.
Basic Syntax and Core Command
The showwaves audio filter converts audio input into a
video stream representing the waveform. The most straightforward command
takes an audio file, generates the waveform video, and combines it with
the original audio stream into an MP4 container.
ffmpeg -i input.mp3 -filter_complex "[0:a]showwaves=s=1280x720:mode=line:r=30[v]" -map "[v]" -map 0:a -c:v libx264 -pix_fmt yuv420p -c:a copy output.mp4In this command:
-i input.mp3: Specifies the input audio source.-filter_complex: Invokes the filter graph.[0:a]showwaves=...[v]: Takes the first audio stream, converts it to video labeled[v].-map "[v]" -map 0:a: Ensures both the newly created video stream and the original audio stream are included in the output.-c:v libx264 -pix_fmt yuv420p: Encodes the video to H.264 using standard pixel formatting for maximum playback compatibility.-c:a copy: Copies the audio stream without re-encoding.
Key showwaves
Parameters
You can adjust several options within the filter to customize the output:
sizeors: Sets the video resolution (e.g.,s=1920x1080). The default is600x240.mode: Defines how the waveform samples are drawn:point: Draws individual sample points.line: Draws continuous lines connecting consecutive samples (default).p2p: Draws point-to-point lines between samples.cline: Draws centered lines from the middle axis to the peak, creating a traditional audio visualizer look.
rorrate: Sets the output video frame rate (e.g.,r=25,r=60). The default is 25 fps.colors: Sets the color of the waveform. You can specify named colors (such aswhite,red,cyan) or hexadecimal values (e.g.,0x00FF00or#FF0055). Multiple channels can have distinct colors separated by|(e.g.,colors=red|blue).scale: Defines the amplitude scaling method. Options includelin(linear, default),log(logarithmic),sqrt(square root), andcbrt(cubic root).
Practical Examples
Centered Waveform with Custom Colors
To create a 1080p, 60fps video with a centered waveform style and custom coloration:
ffmpeg -i input.wav -filter_complex "[0:a]showwaves=s=1920x1080:mode=cline:r=60:colors=#00FFAA:scale=cbrt[v]" -map "[v]" -map 0:a -c:v libx264 -pix_fmt yuv420p -c:a aac output.mp4Overlaying a Waveform onto a Background Image
To place a transparent waveform on top of a static background image,
generate the waveform with transparency and use the overlay
filter:
ffmpeg -loop 1 -i background.jpg -i input.mp3 -filter_complex "[1:a]showwaves=s=1280x300:mode=cline:r=30:colors=white[wave];[0:v][wave]overlay=(W-w)/2:(H-h)/2:shortest=1[v]" -map "[v]" -map 1:a -c:v libx264 -pix_fmt yuv420p -c:a copy output.mp4In this setup:
-loop 1 -i background.jpg: Loops the background image indefinitely.overlay=(W-w)/2:(H-h)/2: Centers the 1280x300 waveform over the background image.shortest=1: Stops encoding when the audio stream ends.