Log in

View Full Version : How the ffdshow pase the "vol" segment of a I frame that encoded by x264


shallway
21st July 2005, 10:27
I compress a video clip by using x264_vfw codec to a avi file from the virtual Dub. I find that a first frame is a I frame. After "00dc" ,the hex data is below:

---------------------------------------------------------
90 02 00 00 00 00 00 01 06 05 7f dc 45 e9 bd e6
... ...
80 00 00 00 01 67 42 00 28 9a 74 0a 05 34 20 01
e8 48 20 01 e8 48 10 80 00 00 00 01 68 ce 3c 80
00 00 00 01 65 88 80 20 00 2d 7f ff e1 e8 a0 00
20 b1 e4 ... ...
---------------------------------------------------------

the first segment between two "00 00 00 01" indications is the SEI, and the second and third are available for the ffdshow decoder. I found that when I convert the avi file to mp4 file by mp4creator the I frame's head data has been changed, the "00 00 00 01" indication has chenged to the length of the following segment, for example the first " 00 00 00 01" --> "00 00 00 83" and the second and third segment have been erased, the fore 4 bytes are below:

----------------------------------------------------------
00 00 00 83 ... ...
----------------------------------------------------------

when I intercept the frame data from the mp4 file and pass it to the ffdshow h264 decoder(libavcodec.dll) through the ICMDecompress() func, and it return -1 that showes the data is not available. when I intercept a complete I frame from the avi file that begin with the "00 00 00 01" indication, the decoder can work correctly.

I guess that the input data is not availabe for the decoder. Who can help me to explain the "vol" of the head of the I frame and which "vol" format that the decoder can recognizied.

Thank you very much!!!

bond
21st July 2005, 20:01
avc doesnt have a "vol" as asp, it has sps and pps

00 00 00 01 67 is the SPS, little bit after that there should also be 00 00 00 01 68 (thats the PPS) and after that 00 00 00 01 65 (thats the keyframe)

afaik when x264 outputs a raw stream it writes the userdata SEI at the beginning. afaik the mp4 muxers move the SEI after the PPS, dunno why

btw you can not make direct .avi -> .mp4 conversions, you have to go via raw .264 in between

shallway
22nd July 2005, 02:16
Thank you very much, I have learned a lot from you.

Now my question is that the I frame head in the mp4 file is diff from that in the avi file such as the "00 00 00 01" indication has been changed to "00 00 00 83"(the length of the following segment), thereby the libavcodec.dll can not decoder the frame any more. but I found that the MPC(Media Player Classic) can play the mp4 file, it use the libavcodec.dll to decode, how does it work? It change the head indicaition back for example "00 00 00 83"-->"00 00 00 01"?

Thank you very much

bond
22nd July 2005, 09:38
SPS, PPS and SEI are indicated the same way in .mp4 as in .avi and .264 of course as the stream itself isnt changed

i assume you are simply looking at the wrong values

shallway
26th July 2005, 07:39
Because I don't know the libavcode(h264) parse the packetization mode of the h264 nal. For example, the "00 00 00 01" indicator can be recgnized by it , but that the FU-A and the SPS, PPS nal not.

SPS:
in avi file: 00 00 00 01 67 .. ..
rec from rtp: 78 00 12 67 .. ..

FU-A:
in avi file: 00 00 00 01 65 .. ..
rec from rtp: 7c 85 65 .. ..

If I should change the "78 00 12" and "7c 85" to "00 00 00 01" so that the ffdshow libavcodec(h264) can decode it.

Thank you.

bond
26th July 2005, 10:58
merged with this thread as i think the two belong together?