How can i display the variable bitrate, for a mp3/ogg file playing. In winamp you can see how many kbps the current frame is encoded at, and this number shifts rapidly. How can i implement this, using fmod.. preferebly in Delphi?

I got it to work, but it seems to me its very inaccurate. The math looks ok to me, but it keep returning kbit in rages of 32-96 kbit, even when im sure the current mp3 file s playing in 160-320 kbit ranges.

Hmm, I recall noticing weird behaviour of the GetTimeMs function, but I just added a factor and dismissed the problem. I’ll look into this again, however right now my computers are still in my dorm and I’m at home, so until I get the chance to move them here you’ll have to wait a bit
You could also try to increase the delay between updates, to improve the accuracy.

I have tried several different solutions to this. This is my latest approch, and should work regardless of platform, and the type of file playing (Delphi):
[code:2qukpoqe]
nowpos:=FSOUND_Stream_GetPosition(song.Stream);
nowtime:=FSOUND_Stream_GetTime(song.Stream);

// Calculate how many bits, used in the last (nowtime-lasttime) ms
bitrate:=(8*(nowpos-lastpos))/(nowtime-lasttime);
[/code:2qukpoqe]

This is the most accurate result i’ve got so far, but it still jumps up above 400kbit and goes below 32kbit, even on CBR mp3 files. (??)

Evinyatar Wrote:
[quote:2qukpoqe]Hmm, I recall noticing weird behaviour of the GetTimeMs function, but I just added a factor and dismissed the problem.[/quote:2qukpoqe]

Still i get inaccurate results. If i try using it on CBR MP3 files, it still varies in kbit.

And yes, i’ve tried to update the bitrate every 25th ms, or once a second, and i’ve get slightly better results.. still alot inaccurate. Also tried, according to help:
[quote:2qukpoqe]Position information is also based on the current file position, not the actual playing
position, so if the stream is only updated every 100ms, then the position will only be
updated every 100ms.[/quote:2qukpoqe], to update to aaround every 100ms, and even wait for ‘GetPosition’ to change, until i update my bitrate calculations, still highly inaccurate.

My latest solution was to use the value returned from FSOUND_Stream_GetPosition, and then open the current mp3(it only works for mp3 files), and seek to the position from FSOUND_Stream_GetPosition, and then decode the header/frame info, to get an accurate value.. but this also proved highly inaccurate, and only works with mp3 files.

Hope someone got news on this, or any other way to get the current kbps for the currently playing media file(Streams).

I’m amazed that this ‘simple’ thing(To show how many kbps the current fram is using, like winamp) is so hard to implement. I have tried tons of dofferent approches, but still i’m left with an painfully inaccurate kbps value for my player.

Even tried to scan the m3 for its headers, but is utter useless, and requires too many ressources for a simple player.

Is there really no news on this, or is fmod inaccurate in reporting back its consumption of bytes per second, while playing a media file?

Download [url=http://www.foobar2000.org/SDK.zip:15raj6df]this[/url:15raj6df]. This is the SDK of the [url=http://www.foobar2000.org:15raj6df]Foobar2000[/url:15raj6df] player. Go to the “foobar2000\foo_input_std” directory and open the mp3.cpp file. You can find an interresting function : get_dynamic_info(). Here, for each frame, you must recalculate the bitrate. Good luck.