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

Breakdown of the Command Options

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

In 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.mp4

This configuration creates a solid green wave pattern that mimics traditional graphic equalizers.