[ID3 Dev] Finding the end of an ID3 Header

Scott Wheeler wheeler at kde.org
Mon Nov 6 17:24:09 PST 2006


Robert Sewell wrote:
>
> Hello,
>
> I have a need to verify that mp3 files uploaded by our users comply
> with certain minimum specs (bit and sample rates, etc.). To get to the
> mp3 headers, I first have to check for an ID3 tag, and if found, use
> bytes 6-9 to calculate the location of the first mp3 frame. My routine
> seems to work in most cases. However, I’ve got one mp3 files that
> doesn’t seem to fit the specs, and fails my verification process,
> although all mp3 players play the file without a problem. Below are
> the first 13 bytes of the file:
>
> 49 44 33 03 00 00 00 01 79 76 57 4F 41 46
>
> If I am interpreting the ID3 specs correctly, the first mp3 frame
> should be found at offset 7D00. However, I only find 00 there; the
> first mp3 is really at 7EA1.
>

Yep, your calculations are correct.

> Am I missing something? Or did the program that added the ID3 tag
> miscalculate the ID3v2 size bytes? If the latter, do all players allow
> for mistakes and just start hunting for the 11-bit frame sync?
>

Being pedantic, the ID3v2 length doesn't indicate where the data starts,
it indicates where the tag ends. Until you hit a valid MPEG synch it's
just a blob of data. That said, it was probably some tagger that messed
things up (apparently not including the padding in the length), but
likely your users won't much care since the file seems fine to them. ;-)
Basically you do need to look for the MPEG synch.

-Scott

---------------------------------------------------------------------
To unsubscribe, e-mail: id3v2-unsubscribe at id3.org
For additional commands, e-mail: id3v2-help at id3.org



More information about the ID3v2 mailing list