locked
IMFMediaEngine crash

    Question

  • I ran the "Windows 8 Media engine native C++ video playback sample in C++" 

    with no problems. When I tried to use the sample code in our project, shortly after loading a file (that plays with no errors in the sample) it throws up two exceptions. Then every call to IMFMediaEngine::TransferVideoFrame() returns MF_E_INVALIDMEDIATYPE no matter what video file I try to load. I've tried loading WVC1, h264, WMV4 and MP4 videos. All the files I've tried work in the original sample.

    Do you have any idea or information as to what could be causing the crash?

    The call stacks from the two exceptions are below:

    >             KernelBase.dll!_RaiseException@16 ()  Unknown
                    msvcrt.dll!__CxxThrowException@8 () Unknown
                    d3d11.dll!_memcmp () Unknown
                    d3d11.dll!_memcmp () Unknown
                    d3d11.dll!CDevice::QIVideoDevice(void *,struct _GUID const &,void * *,unsigned long)                Unknown
                    d3d11.dll!ATL::AtlInternalQueryInterface(void *,struct ATL::_ATL_INTMAP_ENTRY const *,struct _GUID const &,void * *)          Unknown
                    d3d11.dll!ATL::CComObjectRootBase::InternalQueryInterface(void *,struct ATL::_ATL_INTMAP_ENTRY const *,struct _GUID const &,void * *)              Unknown
                    d3d11.dll!ATL::CComObjectRootBase::_Delegate(void *,struct _GUID const &,void * *,unsigned long)   Unknown
                    d3d11.dll!ATL::AtlInternalQueryInterface(void *,struct ATL::_ATL_INTMAP_ENTRY const *,struct _GUID const &,void * *)          Unknown
                    d3d11.dll!ATL::CComObjectRootBase::InternalQueryInterface(void *,struct ATL::_ATL_INTMAP_ENTRY const *,struct _GUID const &,void * *)              Unknown
                    d3d11.dll!CLayeredObject<class NDXGI::CDevice>::QueryInterface(struct _GUID const &,void * *)          Unknown
                    d3d11_1sdklayers.dll!NDebug::CDevice::QIVideoDevice(void *,struct _GUID const &,void * *,unsigned long)                Unknown
                    d3d11_1sdklayers.dll!ATL::AtlInternalQueryInterface(void *,struct ATL::_ATL_INTMAP_ENTRY const *,struct _GUID const &,void * *)               Unknown
                    d3d11_1sdklayers.dll!CLayeredObject<class NDebug::CDevice>::_InternalQueryInterface(struct _GUID const &,void * *,struct ATL::_ATL_INTMAP_ENTRY const *)     Unknown
                    d3d11_1sdklayers.dll!CLayeredObject<class NDebug::CDevice>::QueryInterface(struct _GUID const &,void * *)                Unknown
                    d3d11.dll!TComObject<class NOutermost::CDevice>::QueryInterface(struct _GUID const &,void * *)     Unknown
                    d3d11_1sdklayers.dll!CLayeredObject<class NDebug::CDevice>::CContainedObject::QueryInterface(struct _GUID const &,void * *)              Unknown
                    mfsvr.dll!IsD3D11VideoSupported(class TSmartPointer<struct ID3D11Device> &)             Unknown
                    mfsvr.dll!CXVPDrawDevice::CreateXVP(void)     Unknown
                    mfsvr.dll!CXVPDrawDevice::Initialize(struct IUnknown *,enum DXGI_FORMAT)                Unknown
                    mfsvr.dll!RefCounted<class CXVPDrawDevice,struct MultiThreadedRefCount>::Create<struct ISimpleDrawDevice,struct IUnknown *,enum DXGI_FORMAT>(struct IUnknown *,enum DXGI_FORMAT,class TSmartPointer<struct ISimpleDrawDevice> &)   Unknown
                    mfsvr.dll!CreateXVPDrawDevice(struct IUnknown *,enum DXGI_FORMAT,struct ISimpleDrawDevice * *)                Unknown
                    mfsvr.dll!CSimpleVRStreamSink::Initialize(class CSimpleVRSink *,class TSmartPointer<struct IMFAttributes> &)                Unknown
                    mfsvr.dll!CreateSVRStreamSink(class CSimpleVRSink *,class CCriticalSection *,class TSmartPointer<struct IMFAttributes> &,class CSimpleVRStreamSink * *)           Unknown
                    mfsvr.dll!CSimpleVRSink::Initialize(class TSmartPointer<struct IMFAttributes> &)             Unknown
                    mfsvr.dll!RefCounted<class CSimpleVRSink,struct MultiThreadedRefCount>::Create<struct IMFMediaSink,class TSmartPointer<struct IMFAttributes> >(class TSmartPointer<struct IMFAttributes>,class TSmartPointer<struct IMFMediaSink> &)          Unknown
                    mfsvr.dll!CreateSVR(class TSmartPointer<struct IMFAttributes> &,struct IMFMediaSink * *)      Unknown
                    mfsvr.dll!CSimpleVRActivate::CreateMediaSink(void)    Unknown
                    mfsvr.dll!CSimpleVRActivate::ActivateObject(struct _GUID const &,void * *)      Unknown
                    mfcore.dll!6c197c48()    Unknown
                    [Frames below may be incorrect and/or missing, no symbols loaded for mfcore.dll]         
                    mfcore.dll!6c197b75()    Unknown
                    mfcore.dll!6c193e39()    Unknown
                    mfcore.dll!6c193a12()    Unknown
                    mfcore.dll!6c241db6()   Unknown
                    mfcore.dll!6c241fc9()     Unknown
                    mfplat.dll!CSerialWorkQueue::QueueItem::ExecuteWorkItem(struct IMFAsyncResult *)              Unknown
                    mfplat.dll!CSerialWorkQueue::QueueItem::OnWorkItem(struct IMFAsyncResult *)        Unknown
                    mfplat.dll!CSerialWorkQueue::QueueItem::OnWorkItemAsyncCallback::Invoke(struct IMFAsyncResult *)                Unknown
                    mfplat.dll!CosWorkItem::~CosWorkItem(void)  Unknown
                    mfplat.dll!GetThreadData(unsigned long)            Unknown
                    ntdll.dll!_TppTimerpExecuteCallback@8 ()          Unknown
                    ntdll.dll!_TppWorkerThread@4 ()            Unknown
                    kernel32.dll!@BaseThreadInitThunk@12 ()         Unknown
                    ntdll.dll!___RtlUserThreadStart@8 ()     Unknown
                    ntdll.dll!__RtlUserThreadStart@8 ()       Unknown
     
     
    //----------------------------------------------------------------------------------
     
    >             KernelBase.dll!_RaiseException@16 ()  Unknown
                    msvcrt.dll!__CxxThrowException@8 () Unknown
                    d3d11.dll!_memcmp () Unknown
                    d3d11.dll!_memcmp () Unknown
                    d3d11.dll!CDevice::QIVideoDevice(void *,struct _GUID const &,void * *,unsigned long)                Unknown
                    d3d11.dll!ATL::AtlInternalQueryInterface(void *,struct ATL::_ATL_INTMAP_ENTRY const *,struct _GUID const &,void * *)          Unknown
                    d3d11.dll!ATL::CComObjectRootBase::InternalQueryInterface(void *,struct ATL::_ATL_INTMAP_ENTRY const *,struct _GUID const &,void * *)              Unknown
                    d3d11.dll!ATL::CComObjectRootBase::_Delegate(void *,struct _GUID const &,void * *,unsigned long)   Unknown
                    d3d11.dll!ATL::AtlInternalQueryInterface(void *,struct ATL::_ATL_INTMAP_ENTRY const *,struct _GUID const &,void * *)          Unknown
                    d3d11.dll!ATL::CComObjectRootBase::InternalQueryInterface(void *,struct ATL::_ATL_INTMAP_ENTRY const *,struct _GUID const &,void * *)              Unknown
                    d3d11.dll!CLayeredObject<class NDXGI::CDevice>::QueryInterface(struct _GUID const &,void * *)          Unknown
                    d3d11_1sdklayers.dll!NDebug::CDevice::QIVideoDevice(void *,struct _GUID const &,void * *,unsigned long)                Unknown
                    d3d11_1sdklayers.dll!ATL::AtlInternalQueryInterface(void *,struct ATL::_ATL_INTMAP_ENTRY const *,struct _GUID const &,void * *)               Unknown
                    d3d11_1sdklayers.dll!CLayeredObject<class NDebug::CDevice>::_InternalQueryInterface(struct _GUID const &,void * *,struct ATL::_ATL_INTMAP_ENTRY const *)     Unknown
                    d3d11_1sdklayers.dll!CLayeredObject<class NDebug::CDevice>::QueryInterface(struct _GUID const &,void * *)                Unknown
                    d3d11.dll!TComObject<class NOutermost::CDevice>::QueryInterface(struct _GUID const &,void * *)     Unknown
                    d3d11_1sdklayers.dll!CLayeredObject<class NDebug::CDevice>::CContainedObject::QueryInterface(struct _GUID const &,void * *)              Unknown
                    mfplat.dll!CMFDXGIDeviceManager::GetVideoService(void *,struct _GUID const &,void * *)     Unknown
                    WMVDECOD.DLL!58ee276a()     Unknown
                    [Frames below may be incorrect and/or missing, no symbols loaded for WMVDECOD.DLL]           
                    WMVDECOD.DLL!58ee36d3()     Unknown
                    mfcore.dll!6c1ddf7c()    Unknown
                    mfcore.dll!6c1dfaf5()     Unknown
                    mfsvr.dll!RefCounted<class CSimpleVRSink,struct MultiThreadedRefCount>::AddRef(void)        Unknown
                    mfsvr.dll!RefCounted<class CSimpleVRSink,struct MultiThreadedRefCount>::Release(void)        Unknown
                    mfsvr.dll!CSimpleVRStreamSink::Release(void) Unknown
                    613fc28b()           Unknown
                    mfcore.dll!6c15f67e()    Unknown
                    mfcore.dll!6c1e675d()   Unknown
                    mfcore.dll!6c1db8d6()   Unknown
                    mfcore.dll!6c1db680()   Unknown
                    mfcore.dll!6c1db50d()   Unknown
                    mfcore.dll!6c1daf16()    Unknown
                    mfcore.dll!6c193e62()    Unknown
                    mfcore.dll!6c193a12()    Unknown
                    mfcore.dll!6c241db6()   Unknown
                    mfcore.dll!6c241fc9()     Unknown
                    mfplat.dll!CSerialWorkQueue::QueueItem::ExecuteWorkItem(struct IMFAsyncResult *)              Unknown
                    mfplat.dll!CSerialWorkQueue::QueueItem::OnWorkItem(struct IMFAsyncResult *)        Unknown
                    mfplat.dll!CSerialWorkQueue::QueueItem::OnWorkItemAsyncCallback::Invoke(struct IMFAsyncResult *)                Unknown
                    mfplat.dll!CosWorkItem::~CosWorkItem(void)  Unknown
                    mfplat.dll!GetThreadData(unsigned long)            Unknown
                    ntdll.dll!_TppTimerpExecuteCallback@8 ()          Unknown
                    ntdll.dll!_TppWorkerThread@4 ()            Unknown
                    kernel32.dll!@BaseThreadInitThunk@12 ()         Unknown
                    ntdll.dll!___RtlUserThreadStart@8 ()     Unknown
                    ntdll.dll!__RtlUserThreadStart@8 ()       Unknown
    


    Thursday, March 21, 2013 6:13 PM

Answers

  • Managed to work out the solution - firstly, the exceptions were because I hadn't set my D3D device to be multithreaded. This caused memory corruption.

            ComPtr<ID3D10Multithread> spMultithread;
            MEDIA::ThrowIfFailed(
                m_spDX11Device.Get()->QueryInterface(IID_PPV_ARGS(&spMultithread))
                );
            spMultithread->SetMultithreadProtected(TRUE);

    Secondly, the texture format set in the Media Engine was BGRA and my code was trying to display ARGB textures! I hadn't realised the MF_E_INVALIDMEDIATYPE  error was referring to the texture format, not the video!

    • Marked as answer by AJMeredith Sunday, March 24, 2013 1:22 PM
    Sunday, March 24, 2013 1:22 PM

All replies

  • To clarify, I'm attempting to copy into a ID3D11Texture2D for rendering, rather than a swap chain back buffer. Both the texture and the IMF engine use the DXGI_FORMAT_B8G8R8A8_UNORM format.

    Thursday, March 21, 2013 6:36 PM

  • How about the sample codes works without any change on your side?

    Best regards,
    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, March 22, 2013 6:03 AM
  • Sorry, I don't understand your question. The sample code works correctly without any changes. When I try and use the code in my project to render a video to an ID3D11Texture2D I get the crashes an error messages.
    Friday, March 22, 2013 9:16 AM
  • Managed to work out the solution - firstly, the exceptions were because I hadn't set my D3D device to be multithreaded. This caused memory corruption.

            ComPtr<ID3D10Multithread> spMultithread;
            MEDIA::ThrowIfFailed(
                m_spDX11Device.Get()->QueryInterface(IID_PPV_ARGS(&spMultithread))
                );
            spMultithread->SetMultithreadProtected(TRUE);

    Secondly, the texture format set in the Media Engine was BGRA and my code was trying to display ARGB textures! I hadn't realised the MF_E_INVALIDMEDIATYPE  error was referring to the texture format, not the video!

    • Marked as answer by AJMeredith Sunday, March 24, 2013 1:22 PM
    Sunday, March 24, 2013 1:22 PM