Looking for a Linux or Windows command line .WAV file checker

command linevalidationwav

I am trying to find a command line program (Windows or Linux) that can check .WAV files, to see if they are complete, with no corruption or sudden endings.

While I have found several programs that can do this with .mp3 files, I cannot find anything that can do it with .WAV files, apart from a couple of commerical Windows programs that only use a GUI and so cannot be used in scripts.

Best Answer

Here's an article about what a PCM wav file should look like:

https://ccrma.stanford.edu/courses/422/projects/WaveFormat/

Should be able to write a little script of some kind to check out the headers and make sure they look OK.

Update:

http://www.sendspace.com/file/cdy1hk

Here's a small utility that may suit your need. It checks the file, outputs some information on the file, and exits. The return code is 0 if successful, nonzero if there's a problem with the file.

It is written in Python and depends on the Python wave library. You can extract the .py file from the zip and examine/run independently, or use the compiled exe along with the support files included.

Seems to work OK for e.g. files output by lame --decode, and catches when I truncate a WAV (checks to make sure the file size is sane).

There is no way to determine if the PCM data has been corrupted without e.g. external checksums, etc.

Update:

Added a bit better error checking. Compiled exe version freaks out when wavcheck.py is in the same folder, so I stuck it in a subfolder (/src). Lol. Updated link above to new file.

Update:

I took a look at shntool as suggested by @boehj -- looks like good software for checking WAV files, and it has nice detailed output. Its output could be trivially parsed or its source code modified to allow for an all-OK exit status in 'info' and/or 'len' mode. As it stands, it has exit code 0 even when it is reporting problems with the file.

Homepage for shntool: http://www.etree.org/shnutils/shntool/

Related Question