getid3 reports a wrong bitrate on some files

Locked
erwan
User
Posts: 6
Joined: Wed Jul 30, 2008 9:34 pm

getid3 reports a wrong bitrate on some files

Post by erwan » Wed Jul 30, 2008 9:38 pm

Hello,

I'm an ampache user and I found some troubles. Their are linked to getid3.
This file for examples is said to have a 144239.41380115 bitrate.
All other tools I have reports a 128K bitrate.

The example file : http://konilope.linuxeries.org/tmp/a.mp3
The sample basic code that shows the trouble :
http://fw/tmp/getid3/demos/demo.basic.php

Can this be fixed ?

Cheers,
Erwan

erwan
User
Posts: 6
Joined: Wed Jul 30, 2008 9:34 pm

Re: getid3 reports a wrong bitrate on some files

Post by erwan » Wed Jul 30, 2008 9:48 pm

sorry for the wrong url.
please read : http://konilope.linuxeries.org/tmp/geti ... .basic.php

erwan
User
Posts: 6
Joined: Wed Jul 30, 2008 9:34 pm

Re: getid3 reports a wrong bitrate on some files

Post by erwan » Wed Jul 30, 2008 9:54 pm

I also have same oggs that plays nearly the same :

http://konilope.linuxeries.org/tmp/geti ... ic.ogg.php
http://konilope.linuxeries.org/tmp/b.ogg

This ogg is a 192kbps and shown as 189228.97733435

Any ideas why ?

erwan
User
Posts: 6
Joined: Wed Jul 30, 2008 9:34 pm

Re: getid3 reports a wrong bitrate on some files

Post by erwan » Thu Jul 31, 2008 3:27 pm

I made also some others tests.. The demo.browse reports lots of different bitrates whereas all of them are strict 128k as mplayer or mpeginfo reports.
-
http://konilope.linuxeries.org/tmp/geti ... browse.php

erwan
User
Posts: 6
Joined: Wed Jul 30, 2008 9:34 pm

Re: getid3 reports a wrong bitrate on some files

Post by erwan » Thu Jul 31, 2008 4:30 pm

The very simple code reports the correct 128Kbps bitrate on my files. If this can helps...
-
http://www.phpcs.com/codes/FONCTION-PHP ... 25034.aspx

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

Re: getid3 reports a wrong bitrate on some files

Post by James Heinrich » Fri Aug 01, 2008 2:03 am

erwan wrote:Can this be fixed ?
No, because it's right :)

The file is in fact a VBR file of approx 144kbps. You can verify this with a simple calculation -- the playtime is 5:35 (335 seconds), and the filesize is ~5.8MB (6055936 bytes).
Since there is 8 bits in 1 byte, you get:
(6055936 * 8) / 335 = 144619bps
Note: this number is slightly off since it's not taking into account the space used by ID3v2, ID3v1, VBR header, and the playtime is rounded, but you can see it's very close to the actual bitrate of 144239bps.

More simplistic programs might simply examine the first frame of the file and see 128kbps (or 192kbps or whatever) and report that as the bitrate for the entire file, which is incorrect.

erwan wrote:This ogg is a 192kbps and shown as 189228.97733435
This file was encoded with a nominal (i.e. target) bitrate of 192kbps. The actual encoded bitrate is ~189kbps which is pretty close to the target. The encoder tries to match the target bitrate as best it can; for single-pass encoding a deviation of 1.5% from target is perfectly normal.


getID3 is reporting correct values for both files.

erwan
User
Posts: 6
Joined: Wed Jul 30, 2008 9:34 pm

Re: getid3 reports a wrong bitrate on some files

Post by erwan » Fri Aug 01, 2008 7:12 am

That's at least very surprising to see a bitrate such 144239.41380115
Does all external code that uses getid3() must round your bitrate calculation ?

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

Re: getid3 reports a wrong bitrate on some files

Post by James Heinrich » Fri Aug 01, 2008 12:00 pm

If you want the actual bitrate, rounding is not neccesary. If you want to display the bitrate to the user (for example), in most cases the displayed bitrate would likely be shown in kbps, so you'd display it as

Code: Select all

round($info['bitrate'] / 1000);

Locked