Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Perl (http://www.go4expert.com/forums/perl/)
-   -   Identifying files before and after renaming - mp3 format finding end of id3v2 tags (http://www.go4expert.com/forums/identifying-files-renaming-mp3-format-t22465/)

rumex 17Jun2010 17:19

Identifying files before and after renaming - mp3 format finding end of id3v2 tags
 
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?
R

chorny 19Jun2010 03:49

Re: Identifying files before and after renaming - mp3 format finding end of id3v2 tag
 
You can use Audio::Digest::MP3 from CPAN. It calculates digest from whole file. Or you can look into it's source and use MPEG::Audio::Frame directly.

chorny 19Jun2010 03:52

Re: Identifying files before and after renaming - mp3 format finding end of id3v2 tag
 
Audio::Digest::MP3


All times are GMT +5.5. The time now is 01:30.