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

Wrong duration for mp3 file #24

Open ghost opened 2 years ago

ghost commented 2 years ago

I have tested two mp3 files with the code provided as example, one was ok, but the other, it should be 3.13 min. but it shows 6.24 min.

wapmorgan commented 1 year ago

Provide sample file

Nispeon commented 1 year ago

Hello, I fear I am experiencing the same issue.

I have personally tested with files from there : https://samplelib.com/sample-mp3.html (the 3s and 9s samples).

For the 9s file, I get a duration of 19s, for the 3s file, I get 6s.

However, the 700KB audio file from this other source works fine, I get the correct duration of 27s.

Any chance you're still maintaining this project ? 😄

mostafa-norouzi commented 1 year ago

I checked Duration param on below sample file (PHP 8.1) and value was "187" but correct answer is "93". https://file.io/4oLhqewhW6nJ

It seems package is abandoned.

Nispeon commented 1 year ago

To @greenreptile and anyone who might see this in the future: I have since found an alternative to this issue by using : https://github.com/PHP-FFMpeg/PHP-FFMpeg. It works like a charm and even works for video files.

I hate to advertise someone else's package here, but I feel like other devs might find it useful, so as to not go through the same process I have after I posted this initial comment.

mostafa-norouzi commented 1 year ago

@Nispeon Yes. I tested it right now and seems satisficing.

wapmorgan commented 1 year ago

@Nispeon @greenreptile Fixed in 0.1.0: if does not work, increase \wapmorgan\Mp3Info\Mp3Info::$framesCountRead from 2 to 3 or 4.

wapmorgan commented 1 year ago
               File name |   dur. | bitrate | sample |        song |     artist | track | time
          sample-12s.mp3 |   0:12 | 128kbps |   44.1 |             |            |       | 3.504753112793E-5
           sample-3s.mp3 |   0:03 | 128kbps |   44.1 |             |            |       | 1.5974044799805E-5
           sample-6s.mp3 |   0:06 | 128kbps |   44.1 |             |            |       | 1.5974044799805E-5
           sample-9s.mp3 |   0:09 | 128kbps |   44.1 |             |            |       | 1.5020370483398E-5
                      Total duration: 0:51 |         Total parsing time: 0.0001