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