使用原始数据字节逐帧播放

Playback using Raw Data Bytes Frame by Frame

我有一个由 H264.Now 编码的字节流 我想使用 Media Foundation 进行播放 我将这些帧作为没有容器的原始数据,并且我通过 frame.does 接收它的帧 任何人都知道我该怎么做?

下面的代码片段演示了如何从字节缓冲区创建 IMFSample 对象。获得 IMFSample 后,可以将其提供给 MF 增强型视频渲染器。

MFCreateSample(&reConstructedVideoSample); 
CHECK_HR(MFCreateMemoryBuffer(srcBufLength, &reConstructedBuffer), "Failed to create memory buffer.\n"); 
CHECK_HR(reConstructedVideoSample->AddBuffer(reConstructedBuffer), "Failed to add buffer to re-constructed sample.\n"); 
CHECK_HR(reConstructedVideoSample->SetSampleTime(llVideoTimeStamp), "Error setting the re-constructed video sample time.\n"); 
CHECK_HR(reConstructedVideoSample->SetSampleDuration(llSampleDuration), "Error setting re-constructed video sample duration.\n"); 

byte *reconByteBuffer; 
DWORD reconBuffCurrLen = 0; 
DWORD reconBuffMaxLen = 0; 
CHECK_HR(reConstructedBuffer->Lock(&reconByteBuffer, &reconBuffMaxLen, &reconBuffCurrLen), "Error locking re-constructed buffer.\n"); 
memcpy(reconByteBuffer, srcByteBuffer, srcBuffCurrLen);         // srcByteBuffer is a byte * that contains the sample video data read from file.
CHECK_HR(reConstructedBuffer->Unlock(), "Error unlocking re-constructed buffer.\n"); 
reConstructedBuffer->SetCurrentLength(srcBuffCurrLen);