Display Audio Levels on Command Line with FFmpeg
Visualizing audio levels directly in the terminal is a powerful way to monitor audio streams, check for clipping, and verify signal presence without launching a heavy graphical user interface. This article explains how to use FFmpeg, the versatile open-source multimedia framework, to display real-time dynamic audio levels and peak meters on the command line using built-in audio filters.
Real-Time Loudness and Peak Metering with EBUR128
The most effective way to display dynamic audio levels in the
terminal is by using FFmpeg’s ebur128 filter. This filter
conforms to the EBU R128 loudness standard and outputs real-time
text-based metrics directly to the command line, including momentary
loudness, short-term loudness, integrated loudness, and true peak
levels.
To analyze an audio file in real time and output the level data to your terminal, run the following command:
ffmpeg -i input.wav -filter_complex ebur128=peak=true -f null -Understanding the Output
As the file plays, FFmpeg will constantly update the terminal screen with lines of text resembling the following:
t: 1.4 M: -18.2 S: -19.5 I: -21.1 LRA: 0.0 FTPK: -5.2 MTPK: -5.2
- t: The current timestamp in seconds.
- M: Momentary loudness (LUFS), integrated over a 400ms sliding window. This represents the immediate, dynamic volume level.
- S: Short-term loudness (LUFS), integrated over a 3-second sliding window.
- I: Integrated loudness (LUFS) from the start of the playback.
- FTPK: True Peak (dBFS) measured for the current frame. This acts as your dynamic peak meter.
- MTPK: Maximum True Peak (dBFS) encountered since the start of playback.
Live Audio Input Monitoring
If you want to monitor a live audio input (such as a microphone or system loopback) in real time, you can replace the input file with your system’s audio device driver.
For Linux (ALSA):
ffmpeg -f alsa -i default -filter_complex ebur128=peak=true -f null -For macOS (AVFoundation):
ffmpeg -f avfoundation -i ":0" -filter_complex ebur128=peak=true -f null -For Windows (dshow):
ffmpeg -f dshow -i audio="Your Microphone Name" -filter_complex ebur128=peak=true -f null -Displaying Peak Levels via the Astats Filter
If you do not need a continuous, frame-by-frame stream but instead
want a quick terminal printout of the peak levels, dynamic range, and
overall audio statistics, use the astats filter.
Run the following command:
ffmpeg -i input.wav -filter:a astats -f null -FFmpeg will process the file at maximum speed and output a detailed text summary of both channels (or more) to your terminal. Look for the following fields in the console output to find your peak values:
- Peak level dB: The highest absolute amplitude level reached.
- RMS level dB: The average root-mean-square amplitude level (representing perceived volume).
- Crest factor: The difference between the peak and RMS levels, showing dynamic range.