locked
IMFMediaEngine crash using DirectX 11.0 RRS feed

  • Question

  • Hi,

    I tried to run this IMFMediaEngine sample on a Windows 8 Pro 64 machine using Visual Studio 2012 and Windows SDK 8.0:

    http://code.msdn.microsoft.com/windowsapps/media-engine-playback-ce1c82f0


    My machine has a GeForce GTS 450 with the latest drivers and it always crashed when calling IMFMediaEngine:TransferVideoFrame. I saw that the D3D Device initialized at application startup always returned DX level 11.0 (which is normal as my Graphics Card doesn't support level 11.1) but the Sample code explicitly request level 11.1. So, I switched D3D Device initialization to D3D_DRIVER_TYPE_WARP (software mode) which allowed the Device to be set at level 11.1 and then, the Sample ran perfectly without any error!


    My question is:

    Do I really need to have a DirectX 11.1 graphics card to use the IMFMediaEngine or is it a bug in the API?

    There are nowdays few cards supporting level 11.1 that's why I asking this question.

    Then, I tried to use the IMFMediaEngine in my own application and I felt that I HAD TO use a different D3D Device than my own application's Device to Initialize the IMFMediaEngine. I don't know what the IMFMediaEngine does with the D3D Device but if I'm using a different device than the one my application uses, I need to use shared resources between the two Device to copy texture from one to another. Which make me thing about timing issue. I pretty sure I'll end up with a frame delay, the video image I'll get won't be sync with the audio anymore.

    Can someone give me some light about the use of the IMFMediaEngine? How should I use it to be able to get video images and display them on a texture on a mesh in my D3D application?

    In theory, the MediaEngine seems to be the appropriate solution as it plays the media and then, I should, I theory, only have to call IMFMediaEngine:TransferVideoFrame to get the current video frame on a texture.


    • Edited by Damien0000 Monday, January 28, 2013 1:30 PM
    Monday, January 28, 2013 1:29 PM

All replies

  • I found out it the crash in IMFMediaEngine::TransferVideoFrame came from my NVidia card.

    Reading this post:

    http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/2f467b60-a99b-481d-baa1-fe0be124d8bb

    Made me wanted to try the sample on an AMD card.

    So, I tested the IMFMediaEngine sample on an AMD Radeon HD 5770 (DX 11.0) and it works fine!

    Does anyone know why this seems only to happen on NVidia cards?

    I still can't get the video on a texture in my app though but still working on it...

    Tuesday, January 29, 2013 10:57 AM
  • I finally managed to make it work between two different DX11 devices but it also works between a DX9 and DX11 Device!

    -----------------------------------------

    1- Copy playback to texture SOLVED (partially)

    Based on this page:

    http://msdn.microsoft.com/en-gb/library/windows/desktop/bb173598%28v=vs.85%29.aspx


    I used the ID3D10Device::OpenSharedResource function to create a shared texture (named "Text00") on my Media Engine DX11 Device, then I created a texture (named "Text01") on my Application DX11 Device using OpenSharedResource with the HANDLE corresponding to Text00. After that, I just needed to pass Text00 to the IMFMediaEngine::TransferVideoFrame function and Text01 was automatically updated without doing any CopyResource or so!



    But I observed that in my application (but ALSO in the Sample), right after the video has been loaded until it starts to play, lots of First Chance Exceptions are thrown.

    Here's the console output:


    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x0652F588.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x0652F588.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x0652F588.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x0652F588.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x0652F588.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x0652F588.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x0652F588.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x0652F588.
    'MEPlaybackNative.exe' (Win32): Loaded 'C:\Windows\SysWOW64\threadpoolwinrt.dll'. Cannot find or open the PDB file.
    The thread 0x147c has exited with code 0 (0x0).
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x06FADF84.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x06FADF84.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x06FAF0D0.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x06FAF0D0.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x074AF7D8.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x074AF7D8.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x074AF7D8.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x074AF7D8.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x074AF7D8.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x074AF7D8.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x074AF7D8.
    First-chance exception at 0x76F44B32 in MEPlaybackNative.exe: Microsoft C++ exception: _com_error at memory location 0x074AF7D8.
    The thread 0x14b4 has exited with code 1 (0x1).
    The thread 0x4b4 has exited with code 0 (0x0).


    I'm not quite sure this is the expected behaviour of the API.

    Does anyone from Microsoft can tell me whether if those exceptions are normal or not?


    -----------------------------------------

    2- Multiple videos playback issue


    I tried to play multiple videos in my Application but they all were extremely slow. Each video belongs to ONE MediaEngine instance. I tried with a Single D3D Device for all my videos and also one D3D Device PER video, but in any case, it's still very slow. (All Device were created with D3D11_CREATE_DEVICE_VIDEO_SUPPORT.)


    -----------------------------------------

    3 - NVidia issue


    Last thing, I still don't know WHY it keeps crashing on NVidia cards!!!


    • Edited by Damien0000 Monday, February 4, 2013 9:20 AM
    Wednesday, January 30, 2013 8:39 AM
  • -----------------------------------------

    2- Multiple videos playback issue

    [Fixed]

    I was calling IMFMediaEngine::TransferVideoFrame on the main thread which slowed down my application. I tried to call it un the event callback of my media engine instance but it was clearly a bad idea. The good solution seems to have another thread running that only calls IMFMediaEngine::TransferVideoFrame whenever possible. By doing this, I can play many videos at the same time in a fluent way. (Still depending on the limitations of my machine of course. No more than two 1920x1400 videos at the same time but 9 videos 470x360 videos works fine.)


    • Edited by Damien0000 Monday, February 4, 2013 9:25 AM
    Monday, February 4, 2013 9:25 AM
  • I might have a workaround for the crashing on NVIDIA cards. It requires limiting yourself to feature levels 9.3 though. See the post in this thread for my reply.

    Andrew Porritt GoGo-Robot Ltd www.gogo-robot.com

    Friday, March 22, 2013 11:37 AM
  • Thanks for sharing your solution Andrew.
    Also, the newest NVidia drivers 314.22 seem to fix the issue on my GTS 450. I can use the D3D device up to level 11.0 (couldn't test level 11.1 though).
    Tuesday, March 26, 2013 5:00 PM