Well, I use FMOD Stream* functions to play all the mp3s, and thats all good – even if the displays are wrong, the file still plays to completion, whether or not you use the MPEGACCURATE flag, just don’t try to seek or get time, as it will be wrong for VBR
I’d still like to know if theres a way to tell a VBR mp3 apart from a CBR (certain bytes of the file signaling the bitrate changes). This way, the MPEGACCURATE flag could be set automatically only for the few VBR mp3s, and the rest load quickly as usual.
See, I have an mp3 class module that can parse ID3 and such from CBR files, but its inaccurate for VBR. I display the bitrate and length in the playlists as each file is parsed. Having this VBR detection would give the playlist accurate VBR results, and the usual speedy CBR parsing. I’m thinking of having the VBR files preload into a hidden channel with MPEGACCURATE, to get the correct attributes for just those files.
Calling all geniuses
<font size=-1>[ This Message was edited by: K6Deux on 2002-03-07 15:48 ]</font>
- K6Deux asked 16 years ago
So, if I understand your code, you look for the mp3 header in the first 5000 bytes, and 36 bytes into header for the string “Xing” and that means its VBR.
What about VBR mp3s not encoded with a Xing derivative (Blade, LAME, etc), have you tested this, or do they all have Xing signatures? I did look at a couple of my existing VBR mp3s and indeed Xing appears around byte 36 (header at 0), so I guess you’re right.
If its really this easy and I’m not dreaming, wow, perfect and thanks! 😀
Thats not what I meant brett, I was referring to VBR without mpegaccurate and using my class module. You and I both know Fmod kicks ass
I’m just looking for a “smarter” way to tell if a file is VBR before having to open streams with mpegaccurate, so the CBR files will still load quickly, and the VBR will load accurately, and all the displays and seeking will be perfect.
Assuming I find a solution here (with help) I will no longer rely on the mp3 class module for bitrate and run length, as Fmod indeed does a better job
Maybe reading the first ten/twenty/thirty frame headers could be useful. If the bitrate is the same in all headers, probably they are CBR, else they are surely VBR.
Frames can be also analized in the middle or at the end of the file…
Can it work?
Here is a cut/past of my function from my player :
Private Function IsVBR(ByVal Filename As String) As Boolean
Dim XingH As String * 4
Dim FileSize As Long
Dim i As Long
Dim x As Byte
FIO% = FreeFile Open Filename For Binary Access Read As FIO% FileSize = LOF(FIO%): If FileSize < 256 Then Close FIO%: Return
For i = 1 To 5000 ‘check out first 5000 bytes
Get #FIO%, i, x
If x = 255 Then ‘ header must begin with 255 then followed by 250 or 251
Get #FIO%, i + 1, x
If x > 249 And x < 252 Then
Headstart = i ‘ Inititialize the position of the header
'Check for XingHeader Get #FIO%, Headstart + 36, XingH If XingH = "Xing" Then IsVBR = True Else IsVBR = False End If Close FIO%
Please login first to submit.