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.mp3ffplay: Invokes the media player.-showmode 1: Instructs FFplay to display a visual waveform of the audio.input.mp3: The path to your audio file (works with MP3, WAV, FLAC, OGG, and other FFmpeg-supported formats).
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.mp3Alternative 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.mp3Keyboard Controls During Playback
While the waveform window is active, you can control playback using your keyboard:
- Spacebar: Pause and resume the audio playback.
- Left/Right Arrow Keys: Seek backward/forward by 10 seconds.
- Up/Down Arrow Keys: Seek backward/forward by 1 minute.
- Escape / Q: Quit FFplay and close the window.