[mad-dev] test if file is mp3
Thu, 7 Nov 2002 08:52:21 -0800 (PST)
-----BEGIN PGP SIGNED MESSAGE-----
[To: email@example.com, firstname.lastname@example.org]
On Thu, 7 Nov 2002, Sebastian Trueg wrote:
> Hy list,
> is there a good and fast way to test if a file actually is a mp3 file or not?
> My attempts with decoding some bytes at the beginning of the file do not
I was thinking about this problem recently. I was planning on
implementing the following.
Read the first 4 bytes A B C D
if ABC = ID3, then it's MP3 (It might be better to skip the ID3 header
and then ensure the following holds)
or if ABCD form a valid MP3 header, then it's MP3.
Otherwise not MP3.
To check if it's a valid header, I'd ensure
A = FF
B & 0xE0 = E0
B & 0x18 != 0x08
B & 0x06 != 0
C & 0xF0 != 0xF0
C & 0x0C != 0x0C
D & 0x03 != 0x02
I'd be interested in other's opinions of this detection algorithm.
Russell O'Connor <http://www.math.berkeley.edu/~roconnor/>
``[Law enforcement officials] suggested that the activists were stopped
not because their names are on the list, but because their names resemble
those of suspected criminals or terrorists.'' -- SFGate.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (SunOS)
Comment: For info see http://www.gnupg.org
-----END PGP SIGNATURE-----