Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong duration for VBR encoded MP3s #16

Closed
kadai opened this issue Jun 15, 2020 · 6 comments
Closed

Wrong duration for VBR encoded MP3s #16

kadai opened this issue Jun 15, 2020 · 6 comments

Comments

@kadai
Copy link

kadai commented Jun 15, 2020

Greetings,

First of all, thank you for the work you have been doing with this library. I have found it very useful. And while so, I have come across a little bug.

If a MP3 is encoded as VBR with a set quality, the duration of the track is not properly calculated by the class.

For example, I have found that a track that should have a duration of 1:34 (~94 secs) it is reported to last ~56.89 seconds instead.

This does not affect tracks that are not VBR encoded.

Further looking into the code, I found out that Quality is used to calculate the $samples_per_second in the lines 295 to 297 in MP3Info.php:

if ($this->isVbr && isset($this->vbrProperties['quality'])) {
    $samples_in_second = floor($samples_in_second * $this->vbrProperties['quality'] / 100);
}

After doing some tests, I found out that the "time" difference was related to the quality. In my case, the MP3 had a quality of 60, so the time was 60% shorter than expected.

I am using the dev-master version of the library.

Thanks in advance.

@wapmorgan
Copy link
Owner

This way of calculation had a purpose.
Please, provide an example of mp3 to test it

@kadai
Copy link
Author

kadai commented Jun 15, 2020

I have attached one of the files that gives me issues.

I created this file using LameXP (that uses Lame CLI if I am not wrong) with the next settings:

  • Average quality (ABR)
  • Bit Rate: ~224kbps

Then I tagged the track with Clementine, MP3Tag and TagScanner... and after that I eventually applied normalization.

test_audio.zip

I suspect that maybe it has to do with the fact it uses ABR (A variant of VBR) and probably supplies aditional information to detect it.

@ghasrfakhri
Copy link

I have exactly same problem. I attached two sample files.

5f9027d3cc122.zip
5f9028549dca7.zip

@MakamuEvans
Copy link

Any working solution to this?

@au-lait77
Copy link

anyone a solution? have the same problem that the duration is not correct with VBR.

@wapmorgan
Copy link
Owner

wapmorgan commented Aug 11, 2021

Fixed in 0.0.6 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants