wapmorgan / Mp3Info

The fastest PHP library to extract mp3 meta information (duration, bitrate, samplerate and so on) and tags (id3v1, id3v2).
https://wapmorgan.github.io/Mp3Info/
GNU Lesser General Public License v3.0
139 stars 41 forks source link

Duration is off #5

Closed d3pendent closed 4 years ago

d3pendent commented 7 years ago

Hi, first I wan to say great work! It is blasting fast. Very impressive! I just figured out that the duration you calculate is off by about 0.5% depending on the actual size. On a 30 min audio file it is about 8-9 seconds off. I have no clue how that whole calculation is done, otherwise I would fix it and create a PR.

Some files couldn't even be read because it did not find the header.

I compared the parsed time with this class: http://www.zedwood.com/article/php-calculate-duration-of-mp3 this one is mostly correct (sometime off by one second) but it is 662x slower than yours. ;) Maybe it helps you.

wapmorgan commented 7 years ago

Will check it in few days.

wapmorgan commented 6 years ago

Sorry for late response. Can you provide example mp3 showing issues?

d3pendent commented 6 years ago

Now it is me who took so long to respond :) Sorry about that. I am attaching a zip file with two mp3 files. They are quite large. One of them leads to an exception when parsing and the other ones calculated time is off by 8 seconds. I named the files to the testcase so you will see which one is which. I hope it helps in any ways. If not I can provide more data.

Thank you for checking it out. mp3_to_test.zip

d3pendent commented 6 years ago

Hi, is there any way I can assist you on this?

wapmorgan commented 6 years ago

I've looked that and could not fix it at that moment. It requires more time and attention. If you can, I'd ask for assistance. First of all, we need to understand which parts of mp3 decoded successfuly and which not.

d3pendent commented 6 years ago

oh wow. I have looked into this and it is quite advanced. I need to understand the frames and sections of the mp3 stream first to be able to figure out what's wrong. I didn't think this would be so complex.

wapmorgan commented 4 years ago

Found a problem and fixed