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.

link|improve this question

77% accept rate
1  
Got a broken file that can be tested upon? – Ignacio Vazquez-Abrams May 5 '11 at 17:28
@Ignacio: I have some, but it will take some time for me to find them out of thousands of files, which is why I need this in the first place. I'll get back to you if I find one. – paradroid May 5 '11 at 18:42
You could probably just use dd to cut one short, say the first few tens of kilobytes from a multi-megabyte file. Also, are they all PCM, or do they use other encodings as well? – Ignacio Vazquez-Abrams May 5 '11 at 18:45
1  
I wonder if there's something in shntool that may be of use? – boehj May 6 '11 at 18:24
feedback

1 Answer

up vote 6 down vote accepted
+100

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/

link|improve this answer
1  
Of course that isn't what he's asking for .... – CarlF May 5 '11 at 20:00
He was looking for something to detect cut-off (damaged, e.g. partially copied) files. Do WAV headers actually encode the file's size? I do not believe so but am willing to be corrected. – CarlF May 6 '11 at 12:10
1  
OK, +1 because when I actually followed your link (in the answer itself) it did show exactly what you say it should. My apologies. – CarlF May 6 '11 at 17:47
Thanks for the answers. When I have gone through your suggestions properly, I will reply saying what worked best. – paradroid May 12 '11 at 11:41
@paradroid I also submitted a feature request to the devs of shntool to add a new 'check' mode with exit status set. No response, so dunno how fruitful that'll be. – Mike Simpson May 12 '11 at 20:43
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.