locked
Can anyone get IMFMediaEngine->TransferVideoFrame() to work with an IWICBitmap? RRS feed

  • Question

  • I've been searching around and seen this question asked in a couple places but never with any reply.

    Working from the media engine sample:

    https://code.msdn.microsoft.com/windowsapps/Media-Engine-Playback-ce1c82f0

    All I've done is add construction of an IWICBitmap:

    MEDIA::ThrowIfFailed(
    CoCreateInstance(CLSID_WICImagingFactory,
    NULL, CLSCTX_INPROC_SERVER,
    IID_PPV_ARGS(&mPiFactory))
    );

    MEDIA::ThrowIfFailed(
    &mWicBitmap)
    mPiFactory->CreateBitmap(640, 480, GUID_WICPixelFormat24bppBGR, WICBitmapCacheOnDemand, &mWicBitmap)
    &mWicBitmap)
    );

    and then in OnTimer(), added this above the current TransferVideoFrame:

    m_spMediaEngine->TransferVideoFrame(mWicBitmap.Get(), nullptr, &r, &m_bkgColor);

    but it always fails. I've tried adding the MFVideoNormalizedRect arg (0, 0, 1, 1), but that makes no difference.

    I've tried using different pixel formats for the WICBitmap, which varies the error a little. I.e.,

    GUID_WICPixelFormat24bppRGB

    GUID_WICPixelFormat24bppBGR

    give me "One or more arguments are invalid."

    I've tried matching the format that the sample's DX11 texture is created in but

    GUID_WICPixelFormat32bppBGRA

    gives me "No such interface supported."

    Is there something obvious I'm missing here?

    thanks much!

    Sunday, January 17, 2016 7:23 PM

Answers

  • I figured it out -- remove this line

                spAttributes->SetUnknown(MF_MEDIA_ENGINE_DXGI_MANAGER, (IUnknown*) m_spDXGIManager.Get())

    when constructing the MediaEngine. The whole decode path now won't use hardware acceleration, so apparently you can't mix hardware decoding with getting the frame data via WIC. Or if you can, I don't know how to do it. So now I guess the question is, is it faster to use DX11 and get any hardware acceleration, but go through an extra copy at the end to get the data, or faster to do this. I'd guess the DX11 path would typically be much faster on most hardware, but that's a question for another day.

    • Marked as answer by hackborn Sunday, January 17, 2016 11:18 PM
    Sunday, January 17, 2016 11:16 PM