Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
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
add comment

2 Answers

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/

share|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
add comment

Ripcheck is a utility that does this.

Quoting the docs:

"ripcheck" runs a variety of tests on a WAV file, to see if there are potential mistakes that occurred in converting a CD to a WAV file.

[...]

WHY?

This program was written because we'd received some complaints of occasional "pops" at the beginning on some albums at Magnatune. Further research found that most of the albums we released in 2007 had various CD ripping problems. We also found various CDRs burned by our musicians that had small defects in them, probably due to cheap CDR media being used, or the CDR being burnt too quickly.

[...]

share|improve this answer
    
Could you refrain from simply providing a link. Please provide some substance to your link such as how it will answer the OP, have you used it before, what are the key features etc. –  Matthew Williams Feb 28 at 8:31
    
I took the liberty of adding a quote from the docs. It looks like this tool might answer the question. –  sleske Feb 28 at 8:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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