Hi,
I want to do the screen capture(1920*1080) via DirectX function GetFrontBufferData, and use IDirect3DSurface9 with input for h.264 encoder,
but the encoder is without any output video file, here is the my code(modification by smaple code) and the log data by mediasdk_tracer.
Could you help to check which items I need to modify, thanks.
//Run Encoder
while (MFX_ERR_NONE <= sts || MFX_ERR_MORE_DATA == sts )
{
sts = GetFreeTask(&pCurrentTask);
MSDK_BREAK_ON_ERROR(sts);
nEncSurfIdx = GetFreeSurface(m_pEncSurfaces, m_EncResponse.NumFrameActual);
MSDK_CHECK_ERROR(nEncSurfIdx, MSDK_INVALID_SURF_IDX, MFX_ERR_MEMORY_ALLOC);
pSurf = &m_pEncSurfaces[nEncSurfIdx];
if (m_bExternalAlloc)
{
sts = m_pMFXAllocator->Lock(m_pMFXAllocator->pthis, pSurf->Data.MemId, &(pSurf->Data));
}
MSDK_BREAK_ON_ERROR(sts);
pSurf->Info.FrameId.ViewId = currViewNum;
g_pd3dDevice->GetFrontBufferData(0,pSurf->Data.MemId);
if (m_bExternalAlloc)
{
sts = m_pMFXAllocator->Unlock(m_pMFXAllocator->pthis, pSurf->Data.MemId, &(pSurf->Data));
}
MSDK_BREAK_ON_ERROR(sts);
for (;;)
{
sts = m_pmfxENC->EncodeFrameAsync(NULL, &m_pEncSurfaces[nEncSurfIdx], &pCurrentTask->mfxBS, &pCurrentTask->EncSyncP);
if (MFX_ERR_NONE < sts && !pCurrentTask->EncSyncP)
{
if (MFX_WRN_DEVICE_BUSY == sts)
MSDK_SLEEP(1);
}
else if (MFX_ERR_NONE < sts && pCurrentTask->EncSyncP)
{
sts = MFX_ERR_NONE; // ignore warnings if output is available
break;
}
else if (MFX_ERR_NOT_ENOUGH_BUFFER == sts)
{
sts = AllocateSufficientBuffer(&pCurrentTask->mfxBS);
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
}
else
{
MSDK_IGNORE_MFX_STS(sts, MFX_ERR_MORE_BITSTREAM);
break;
}
}
}



