Play Audio with Real-Time Waveform using FFplay

This guide explains how to use FFplay, the command-line media player included with the FFmpeg suite, to play audio files while displaying a real-time visual waveform. You will learn the exact commands and parameters required to enable, customize, and control this visualization directly from your terminal.

The Basic Command for Waveform Visualization

FFplay has a built-in feature designed specifically for rendering audio visualizations. To play an audio file and display its real-time waveform, use the -showmode option set to 1.

Run the following command in your terminal:

ffplay -showmode 1 input.mp3

Customizing the Playback Window

By default, FFplay will open a small window to display the waveform. You can customize the dimensions of this window using the -x (width) and -y (height) flags.

To launch a waveform window that is 800 pixels wide and 400 pixels high, use:

ffplay -showmode 1 -x 800 -y 400 input.mp3

Alternative Visualization: Frequency Spectrum

If you want to analyze the audio frequencies rather than the amplitude waveform, you can switch the showmode to frequency bands. Setting the mode to 2 displays a real-time RDFT (Real Discrete Fourier Transform) spread.

ffplay -showmode 2 input.mp3

Keyboard Controls During Playback

While the waveform window is active, you can control playback using your keyboard: