Creating Audio Waveform Videos with FFmpeg on Linux
This guide provides a straightforward walkthrough on how to convert an audio file into a visually engaging waveform video using FFmpeg on Linux. You will learn the exact commands needed to generate different visualization styles, adjust video resolutions, and combine the visual output with your original audio. Whether you are a podcaster, musician, or content creator, these steps will help you transform your sound files into shareable video content directly from the command line.
Understanding the FFmpeg Waveform Visualizer
FFmpeg features a powerful built-in multimedia filter called
showwaves. This filter samples the incoming audio stream
and generates a video frame representing the audio amplitude over time.
To create a complete video file, you must pair the visual generator with
your audio source and specify a video encoder.
The Basic Waveform Command
To create a standard, no-frills waveform video with a resolution of 1920x1080 (1080p) at 30 frames per second, use the following command structure:
ffmpeg -i input.mp3 -filter_complex "[0:a]showwaves=s=1920x1080:mode=line:r=30[v]" -map "[v]" -map 0:a -c:v libx264 -c:a copy output.mp4Breakdown of the Command Options
-i input.mp3: Specifies your source audio file.-filter_complex: Calls FFmpeg’s advanced filtering graph.[0:a]: Takes the first input’s audio stream as the source for the filter.showwaves=...: Configures the visualization filter.s=1920x1080: Sets the output video resolution.mode=line: Draws the waveform as continuous lines (alternative options includepointorp2p).r=30: Sets the video frame rate to 30 frames per second.[v]: Names the resulting video stream output from the filter.-map "[v]": Instructs FFmpeg to include the generated video stream in the final file.-map 0:a: Instructs FFmpeg to map the original audio stream into the final file.-c:v libx264: Encodes the video using the widely compatible H.264 codec.-c:a copy: Copies the original audio directly without re-encoding, preserving its quality and saving processing time.
Customizing the Waveform Visuals
You can modify the appearance of the waveform by adding color, thickness, and background changes directly inside the filter string.
Changing Waveform Color and Background
By default, FFmpeg draws a red waveform on a black background. You can customize the waveform color using hexadecimal codes or standard color names, and you can change the background opacity.
ffmpeg -i input.mp3 -filter_complex "[0:a]showwaves=s=1280x720:mode=line:colors=cyan:scale=sqrt[v]" -map "[v]" -map 0:a -c:v libx264 -c:a copy output.mp4In this variation, colors=cyan changes the waveform line
color, and scale=sqrt adjusts the drawing scale to make
quiet parts of the audio more visible.
Creating a Solid Fill Waveform
If you prefer a solid, filled-in bar visualization rather than a
single line, switch the mode from line to p2p
(point-to-point):
ffmpeg -i input.mp3 -filter_complex "[0:a]showwaves=s=1920x1080:mode=p2p:colors=0x00FF00[v]" -map "[v]" -map 0:a -c:v libx264 -c:a copy output.mp4This configuration creates a solid green wave pattern that mimics traditional graphic equalizers.