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

6,785

Solution 1

Here's an article about what the wav format spec looks like:

http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html

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

Update:

https://github.com/mbs/wavcheck/releases/tag/0.1

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://shnutils.freeshell.org/shntool/

Update: Since everything in this post was stale for years, I linked to a different article about the wav format, and uploaded the code I wrote and compiled software to github, and updated the link to point to it. Tested the software in Win10 and it does seem to still work on basic LPCM wav files. Doesn't seem like shntool exists at the original link anymore, so I fixed that to point somewhere too, but couldn't tell for sure if it's definitive.

Solution 2

I know this is an old thread, but just in case it is of any use:

The JHOVE tool (which is quite widely used in the archiving / digital libraries domain) includes a WAV module that is able to validate WAV files. Available here:

http://jhove.openpreservation.org/

Don't know how JHOVE's validation compares to the checks that shntool performs.

UPDATE: so after posting my answer I butchered some WAVs myself and then ran them through a number of tools. Full write-up with links to test data and scripts here:

http://openpreservation.org/blog/2017/01/04/breaking-waves-and-some-flacs/

Main outcome: better stick with good old Shntool! JHOVE turns out to be useless for this kind of thing (which was a surprise to me as well). (Incidentally the blog also goes into detecting broken FLAC files, although that was not the question here.)

Solution 3

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:
6,785

Related videos on Youtube

Naidim
Author by

Naidim

The Commodore Amiga was the best 16-bit computer (better than the IBM PC, Apple Macintosh, Atari ST and Apple IIgs). The only computer that rivalled the Amiga was the British 32-bit RISC Acorn Archimedes, which eventually conquered the world, as we all now own devices with ARM chips.

Updated on September 17, 2022

Comments

  • Naidim
    Naidim almost 2 years

    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.

    • Admin
      Admin about 13 years
      Got a broken file that can be tested upon?
    • Admin
      Admin about 13 years
      @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.
    • Admin
      Admin about 13 years
      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?
    • Admin
      Admin about 13 years
      I wonder if there's something in shntool that may be of use?
    • Admin
      Admin over 7 years
      This question belongs to softwarerecs.stackexchange.com - oh but it's too old.
  • CarlF
    CarlF about 13 years
    Of course that isn't what he's asking for ....
  • CarlF
    CarlF about 13 years
    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.
  • Naidim
    Naidim about 13 years
    Thanks for the answers. When I have gone through your suggestions properly, I will reply saying what worked best.
  • Mike Simpson
    Mike Simpson about 13 years
    @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.
  • Matthew Williams
    Matthew Williams over 10 years
    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.
  • sleske
    sleske over 10 years
    I took the liberty of adding a quote from the docs. It looks like this tool might answer the question.
  • Daniel W.
    Daniel W. over 7 years
    Only the last link still works.