Introspect Audio Files

By Niklas Adam (na@notam.no) • 2 minutes read

Table of Contents

Debug audio file issues

The go-to is ffmpeg (via ffprobe or a decode-to-null pass), since it'll parse almost any format and complain loudly about anything malformed.

To check the header and container structure, ffprobe reads the metadata and reports parse errors:

ffprobe -v error -show_format -show_streams file.wav

If the header is broken, you'll see errors like "Invalid data found when processing input" or missing or garbage stream info.

To check the actual audio data, decode the whole file and throw the output away. This catches corruption in the middle of the file that a header check would miss:

ffmpeg -v error -i file.flac -f null -

No output means it decoded cleanly. Anything printed (e.g. "Header missing", "invalid frame", "overread") points to damage, often with a timestamp.

There are also some format-specific tools that are more thorough for their format:

FLAC: flac -t file.flac verifies the embedded MD5 checksum, so it's close to definitive.
WAV/AIFF and general: sox --i file.wav shows header info, and soxi or sox file.wav -n stat will choke on bad data.
Ogg/Vorbis/Opus: ogginfo file.ogg reports stream and page errors.
MP3: mp3val file.mp3 finds (and can fix) broken frames and bad headers. mpck (checkmate) is similar.
Metadata/tags: mediainfo or exiftool are good for spotting inconsistent headers, like a stated duration or size that doesn't match the file.

For inspecting the raw bytes yourself, xxd file.wav | head lets you eyeball the magic bytes (RIFF/WAVE, ID3, fLaC, OggS, etc.).

If you just want one tool, ffmpeg -v error -i file -f null - is the best all-rounder. It's also easy to loop over a whole folder, e.g.

for f in *.wav; do echo "$f"; ffmpeg -v error -i "$f" -f null -; done