Skip to main content

 none
Media foundation multiple videos playback results in memory-leak & crash after undefined timeframe RRS feed

  • Question

  • So we are using a stack consisting of c++ media foundation code in order to playback video files. An important requirement is the ability to play these videos in constantly repeating sequences, so every single video slot will periodically change the video it is playing. In our current example we are creating 16 HWNDs to render video into and 16 corresponding player objects. The main application loops over all of them one after another and does the following:

    Shutdown the last player
    Release the object
    CoCreateinstance for a new player
    Initialize the player with the (old) HWND
    Start Playback

    The media player is called "MediaPlayer2", this needs to be built and registered as COM (regsvr32). The main application is to be found in the TAPlayer2 Project. It searches for the CLSID of the player in the registry and instantiates it. As current test file we use a test.mp4 that has to reside on the disk like C:\test.mp4

    Now everything goes fine initially. The program loops through the players and the video keeps restarting and playing. The memory footprint is normal and all goes smooth. After a timeframe of anything between 20 minutes and 4 days, all of the sudden things will get weird. At this point it seems as if calls to "InitializeRenderer" by the EVR slow down and eventually don't go through anymore at all. With this, also thread count and memory footprint will start to increase drastically and after a certain amount of time depending on existing RAM all the memory will be exhausted and our application crashes, usually somewhere in the GPU driver or near the EVR DLL.


    I am happy to try out any other code examples that propose to solve my issue: displaying multiple video windows at the same time, and looping through them like in a playlist. Needs to be running on Windows 10!

    I have been going at this for quite a while now and am pretty hard stuck. I uploaded the above mentioned code example and added the link to this post. This should work out of the box afaik. I can also provide code excerpts in here in the thread if that is preferred.

    Any help is appreciated, thanks

    Thomas

    filebin_net_xwo7wdvec5nv6tbi ( replace "_" with "." and "/", I cannot yet post links in here)



    Friday, November 15, 2019 2:22 PM

All replies

  • Hi TAISTLEITER,

    The code samples you uploaded are lack of corresponding libraries and header files. 


    If you can upload the library needed by the sample, I can try to reproduce your problem and provide solutions for you.

    Best regards,

    Strive


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, November 18, 2019 5:39 AM
  • Hi Strive,

    I ran into issues with getting marked as spam when I tried to reupload the project and fix the dependencies. Please try the updated link: filebin_net_l8gl79jrz6fd02vt

    Thanks & best regards!

    Thomas



    Monday, November 18, 2019 10:11 AM
  • Hi TAISTLEITER,

    Thank you for your sample.

    For the issue, I will discuss with relevant engineers. As soon as there is  a conclusion,  I will update in the first time.

    Best regards,

    Strive


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, November 20, 2019 9:06 AM