What You’ll Learn
- How to measure audio statistics with the
astatsfilter - How to interpret RMS, peak, DC offset, and dynamic range values
- How to collect per-channel statistics
- When to choose
astatsovervolumedetect - How to build an audio quality check workflow from these measurements
Tested with: FFmpeg 6.1
Platform: Windows / macOS / Linux
What is the astats Filter?
astats is a filter that prints a wide range of statistics about an audio stream to the console. In a single pass it reports RMS, peak level, DC offset, dynamic range, and clipping indicators — enough for a full first-look diagnostic.
Basic Usage
Print audio statistics for a video file
ffmpeg -i input.mp4 -af "astats" -f null /dev/null
The report is written to stderr, just like FFmpeg’s regular log output.
Audio file statistics
ffmpeg -i input.mp3 -af "astats" -f null /dev/null
Reading the Output
A typical run produces output like this:
[Parsed_astats_0 @ ...] Channel: 1
[Parsed_astats_0 @ ...] DC offset: 0.000002
[Parsed_astats_0 @ ...] Min level: -0.999969
[Parsed_astats_0 @ ...] Max level: 0.999939
[Parsed_astats_0 @ ...] Peak level dB: -0.000263
[Parsed_astats_0 @ ...] RMS level dB: -17.834118
[Parsed_astats_0 @ ...] RMS peak dB: -12.456
[Parsed_astats_0 @ ...] RMS trough dB: -40.123
[Parsed_astats_0 @ ...] Crest factor: 32.789
[Parsed_astats_0 @ ...] Flat factor: 0.000000
[Parsed_astats_0 @ ...] Peak count: 0
[Parsed_astats_0 @ ...] Noise floor dB: -90.234
[Parsed_astats_0 @ ...] Dynamic range: 72.400
...
[Parsed_astats_0 @ ...] Overall
| Field | Meaning |
|---|---|
DC offset | DC offset (closer to 0 is better) |
Peak level dB | Highest instantaneous peak (dBFS) |
RMS level dB | Overall average RMS level (dBFS) |
RMS peak dB | Maximum RMS level |
RMS trough dB | Minimum RMS level |
Crest factor | Crest factor (peak-to-RMS ratio) |
Flat factor | Share of consecutive identical samples (useful for clipping detection) |
Peak count | Number of clipped samples |
Dynamic range | Dynamic range (dB) |
Filtering Which Measurements Are Reported
Use measure_perchannel and measure_overall to pick which fields to print.
Show RMS and peak level only
ffmpeg -i input.mp4 -af "astats=measure_perchannel=RMS_level+Peak_level" -f null /dev/null
Overall statistics only (skip per-channel)
ffmpeg -i input.mp4 -af "astats=measure_perchannel=0" -f null /dev/null
Emitting Results as Metadata
With metadata=1, per-frame statistics are attached as frame metadata, which can then be printed with the ametadata filter:
ffmpeg -i input.mp4 -af "astats=metadata=1,ametadata=print:file=-" -f null /dev/null 2>&1 | head -50
Segment-by-Segment Statistics (reset Parameter)
Use the reset parameter to reset and emit statistics every N samples:
ffmpeg -i input.mp4 -af "astats=reset=44100" -f null /dev/null
At 44.1 kHz, 44,100 samples is roughly one second, so this prints a fresh snapshot every second. Useful when you want to see how loudness changes over time.
astats vs. volumedetect
| Filter | Primary use | Output |
|---|---|---|
astats | Detailed audio quality diagnosis | RMS, peak, DC offset, dynamic range, and more |
volumedetect | Quick volume sanity check | mean_volume, max_volume, histogram |
Use volumedetect when you just need a fast look at loudness, and astats when you need a thorough quality check:
ffmpeg -i input.mp4 -af "volumedetect" -f null /dev/null
Detecting Clipping
If Peak count is greater than 0 or Flat factor is high, the audio is likely clipping:
ffmpeg -i input.mp4 -af "astats=measure_perchannel=Peak_count+Flat_factor" -f null /dev/null
When clipping is detected, lower the level with the volume filter or fix the gain at the source.
Checking and Fixing DC Offset
A large DC offset can be removed with the highpass filter:
ffmpeg -i input.mp4 -af "highpass=f=10" output.mp4
Confirm the DC offset with astats before applying the fix.
Audio Quality Check Workflow
- Run
astatsto inspect RMS, peak, DC offset, and clipping - If clipping is present, reduce the level with the
volumefilter - If DC offset is large, remove it with the
highpassfilter - If RMS is uneven across the material, normalize with the
loudnormfilter
Frequently Asked Questions
What is the difference between astats and ebur128?
astats reports peak/RMS/DC/crest factor frame-by-frame, while ebur128 measures broadcast-standard loudness (LUFS). Use astats for waveform diagnostics and ebur128 for delivery loudness targets.
How do I get only the peak level?
Filter the metadata output: ffprobe -f lavfi -i "amovie=in.wav,astats=metadata=1:reset=0" -show_entries frame_tags=lavfi.astats.Overall.Peak_level -of csv=p=0.
Can astats detect silence?
Indirectly — when RMS drops below your threshold (e.g. -60 dB) the segment is silent. For a true silence detector use the silencedetect filter instead.
Why does astats report different numbers per channel?
It analyses each channel independently. A stereo file with content only on the left channel will show -inf dB peak on the right. Add metadata=mode=single to get an aggregated value.
Can I run astats on a video file?
Yes — FFmpeg auto-extracts the audio stream. For a multi-track video, select the stream explicitly with -map 0:a:0.
Related Articles
- Volume Detection and Adjustment (volumedetect / volume)
- Loudness Normalization (loudnorm / LUFS)
- Reading Video and Audio Metadata with ffprobe
Tested with ffmpeg 6.1 / Ubuntu 24.04 (GitHub Actions runner)
Primary source: ffmpeg.org/ffmpeg-filters.html#astats