From: Chris B. <ch...@cn...> - 2008-11-09 15:56:02
|
Reuben Thomas wrote: > Hi, > > it occurs to me that you might be interested in helping us improve the > magic, so this sort of problem is less likely. In particular, I had the > following idea: > > 1. I commented out the magic line in the "audio" magic file (I'm talking > about the source distribution of file here) that causes ID3-tagged files to > be detected as audio/mpeg. > > 2. The current magic for detecting audio formats is based on fixed offsets. > I notice that ID3 blocks are often a particular length long; is that usually > true? The issue is this: one could allow a variable offset to the start of > the audio format magic, but in that case, the magic has to be strong (i.e. > match lots of bytes) to avoid false positives. If the ID3 block is usually a > certain length, then the magic could simply be duplicated, once for the > start of the audio file, and once at the standard offset. > > ID3v1's are fixed length but they are always at the end of the file... so not an issue. ID3v2 are variable by definition but I don't know if standard practice pads things so they can share code with ID3v1. If so then you can base offset off ID3v1 length and check for an mp3 frame header after the ID3 and then treat it as an MP3. That wouldn't handle the variable size case unless you can do a scan for the MP3 frame header (which my /usr/share/magic implies you can't because it commented out something similar in the ogg section to fix this same issue; saying search assumes text mode). Chris |