Identifying files before and after renaming - mp3 format finding end of id3v2 tags

rumex's Avatar, Join Date: Jun 2010
Newbie Member
Hi I am a newbie to the mp3 format.
I want to generate a CRC or SHA1 over the first music data section in an mp3 file so I can identify the file in a database; after both filename, path and internal id3v2 and id3v1 tags have been added, deleted and modified.
I believe the highlevel layout of an mp3 file looks like:
|0..n id3v2 tags...|0.n music sections|0..1 id3v1 tag|
I think the id3v2 tags optionally occupy many sections at the front of the file. I tried a sha1 at the end of the file, avoiding any id3v1 tag, but too many tracks had identical sha1 generated in the last 10,000 bytes of the file. These were tracks from the same album CD.
I am using perl and wish to programatically identify id3v2 sections and their length to skip over them. For consistency I need to always identify the first music section.
Has anyone done this or suggest a better way to do this?
chorny's Avatar, Join Date: Jun 2010
Go4Expert Member
You can use Audio:igest::MP3 from CPAN. It calculates digest from whole file. Or you can look into it's source and use MPEG::Audio::Frame directly.
chorny's Avatar, Join Date: Jun 2010
Go4Expert Member
rumex like this