I can already read an MP3's ID3 tags. I need to know how to calculate the bitrate and duration as it is not included in ID3 tags. If anyone can give examples or point me in the right direction that would be most helpful.
Printable View
I can already read an MP3's ID3 tags. I need to know how to calculate the bitrate and duration as it is not included in ID3 tags. If anyone can give examples or point me in the right direction that would be most helpful.
http://www.wotsit.org/ will have a documentation on an MP3 file for sure, hopefully one of them will give you information about the header of an MP3.
I know how to get... through winamp. I don't know if that helps.
hey how do you open a file with winamp? like your mp3 thing???
Do you mean how I get it played with Winamp?Quote:
Originally posted by Vanguard-MnC
hey how do you open a file with winamp? like your mp3 thing???
I would rather not use winamp. I am writing a dll that will read ID3 tags, duration and bitrate (for use in an asp script). It would be a lame dll if it depended on winamp, you know?
I know that there is a way that duration and bitrate can be calculated.
You can easily calculate the bitrate. I've never tried to calcualate the duration but I'm sure its possible. But you do need the duration before you can calculate the bitrate. You would need to find it in the mp3 header. Well, here is the mp3 bitrate calculation. When you have the length of the mp3 in seconds.
VB Code:
Dim ThePath As String Dim TheSize As Long Dim DurationInSec as Long Dim GetMP3Bitrate as Long ThePath = "c:\yourfile.mp3" TheSize = FileLen(ThePath) TheSize = TheSize * 8 GetMP3Bitrate = TheSize \ DurationInSec
You can use the mciSendString API
I and he knows that(I'm assuming he does). He was wanting to calculate it.
hey thanks formulav8 for the formula, useful. I will try it out tonight.
So I can find the duration in the MP3 header?
I thought you wanted to be able to calculate it. You can get the freq., bitrate, ect. from the header file.
I was under the impression that it had to be calculated. I was not aware that it could be read from the header. Do you have any resources? Thanks for your help.
Here you have something to start with:
The private life of MP3 frames or it's main page
Here's what I "saved" (from a bigger project -the one on my signature-) ...
VB Code:
Option Explicit Private Type MP3Header Lenght As Long Position As Long ID As String Layer As String Frequency As String Mode As String Emphasis As String Padding As Boolean FrameSize As Long CopyRighted As Boolean Original As Boolean BitRate As String End Type Public Version As Byte Private Sub ReadFile(strFilename As String, mHeader As MP3Header) Static BitRate(11 To 23, 1 To 14) As String Dim fn As Integer Dim lngHeaderPosition As Long Dim lngFilesize As Long Dim BitLine As Integer Dim i As Byte Dim Tag2 As String Dim TagSize As String * 4 Dim ID3Tag As String * 3 Dim sHeader As String * 4 'BitRate MPEG-1, MPEG-1, MPEG-1, MPEG-2, MPEG-2, MPEG-2, 'Value layer I layer II layer III layer I layer II Layer III '0 0 0 0 '0 0 0 1 32 32 32 32 32 8 '0 0 1 0 64 48 40 64 48 16 '0 0 1 1 96 56 48 96 56 24 '0 1 0 0 128 64 56 128 64 32 '0 1 0 1 160 80 64 160 80 64 '0 1 1 0 192 96 80 192 96 80 '0 1 1 1 224 112 96 224 112 56 '1 0 0 0 256 128 112 256 128 64 '1 0 0 1 288 160 128 288 160 128 '1 0 1 0 320 192 160 320 192 160 '1 0 1 1 352 224 192 352 224 112 '1 1 0 0 384 256 224 384 256 128 '1 1 0 1 416 320 256 416 320 256 '1 1 1 0 448 384 320 448 384 320 '1 1 1 1 If BitRate(11, 1) = "" Then BitRate(11, 1) = "32" BitRate(11, 2) = "64" BitRate(11, 3) = "96" BitRate(11, 4) = "128" BitRate(11, 5) = "160" BitRate(11, 6) = "192" BitRate(11, 7) = "224" BitRate(11, 8) = "256" BitRate(11, 9) = "288" BitRate(11, 10) = "320" BitRate(11, 11) = "352" BitRate(11, 12) = "384" BitRate(11, 13) = "416" BitRate(11, 14) = "448" BitRate(12, 1) = "32" BitRate(12, 2) = "48" BitRate(12, 3) = "56" BitRate(12, 4) = "64" BitRate(12, 5) = "80" BitRate(12, 6) = "96" BitRate(12, 7) = "112" BitRate(12, 8) = "128" BitRate(12, 9) = "160" BitRate(12, 10) = "192" BitRate(12, 11) = "224" BitRate(12, 12) = "256" BitRate(12, 13) = "320" BitRate(12, 14) = "384" BitRate(13, 1) = "32" BitRate(13, 2) = "40" BitRate(13, 3) = "48" BitRate(13, 4) = "56" BitRate(13, 5) = "64" BitRate(13, 6) = "80" BitRate(13, 7) = "96" BitRate(13, 8) = "112" BitRate(13, 9) = "128" BitRate(13, 10) = "160" BitRate(13, 11) = "192" BitRate(13, 12) = "224" BitRate(13, 13) = "256" BitRate(13, 14) = "320" BitRate(21, 1) = "32" BitRate(21, 2) = "64" BitRate(21, 3) = "96" BitRate(21, 4) = "128" BitRate(21, 5) = "160" BitRate(21, 6) = "192" BitRate(21, 7) = "224" BitRate(21, 8) = "256" BitRate(21, 9) = "288" BitRate(21, 10) = "320" BitRate(21, 11) = "352" BitRate(21, 12) = "384" BitRate(21, 13) = "416" BitRate(21, 14) = "448" BitRate(22, 1) = "32" BitRate(22, 2) = "48" BitRate(22, 3) = "56" BitRate(22, 4) = "64" BitRate(22, 5) = "80" BitRate(22, 6) = "96" BitRate(22, 7) = "112" BitRate(22, 8) = "128" BitRate(22, 9) = "160" BitRate(22, 10) = "192" BitRate(22, 11) = "224" BitRate(22, 12) = "256" BitRate(22, 13) = "320" BitRate(22, 14) = "384" BitRate(23, 1) = "8" BitRate(23, 2) = "16" BitRate(23, 3) = "24" BitRate(23, 4) = "32" BitRate(23, 5) = "64" BitRate(23, 6) = "80" BitRate(23, 7) = "56" BitRate(23, 8) = "64" BitRate(23, 9) = "128" BitRate(23, 10) = "160" BitRate(23, 11) = "112" BitRate(23, 12) = "128" BitRate(23, 13) = "256" BitRate(23, 14) = "320" End If fn = FreeFile Open strFilename For Binary As # lngFilesize = LOF(fn) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Check for a Header '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Get #fn, 1, ID3Tag If ID3Tag = "ID3" Then lngHeaderPosition = 1 Dim R As Long Get #fn, 4, Version Get #fn, 7, TagSize R = CVL(TagSize, 128) If R > lngFilesize Or R > 2147483647 Then Exit Sub End If Tag2 = Space$(R) Get #fn, 11, Tag2 lngHeaderPosition = R + 11 End If Get #fn, 11 + Len(Tag2), sHeader Close With mHeader .Lenght = FileLen(strFilename) .Position = 10 + Len(Tag2) 'Second Byte sHeader = Mid$(sHeader, 2) i = (Asc(sHeader) And 8) / 8 .ID = IIf(i = 0, "MPEG-2", "MPEG-1") BitLine = 10 * i i = (Asc(sHeader) And 6) / 2 .Layer = IIf(i = 0, "Not defined", IIf(i = 1, "Layer 3", IIf(i = 2, _ "Layer 2", "Layer 1"))) BitLine = BitLine + (4 - i) 'Third Byte sHeader = Mid$(sHeader, 2) i = (Asc(sHeader) And 240) / 16 On Error Resume Next .BitRate = "Not defined" .BitRate = BitRate(BitLine, i) & "kbit" On Error GoTo 0 i = (Asc(sHeader) And 12) / 4 If .ID = "MPEG-1" Then .Frequency = IIf(i = 0, "44100 Hz", IIf(i = 1, "48000 Hz", _ "32000 Hz")) Else .Frequency = IIf(i = 0, "22050 Hz", IIf(i = 1, "24000 Hz", _ "16000 Hz")) End If i = (Asc(sHeader) And 2) / 2 .Padding = i 'Forth Byte sHeader = Mid$(sHeader, 2) i = (Asc(sHeader) And 192) / 64 .Mode = IIf(i = 0, "Stereo", IIf(i = 1, "Joint Stereo", IIf(i = 2, _ "Dual channel", "Mono"))) i = (Asc(sHeader) And 8) / 8 .CopyRighted = i i = (Asc(sHeader) And 4) / 4 .Original = i i = (Asc(sHeader) And 3) .Emphasis = IIf(i = 0, "None", IIf(i = 1, "50/15ms", IIf(i = 2, _ "", "CCITT j.17"))) .FrameSize = (144 * Val(.BitRate) * 1000 / Val(.Frequency)) - .Padding End With End Sub Public Function CVL(ByVal Cadena As String, Optional Valor As Integer = 256) _ As Long Dim i As Integer CVL = 0 For i = 3 To 0 Step -1 CVL = CVL + (Valor ^ i) * Asc(Cadena) Cadena = Mid$(Cadena, 2) Next i End Function Private Sub Form_Load() Dim mHeader As MP3Header ReadFile "D:\Downloaded Files\MP3\4 Non Blondes - What's Up.mp3", mHeader With mHeader lblMPEGInfo.Caption = "Size: " & .Lenght & " bytes" lblMPEGInfo.Caption = lblMPEGInfo.Caption & vbCr & _ "Header found at: " & .Position lblMPEGInfo.Caption = lblMPEGInfo.Caption & vbCr & .ID & _ " " & .Layer & vbCr & .BitRate & vbCr & .Frequency & " " _ & .Mode lblMPEGInfo.Caption = lblMPEGInfo.Caption & vbCr _ & "Copyrihted: " & IIf(.CopyRighted, "Yes", "No") lblMPEGInfo.Caption = lblMPEGInfo.Caption & vbCr _ & "Original: " & IIf(.Original, "Yes", "No") lblMPEGInfo.Caption = lblMPEGInfo.Caption & vbCr _ & "Emphasis: " & .Emphasis End With End Sub
However, it's not working 10 points.... some MP3s are not showing the right ID or layer (according to WinAmp). Is there anything I'm missing. Besides... I can get the FrameSize, how do you get the number of frames?? What's "CRCs"? And, how do you get the lenght of the song?
Take a look at my activeX dll. It can retrieve everything that Winamp can, only thing is it does not include support for IDv2 tags yet!
I have also added functionality to retrive the MP3's forst audio frame position, the number of frames in the mp3 and the duration. In fact, theres bloody loads of stuff in here. Before you use it though read the documentation.
Ok... I did manage to get the CRC, the duration and the number of frames. However, I still can't understand why on some MP3s the information is not correct. Any ideas?
Probably because it is a vbr mp3 file.
What do you mean?
He means its a variable bitrate MP3. Every MP3 is made up of frames, and the frames have the bitrate encoded into them. VBR MP3's have frames which have different bitrates. This had the advantage of being able to use lower bitrates for lower quality sound in the song. In most cases it can make the MP3 a fair bit smaller. The reason you cant read the info properly from a VBR MP3 is becuase you are only readin the first frame.
I don't get it. I'm only reading the header
Am I missing something? Shouln't I have to be able to read the whole information from the header regardless if it's vbr or not??
This may help:
1st frame is encoded at 128kbps
2nd frame 256kbps
3rd frame 128kbps
4th frame 96kbps
.
.
.
15890th frame 192kbps
15891st frame 128kbps
You read the first frame and take it that the MP3 = 128kbps. But most of the other frames are not. Therefore you calculate the mp3 length bu useing the kbps in the 1st frame, when in fact it should be the average of all the frames kbps. Understand now? Thats why Winamp gets it right becuase it reads ALL the frames then displays the length!
The problem is not with the lenght... it's with the ID and layer, to start with... then, all the rest might be wrong.
Exaxtly, any calculations you make using the bitrate will be wrong within a VBR MP3. If you want precise calculations your going to have to read all the frames to make sure its correct :(
I did understand that already. But, let's get graphical...
http://www.vbforums.com/attachment.php?s=&postid=990547
Both dialog boxes are showing the same information. However, Winamp says it's a MPEG-1 Layer 3, and my app thinks it's a MPEG-2.5 not defined Layer. Also, the headers seems to start on a different position. What could be the difference with this MP3??
any ideas?
A mp3 has more then one header file. It has a header for each frame. If it is a variable bitrate mp3 then certain frames will be encoded at a different bitrate. Of course I could be wrong :D
Jason
I believe there should exist only one HEADER for the MP3, and not multiple frame's headers. I mean, there should be one main header where you can extract all the information needed without the need to seek all the frames to access to the information. What would be the use of a MP3's header, if you have to seek all the frame's header to get the information? Of course... I could be wrong as well.
Am I that far from truth?? :confused:
The thing is that if the mp3 is a vbr mp3 then each frame will be encoded at a different bitrate. How could just the first frame header have the correct bitrate for all of the frames if it is a vbr mp3?
Jason
I understand the bitrate difference. But, if an MP3 is coded as MPEG-1, all the frames should be coded the same way. The same thing should happen with the layer. This information should be on a main header, as it is common for all the frames. Why am I getting differences (about the MPEG coding and layer) Besides... Why WinAmp says the header starts some bytes "later"... what's the difference with other MP3s?? (I mean, how can I detect this difference, for example)
Ok, I have the solution. While I was kaing VBAMP I stumbled accross the same problem. Basically, your looking for the header by checking the sync. If ID2 is pesent then the sync frame is going to be some way down the file e.g. 2306 bytes into the file. Now, the ID2 information will probably have a few bytes that represent the same information as a sync header. It makes it look like you've found a sync header when you havent, your just milling around in the ID2 tag. What you have to do is extract all the ID2 information and record where the end of the ID2 tag is in the file, then start your sync header checking after the ID2 tag. Hope this helps!
From the looks of your pic, you apparently found the first header a little bit before Winamp did, this is why I think you are looking in the ID2 tag still.
Ok... If I force the program to check at 2339 (I wonder why it didn't work in 2338) I get the right values. However, how can I detect if I'm not reading the right value. Anyway, I don't know why I would be reading over the ID3v2's Tag. I'm getting the 4 bytes just after it.So, what could be between the ID3v2's tag and the header? What are those 32 bytes extra in the middle?VB Code:
Get #fn, 11 + Len(Tag2), sHeader
REMEMBER, CRAPPY BYTES OF INFO CAN BE SHOVED ANYWHERE IN ANY FILE
What winamp does is use roughly the same algorithm as you to check for the first header. If it finds what appears to be a header it will check another (roughly) 10000 bytes into the file to find a few more headers. If the layer and mpeg version is consistant throughout those several headers then Winamp assumes that it has found a correct set of headers and continues as normal. If there are differencs within those headers then it will miss out the first header it found and check the 2nd 3rd and 4th headers it found. If they differ from each other then it will delete the second and check the 3rd, 4th and 5th headers. It will keep doing this until it finds a matching header selection. The information you check inside the headers is up to you, but I would go all bits that will remain constant throughout the headers. I think it would be safe to assume that you can rely on the layer, the mpeg version and a couple of others like the copyright and original bits to verify the headers. It would be something like this.
- Pass beginning tags (ID2)
- Record end of Id2 tags
- search for 1st header
- found 1st header
- check for 2nd 3rd and 4th header
- all found
- check for consistency
- 1st header info does not match 2nd or 3rd or 4th
- skip 1st header
- get 5th header
- 2nd 3rd 4th and 5th header info matches
- FOUND GOOD HEADER INFO
- continue!
Hope this helps you, if not, throw me over your source code and I'll take a good look at it for you :)
This is the code I'm using:VB Code:
Option Explicit Public Type MP3Header MP3Length As Long Position As Long Duration As Integer ID As String Layer As String SampleRate As String Mode As String Emphasis As String Padding As Boolean FrameSize As Long FrameCount As Long CopyRighted As Boolean Original As Boolean BitRate As String CRC As Boolean End Type Public Version As Byte Private Sub ReadFile(strFilename As String, mHeader As MP3Header) Static BitRate(11 To 23, 1 To 14) As String Dim fn As Integer Dim lngHeaderPosition As Long Dim lngFilesize As Long Dim BitLine As Integer Dim i As Byte Dim Tag2 As String Dim TagSize As String * 4 Dim ID3Tag As String * 3 Dim sHeader As String * 4 If BitRate(11, 1) = "" Then BitRate(11, 1) = "32" BitRate(11, 2) = "64" BitRate(11, 3) = "96" BitRate(11, 4) = "128" BitRate(11, 5) = "160" BitRate(11, 6) = "192" BitRate(11, 7) = "224" BitRate(11, 8) = "256" BitRate(11, 9) = "288" BitRate(11, 10) = "320" BitRate(11, 11) = "352" BitRate(11, 12) = "384" BitRate(11, 13) = "416" BitRate(11, 14) = "448" BitRate(12, 1) = "32" BitRate(12, 2) = "48" BitRate(12, 3) = "56" BitRate(12, 4) = "64" BitRate(12, 5) = "80" BitRate(12, 6) = "96" BitRate(12, 7) = "112" BitRate(12, 8) = "128" BitRate(12, 9) = "160" BitRate(12, 10) = "192" BitRate(12, 11) = "224" BitRate(12, 12) = "256" BitRate(12, 13) = "320" BitRate(12, 14) = "384" BitRate(13, 1) = "32" BitRate(13, 2) = "40" BitRate(13, 3) = "48" BitRate(13, 4) = "56" BitRate(13, 5) = "64" BitRate(13, 6) = "80" BitRate(13, 7) = "96" BitRate(13, 8) = "112" BitRate(13, 9) = "128" BitRate(13, 10) = "160" BitRate(13, 11) = "192" BitRate(13, 12) = "224" BitRate(13, 13) = "256" BitRate(13, 14) = "320" BitRate(21, 1) = "32" BitRate(21, 2) = "64" BitRate(21, 3) = "96" BitRate(21, 4) = "128" BitRate(21, 5) = "160" BitRate(21, 6) = "192" BitRate(21, 7) = "224" BitRate(21, 8) = "256" BitRate(21, 9) = "288" BitRate(21, 10) = "320" BitRate(21, 11) = "352" BitRate(21, 12) = "384" BitRate(21, 13) = "416" BitRate(21, 14) = "448" BitRate(22, 1) = "32" BitRate(22, 2) = "48" BitRate(22, 3) = "56" BitRate(22, 4) = "64" BitRate(22, 5) = "80" BitRate(22, 6) = "96" BitRate(22, 7) = "112" BitRate(22, 8) = "128" BitRate(22, 9) = "160" BitRate(22, 10) = "192" BitRate(22, 11) = "224" BitRate(22, 12) = "256" BitRate(22, 13) = "320" BitRate(22, 14) = "384" BitRate(23, 1) = "8" BitRate(23, 2) = "16" BitRate(23, 3) = "24" BitRate(23, 4) = "32" BitRate(23, 5) = "64" BitRate(23, 6) = "80" BitRate(23, 7) = "56" BitRate(23, 8) = "64" BitRate(23, 9) = "128" BitRate(23, 10) = "160" BitRate(23, 11) = "112" BitRate(23, 12) = "128" BitRate(23, 13) = "256" BitRate(23, 14) = "320" End If fn = FreeFile Open strFilename For Binary As # lngFilesize = LOF(fn) Get #fn, 1, ID3Tag If ID3Tag = "ID3" Then lngHeaderPosition = 1 Dim R As Long Get #fn, 4, Version Get #fn, 7, TagSize R = CVL(TagSize, 128) If R > lngFilesize Or R > 2147483647 Then Exit Sub End If Tag2 = Space$(R) Get #fn, 11, Tag2 lngHeaderPosition = R + 11 End If Get #fn, 11 + Len(Tag2), sHeader With mHeader .MP3Length = FileLen(strFilename) .Position = 11 + Len(Tag2) '*** Second Byte *** sHeader = Mid$(sHeader, 2) 'MPEG Audio version ID '00 - MPEG Version 2.5 '01 - reserved '10 - MPEG Version 2 (ISO/IEC 13818-3) '11 - MPEG Version 1 (ISO/IEC 11172-3) i = (Asc(sHeader) And 24) / 8 .ID = IIf(i = 0, "MPEG-2.5", IIf(i = 1, "reserved", _ IIf(i = 2, "MPEG-2", "MPEG-1"))) BitLine = IIf(i = 3, 10, 20) 'Layer description '0 0 Not defined '0 1 Layer III '1 0 Layer II '1 1 Layer I i = (Asc(sHeader) And 6) / 2 .Layer = IIf(i = 0, "Not defined", IIf(i = 1, "Layer 3", _ IIf(i = 2, "Layer 2", "Layer 1"))) BitLine = BitLine + (4 - i) 'CRC '0 = No '1 = Yes i = (Asc(sHeader) And 1) .CRC = Not (-i) ' *** Third Byte *** sHeader = Mid$(sHeader, 2) i = (Asc(sHeader) And 240) / 16 On Error Resume Next .BitRate = "Not defined" .BitRate = BitRate(BitLine, i) & "kbit" On Error GoTo errorhandler 'Frequency 'value MPEG-1 MPEG-2 '0 0 44100 Hz 22050 Hz '0 1 48000 Hz 24000 Hz '1 0 32000 Hz 16000 Hz '1 1 i = (Asc(sHeader) And 12) / 4 If .ID = "MPEG-1" Then .SampleRate = IIf(i = 0, "44100 Hz", _ IIf(i = 1, "48000 Hz", "32000 Hz")) Else .SampleRate = IIf(i = 0, "22050 Hz", _ IIf(i = 1, "24000 Hz", "16000 Hz")) End If 'Padding Bit '0 - frame is not padded '1 - frame is padded with one extra slot i = (Asc(sHeader) And 2) / 2 .Padding = i ' *** Forth Byte *** sHeader = Mid$(sHeader, 2) 'Mode value mode '0 0 Stereo '0 1 Joint stereo '1 0 Dual channel '1 1 Mono i = (Asc(sHeader) And 192) / 64 .Mode = IIf(i = 0, "Stereo", IIf(i = 1, "Joint Stereo", _ IIf(i = 2, "Dual channel", "Mono"))) 'Copyright '0 - Audio is not copyrighted '1 - Audio is copyrighted i = (Asc(sHeader) And 8) / 8 .CopyRighted = i 'Original '0 - Copy of original media '1 - Original media i = (Asc(sHeader) And 4) / 4 .Original = i 'Emphasis value Emphasis method '0 0 none '0 1 50/15ms '1 0 '1 1 CCITT j.17 i = (Asc(sHeader) And 3) .Emphasis = IIf(i = 0, "None", IIf(i = 1, "50/15ms", _ IIf(i = 2, "reserved", "CCITT j.17"))) .FrameSize = IIf(.Layer = "Layer 1", _ 12 * Val(.BitRate) * 1000 \ Val(.SampleRate) - .Padding, _ 144 * Val(.BitRate) * 1000 \ Val(.SampleRate) - .Padding) .FrameCount = (.MP3Length - .Position - 4) \ .FrameSize .Duration = ((.MP3Length - .Position - 4) * 8 \ Val(.BitRate)) / 1000 End With Close End Sub Public Function CVL(ByVal Cadena As String, Optional Valor As Integer = 256) _ As Long Dim i As Integer CVL = 0 For i = 3 To 0 Step -1 CVL = CVL + (Valor ^ i) * Asc(Cadena) Cadena = Mid$(Cadena, 2) Next i End Function Private Sub Form_Load() Dim mHeader As MP3Header ReadFile "D:\Downloaded Files\MP3\4 Non Blondes - What's Up.mp3", mHeader With mHeader lblMPEGInfo.Caption = "Size: " & .MP3Length & " bytes" & _ vbCr & "Header found at: " & .Position & " bytes" & _ vbCr & "Length: " & .Duration & " seconds" & _ vbCr & .ID & " " & .Layer & _ vbCr & .BitRate & ", " & .FrameCount & " frames" & _ vbCr & .SampleRate & " " & .Mode & _ vbCr & "CRCs: " & IIf(.CRC, "Yes", "No") & _ vbCr & "Copyrighted: " & IIf(.CopyRighted, "Yes", "No") & _ vbCr & "Original: " & IIf(.Original, "Yes", "No") & _ vbCr & "Emphasis: " & .Emphasis End With End Sub
This is the code I use and it works very well...
VB Code:
For lCount = 1 To 5000 Get #1, lCount, bHead(0) If bHead(0) = 255 Then Get #1, lCount + 1, bHead(1) If bHead(1) = 250 Or bHead(1) = 251 Then FirstFrame = lCount Exit For End If End If Next lCount
I can alter that little loop to make it search from wherever I want, so mabey if you could use it to search for the say first 5 headers
Thanks a lot!!
This is what I got.
http://forums.vb-world.net/attachmen...&postid=994625
BTW, are you sure that the first byte of the header would always be 255 and the second 250 or 251?
Positive, its definatly 255 then 251 or 250, thats the algorithm that every commercial MP3 player uses :)
BTW, if you need help with anything else on the project then gimme a bell, no problems :)
Great!!! I will if I need
BTW, you're invited (if U want) to download the last version of my app (posted in my signature)
Hello, Can you tell me how you're writing the ID3v2 Tag at the begining of the file without overwriting.
I need to write tag but i don't know how :
- not to overwrite existing data if it's not a id3v2 tag
- Erase the previous id3v2 Tag
Thank you for your answer.
BTW, the 250 or 251 behind the 255 byte in the header is only for mpeg1 layer3. If you want to have the info for other mpeg format, or other layer, it will not work (I see you're searching the layer and mpeg format in your code)
I load all the file (ID3's tags and audio) in a string. I add the tag at the beginning (or edit it if it already exists), and write all the new string into the file
Yeah, the 250 - 251 rule only applies to MP3 files. Obviously, multiple layer MPEG encoders would serach for a wide range of headrers but he dosent need to as hes only making an MP3 player.
Actually, what I'm making is not the player. It's pretty far from that. BTW, I have no idea how to do a player.Quote:
Originally posted by Bazza81
Yeah, the 250 - 251 rule only applies to MP3 files. Obviously, multiple layer MPEG encoders would serach for a wide range of headrers but he dosent need to as hes only making an MP3 player.
If you decide to make a player. Go to my websiter. I have plenty of modules, examples, and a tutorial on playing a many media files. :)
Bazza.... I've got an MP3 that's MPEG2-Layer 3. What's that?? This code does not work with this MP3. How could I solve this?