Note that there are some explanatory texts on larger screens.

plurals
  1. POCalculate checksum of audio files without considering the header
    primarykey
    data
    text
    <p>I want to programmatically create a SHA1 checksum of audio files (MP3, Ogg Vorbis, Flac). The requirement is that the checksum should be stable <strong>even if the header (eg. ID3) changes</strong>.<br/> <em>Note: The audio files don't have CRCs</em></p> <p>This is what I tried by now:</p> <h3>1) Reading + Hashing all MPEG frames using Perl and <a href="http://search.cpan.org/dist/MPEG::Audio::Frame/" rel="nofollow noreferrer">MPEG::Audio::Frame</a></h3> <pre><code>my $sha1 = Digest::SHA1-&gt;new; while (my $frame = MPEG::Audio::Frame-&gt;read(\*FH)) { $sha1-&gt;add($frame-&gt;content()); } </code></pre> <h3>2) Decoding + Hashing all MPEG frames using Python and <a href="http://spacepants.org/src/pymad/" rel="nofollow noreferrer">libmad (pymad)</a></h3> <pre><code>mf = mad.MadFile(path) sha1 = hashlib.sha1() while 1: buf = mf.read() if (buf is None): break sha1.update(buf) </code></pre> <h3>3) Using <a href="http://tomclegg.net/mp3cat" rel="nofollow noreferrer">mp3cat</a></h3> <pre><code>&gt; mp3cat - - &lt; file.mp3 | sha1sum </code></pre> <p>However, none of those methods provided a <strong>stable</strong> checksum. Namely, in <em>some</em> cases the checksum changed after retagging the file with <a href="http://musicbrainz.org/doc/PicardTagger" rel="nofollow noreferrer">picard</a>.</p> <p>Are there any libraries that already provide what I want?<br/> I don't care about the programming language… </p> <p><b>Update:</b> I debugged the case a bit further. The libmad checksum inconsitency seems to happen in cases where libmad gets some decoding errors, like <em>"Huffman data overrun (0x0238)"</em>. As this really happens on many of the mp3 files I'm not sure if it really indicates a broken file…</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload