how to combine multi-IMFSample to one?

mc 4,436 Reputation points
2024-08-19T01:07:55.5766667+00:00

I have three IMFSamples and how to combine them to one?

there will be three computers which run my program and they will push IMFSample to me.

and I want to combine them to one. in to same screen.(same texture).

User's image

split a texture into 3 and copy one to each of them.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,592 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,693 questions
{count} votes

Accepted answer
  1. Tong Xu - MSFT 2,456 Reputation points Microsoft Vendor
    2024-08-19T03:28:17.0833333+00:00

    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?

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.