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
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
i am using sink writer to write sample.
here is the code:
while(true){
hr = dxgiOutputDuplication->AcquireNextFrame(0, &frame_info, &resource);
if (SUCCEEDED(hr)) {
ID3D11Texture2D* texture = NULL;
hr = resource->QueryInterface(__uuidof(ID3D11Texture2D), (void**)&texture);
if (SUCCEEDED(hr)) {
IDXGISurface* dxgiSurface = NULL;
hr = texture->QueryInterface(__uuidof(IDXGISurface), (void**)&dxgiSurface);
if (SUCCEEDED(hr)) {
IMFSample* sample = NULL;
hr = MFCreateSample(&sample);
if (SUCCEEDED(hr)) {
IMFMediaBuffer* buffer = NULL;
hr = MFCreateDXGISurfaceBuffer(__uuidof(ID3D11Texture2D), dxgiSurface, 0, FALSE, &buffer);
if (SUCCEEDED(hr)) {
hr = sample->AddBuffer(buffer);
hr = sample->SetSampleDuration(duration);
hr = presentation->GetTime(&sampleTime);
hr = sample->SetSampleTime(sampleTime);
//sampleTime += duration * 10;
DWORD length = 0;
IMF2DBuffer* imf_buffer = NULL;
hr = buffer->QueryInterface(__uuidof(IMF2DBuffer), (void**)&imf_buffer);
if (SUCCEEDED(hr)) {
hr = imf_buffer->GetContiguousLength(&length);
hr = buffer->SetCurrentLength(length);
hr = writer->WriteSample(0, sample);
if (FAILED(hr)) {
OutputDebugString(L"FAILED WRITE SAMPLE\n");
}
o++;
if (o > 1920) {
writer->Finalize();
OutputDebugString(L"OOOOOOOOOO");
break;
}
imf_buffer->Release();
imf_buffer = NULL;
}
buffer->Release();
buffer = NULL;
}
sample->Release();
sample = NULL;
}
dxgiSurface->Release();
dxgiSurface = NULL;
}
texture->Release();
texture = NULL;
}
resource->Release();
resource = NULL;
}
dxgiOutputDuplication->ReleaseFrame();
}
and this is the example code:https://github.com/ljzj2/testdemo1