Can getid3 be used to compute a checksum of "audio part"

The place for "I can't figure out how to..." questions.
Post Reply
fred727
User
Posts: 11
Joined: Wed Jun 08, 2016 6:20 pm
Are you a spambot?: no

Can getid3 be used to compute a checksum of "audio part"

Post by fred727 » Fri Nov 11, 2016 4:43 pm

Hi,

First of all, thank you for getid3 !

Is it possible with getid3 to compute the checksum of a file, ignoring id3/APE informations ? My need is to generate such a checksum to check duplicate files with same audio information but with id3 tags wich are different.

I'd like a very fast algorithm... Is it possible for exemple to obtain very quickly all the positions of the audio frames of the file ? If we have this information, we could easyly get a checksum (md5 or other) of these part.

I found the linux shell cmd "avconv" wich can make something similar (give a CRC of audio frames) :
avconv -i MP3FILE -f crc - 2>/dev/null
But it is not very fast...

James Heinrich
getID3() v1 developer
Posts: 1427
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Can getid3 be used to compute a checksum of "audio part"

Post by James Heinrich » Fri Nov 11, 2016 5:18 pm

Yes, for most formats the MD5 and/or SHA1 can be calculated automatically, if you enable the appropriate option on your getID3 object:
https://github.com/JamesHeinrich/getID3 ... hp#L96-L98
for example:

Code: Select all

$getid3 = new getID3();
$getid3->option_md5_data = true;
$info = $getid3->analyze($filename);
echo 'MD5: '.$info['md5_data'];
It's not "very" fast, but since that's a subjective description you can try it for yourself and decide.

fred727
User
Posts: 11
Joined: Wed Jun 08, 2016 6:20 pm
Are you a spambot?: no

Re: Can getid3 be used to compute a checksum of "audio part"

Post by fred727 » Fri Nov 11, 2016 9:12 pm

So great !!!!!

This is realy faster, and it work as expected. Just beautifull !

For the same mp3 file (10 Mo) the "time" unix command gives :
- an average of 0.7s with avconv
- an average of 0.1s with getid3

So it is 7 times faster ! Thank you so much :)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests