Heuristic for determining valid MP3 file

Erik Jälevik <[email protected]>
Newsgroups gmane.comp.audio.mad.devel
Message-ID <008b01c417eb$27f68fc0$a59d0050@Komputer>
What's a good heuristic for determining whether a file is a valid MP3 or not?

My first thought was to grab a chunk at the beginning of the file and repeatedly
call mad_header_decode until it comes back with a header and take that as an
indication that the file is valid.

However, on trying this out on the first 10k of a plain text file,
mad_header_decode still returns a header found at 8k but with wrong data in it.
Maybe this is due to it just looking for the sync bits and this file happened to
have them within its first 10k?

Is there a better way of doing this? Maybe start trying to decode and if more
errors than a certain threshold occur, assume the file is not valid?

Thanks,
Erik
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.