Just set one buffer for the video frame.
IMFSample* pSample = NULL;
IMFMediaBuffer* pBuffer = NULL;
const LONG cbWidth = 4 * uiWidth;
const DWORD cbBuffer = cbWidth * uiHeight;
BYTE* pData = NULL;
// Create a new memory buffer.
hr = MFCreateMemoryBuffer(cbBuffer, &pBuffer);
// Lock the buffer and copy the video frame to the buffer.
if (SUCCEEDED(hr)) {
hr = pBuffer->Lock(&pData, NULL, NULL);
}
if (SUCCEEDED(hr)) {
#ifdef REVERSE_IMAGE
for (int i = 0, j = uiHeight - 1; i < uiHeight; i++, j--)
for (int k = 0; k < cbWidth; k++)
pData[(i * cbWidth) + k] = ((BYTE*)rc.pBits)[(j * cbWidth) + k];
#else
hr = MFCopyImage(pData, cbWidth, (BYTE*)rc.pBits, rc.Pitch, cbWidth, uiHeight);
#endif
}
if (pBuffer) {
pBuffer->Unlock();
}
// Set the data length of the buffer.
if (SUCCEEDED(hr)) {
hr = pBuffer->SetCurrentLength(cbBuffer);
}
// Create a media sample and add the buffer to the sample.
if (SUCCEEDED(hr)) {
hr = MFCreateSample(&pSample);
}
if (SUCCEEDED(hr)) {
hr = pSample->AddBuffer(pBuffer);
}
// Set the time stamp and the duration.
if (SUCCEEDED(hr)) {
hr = pSample->SetSampleTime(rtStart);
}
if (SUCCEEDED(hr)) {
hr = pSample->SetSampleDuration(VIDEO_FRAME_DURATION);
}
// Send the sample to the Sink Writer.
if (SUCCEEDED(hr)) {
hr = pWriter->WriteSample(streamIndex, pSample);
}
hr = pSurface->UnlockRect();
SafeRelease(&pSample);
SafeRelease(&pBuffer);
return hr;
May I ask how did you combine three videos to one from 3 computers? Any samples?