BurZum
30th June 2006, 20:26
I currently trying to get an application that stores and streams h.264 video to work propperly. Put simply is there anyone that knows how to properly read the data in the frame header.
Example frame:
01 00 00 00 13 11 00 00 FC 02 00 00 00 10 00 00
01 10 00 00 C0 02 20 01 01 10 00 00 19 10 00 00
00 00 00 00 00 00 00 00 00 00 00 00 11 D5 BC 19
03 10 03 00 4C 00 00 00 0E 00 00 00 0F 02 00 00
A0 AC 00 00 00
From this I get (the application handles this as far as I can see):
Type: IFrame
Length 00 00 A0 AC
Now for a problem frame:
01 00 00 00 14 11 00 00 FF 02 00 00 01 10 00 00
02 10 00 00 C0 02 20 01 07 10 00 00 19 10 00 00
00 00 00 00 00 00 00 00 00 00 00 00 11 D5 BC 19
01 10 00 00 53 00 00 00 0E 00 00 00 09 02 00 00
50 00 00 00 00
Time 00000304
Length 50
Frametype PktAudioFrames
The length isn't 50 (hex) now if I cheat and add 100 to the length of this one will not generate any problems. But this is not good at all.
Last frame but not least!:
01 00 00 00 F3 11 00 00 33 05 00 00 01 10 00 00
03 10 00 00 C0 02 20 01 07 10 00 00 19 10 00 00
00 00 00 00 00 00 00 00 00 00 00 00 1A D5 BC 19
01 10 00 00 43 00 00 00 0E 00 00 00 10 02 00 00
50 00 00 00 00
Time 00000533
Length 50
Frametype PktBBPFrames
This one also shows 50 and I have no idea what to do with this.
Everything works fine if I disable audio but once audio is on it doesn't work at all! I suspect that Audio frames are completely different with respect to decoding but I have had great difficulty finding this kind of information.
Here is some quick and dirty sample code (this is VB.NET / the actual application is C++):
Private Function GetFrameType(ByVal arbyFrameData() As Byte) As eFrameType
Dim byImgType As Byte = arbyFrameData(16)
Dim eReturn As eFrameType
Select Case (byImgType)
Case 1
If (arbyFrameData(12) = 1) Then
eReturn = eFrameType.PktAudioFrames
Else
If (arbyFrameData(24) = 1) Then
eReturn = eFrameType.PktIFrames
Else
eReturn = eFrameType.PktPFrames
End If
End If
Case 2
eReturn = eFrameType.PktAudioFrames
Case 3
eReturn = eFrameType.PktBBPFrames
Case Else
eReturn = eFrameType.PktError
End Select
Return eReturn
End Function
Private Function GetFrameLength(ByVal arData() As Byte) As Long
Dim szReturn As String
szReturn = "&h" & lz2(Hex(arData(67))) & lz2(Hex(arData(66))) & lz2(Hex(arData(65))) & lz2(Hex(arData(64)))
Return CLng(szReturn)
End Function
Private Function GetSubframeLength(ByVal arData() As Byte) As Long
Dim szReturn As String
szReturn = "&h" & lz2(Hex(arData(19))) & lz2(Hex(arData(18))) & lz2(Hex(arData(17))) & lz2(Hex(arData(16)))
Return CLng(szReturn)
End Function
Help or pointers will be greately appreciated.
Example frame:
01 00 00 00 13 11 00 00 FC 02 00 00 00 10 00 00
01 10 00 00 C0 02 20 01 01 10 00 00 19 10 00 00
00 00 00 00 00 00 00 00 00 00 00 00 11 D5 BC 19
03 10 03 00 4C 00 00 00 0E 00 00 00 0F 02 00 00
A0 AC 00 00 00
From this I get (the application handles this as far as I can see):
Type: IFrame
Length 00 00 A0 AC
Now for a problem frame:
01 00 00 00 14 11 00 00 FF 02 00 00 01 10 00 00
02 10 00 00 C0 02 20 01 07 10 00 00 19 10 00 00
00 00 00 00 00 00 00 00 00 00 00 00 11 D5 BC 19
01 10 00 00 53 00 00 00 0E 00 00 00 09 02 00 00
50 00 00 00 00
Time 00000304
Length 50
Frametype PktAudioFrames
The length isn't 50 (hex) now if I cheat and add 100 to the length of this one will not generate any problems. But this is not good at all.
Last frame but not least!:
01 00 00 00 F3 11 00 00 33 05 00 00 01 10 00 00
03 10 00 00 C0 02 20 01 07 10 00 00 19 10 00 00
00 00 00 00 00 00 00 00 00 00 00 00 1A D5 BC 19
01 10 00 00 43 00 00 00 0E 00 00 00 10 02 00 00
50 00 00 00 00
Time 00000533
Length 50
Frametype PktBBPFrames
This one also shows 50 and I have no idea what to do with this.
Everything works fine if I disable audio but once audio is on it doesn't work at all! I suspect that Audio frames are completely different with respect to decoding but I have had great difficulty finding this kind of information.
Here is some quick and dirty sample code (this is VB.NET / the actual application is C++):
Private Function GetFrameType(ByVal arbyFrameData() As Byte) As eFrameType
Dim byImgType As Byte = arbyFrameData(16)
Dim eReturn As eFrameType
Select Case (byImgType)
Case 1
If (arbyFrameData(12) = 1) Then
eReturn = eFrameType.PktAudioFrames
Else
If (arbyFrameData(24) = 1) Then
eReturn = eFrameType.PktIFrames
Else
eReturn = eFrameType.PktPFrames
End If
End If
Case 2
eReturn = eFrameType.PktAudioFrames
Case 3
eReturn = eFrameType.PktBBPFrames
Case Else
eReturn = eFrameType.PktError
End Select
Return eReturn
End Function
Private Function GetFrameLength(ByVal arData() As Byte) As Long
Dim szReturn As String
szReturn = "&h" & lz2(Hex(arData(67))) & lz2(Hex(arData(66))) & lz2(Hex(arData(65))) & lz2(Hex(arData(64)))
Return CLng(szReturn)
End Function
Private Function GetSubframeLength(ByVal arData() As Byte) As Long
Dim szReturn As String
szReturn = "&h" & lz2(Hex(arData(19))) & lz2(Hex(arData(18))) & lz2(Hex(arData(17))) & lz2(Hex(arData(16)))
Return CLng(szReturn)
End Function
Help or pointers will be greately appreciated.