- now I am using media foundation to process h264 data and it is live data.
- receive data by socket
- MFCreateMemoryBuffer to create IMFMediaBuffer and copy the data to the buffer
- MFCreateSample
- ProcessInput to pass the sample created.
- get outputData.
now my question is when I first receive data and ProcessInput it is all right. but then I will receive some small data (may be only 3kb?) and the image is not right and will lack something(only part of the whole right image).
so I think it does not receive the whole data needed to to IMFTransform so I will keep the data until it is 30kb(or other larger) and then go to MFCreateMemoryBuffer.
yes now the image frame is right until the last frame.
so I guess I do not get the whole right data of one Frame right? how to get the right size of one completely IMFSample(Frame)?
Here is a sample code that decodes an H264 stream of bytes using Media Foundation H.264 Video Decoder transform.
It simulates the stream of various-sized chunks of bytes using a file but the principles are the same.
Key points:
Full project is available here https://github.com/smourier/MFDecodeH264