How to retrieve played mp3/ogg 's bitrate?

Started by zajkos,

zajkos

I did'nt find a function to do this. When I compute the bitrate by dividing file lenght by music size in seconds it gives me results which differ from the bitrate showed by winamp ro others programs (for exapmple instead of 128 it gives me 114).

Sebastian_Mares

Yes, this happens because Ogg Vorbis files use VBR encoding (and some of your MP3 files, maybe too). The value you get when dividing the file length by the music duration is the average bitrate.


biggyspender


QuoteSo there is no other way to get the bitrate?

http://www.dv.co.yu/mpgscript/mpeghdr.htm
http://www.oreilly.com/catalog/mp3/chapter/ch02.html

heavy stuff... enjoy...

(: JOBnik! :)

#4
Hi ;D

* It's better to get the Bitrate out from the files header :) but here's how to get it other way:

// Returns - Kilo Bits Per Second
int GetBitsPerSecond(DWORD handle, DWORD FileLength)
{
  return (int)(((FileLength * 8 ) / (long)BASS_ChannelBytes2Seconds(handle, BASS_StreamGetLength(handle))) / 1000);
}

Have fun!

8) JOBnik! 8)