Skip to main content

 none
IMFMediaEngine stops unexpectedly RRS feed

  • Question

  • Hello,

    I'm using IMFMediaEngine and DirectX11 to build a video player application.
    Get the texture (ID3D11Texture2D) using IMFMediaEngine :: TransferVideoFrame.
    Display the acquired texture on the screen.

    I have one problem.
    The conditions are not clear, but if you use this program to run a large size video on a low-spec PC,
    the frame will be delayed while the video is playing, and then frame acquisition will stop.
    In detail, IMFMediaEngine :: OnVideoStreamTick is S_OK, but no new frame is returned.pPts always returns the time at which it stopped.
    Both IMFMediaEngine :: IsEnded and IMFMediaEngine :: IsPaused return false.
    An error could not be obtained with IMFMediaEngine :: GetError.

    The problem was confirmed on a low-spec PC of Windows 10 and Windows 8.1. The function level of each PC is “10_1”.
    No problem has been confirmed on PCs with a function level of "11_0" or higher.

    If you know how to avoid this problem, please let me know.

    This sentence was translated by google translation.
    I'm sorry if it was difficult to read.

    ■Video details
    Format: wmv
    Playing time: 1 minute 57 seconds
    1600x904
    30fps
    File size: 316MB

    ■PC where the problem occurs1

    ThinkPad X121e Intel 30456GJ
    Windows 8.1 Pro 64-bit
    DDI Version: 10.1
    Feature Levels: 10.1,10.0,9.3,9.2,9.1
    Driver Model: WDDM 1.2
    Intel(R) HD Graphics 3000

    ■PC where the problem occurs2
    Dell System XPS L702X
    Windows 10 Home 64-bit
    DDI Version: 11.1
    Feature Levels: 10_1,10_0,9_3,9_2,9_1
    Driver Model: WDDM 1.2
    Intel(R) HD Graphics 3000

    Wednesday, October 9, 2019 10:16 AM

Answers

  • Hi,

    Could you test the video using local media player such as Movies&TV, and reprocude the issue?

    If you can reproduce it, this issue is related to hardware, you'd better to update it.

    Best regards,

    Jeffrey


    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.

    • Marked as answer by gama55 Thursday, October 24, 2019 2:18 AM
    Monday, October 21, 2019 9:22 AM

All replies

  • Initialization program

    IMFMediaEngine* m_spMediaEngine = nullptr;
    IMFMediaEngineEx* m_spEngineEx = nullptr;
    ID3D11Device* m_device = nullptr;
    ID3D11DeviceContext* m_context = nullptr;
    IMFDXGIDeviceManager* m_dxgiManager = nullptr;
    
    HRESULT hr = E_FAIL;
    
    D3D_FEATURE_LEVEL levels[] =
    {
    	D3D_FEATURE_LEVEL_11_1,
    	D3D_FEATURE_LEVEL_11_0,
    	D3D_FEATURE_LEVEL_10_1,
    	D3D_FEATURE_LEVEL_10_0,
    	D3D_FEATURE_LEVEL_9_3,
    	D3D_FEATURE_LEVEL_9_2,
    	D3D_FEATURE_LEVEL_9_1
    };
    D3D_FEATURE_LEVEL FeatureLevel;
    
    hr = D3D11CreateDevice(
    	nullptr,
    	D3D_DRIVER_TYPE_HARDWARE,
    	nullptr,
    	D3D11_CREATE_DEVICE_VIDEO_SUPPORT | D3D11_CREATE_DEVICE_BGRA_SUPPORT,
    	levels,
    	ARRAYSIZE(levels),
    	D3D11_SDK_VERSION,
    	&m_device,
    	&FeatureLevel,
    	&m_context
    );
    
    ID3D10Multithread * spMultithread;
    hr = m_device->QueryInterface(__uuidof(ID3D10Multithread), (void**)&spMultithread);
    spMultithread->SetMultithreadProtected(TRUE);
    spMultithread->Release();
    
    hr = MFStartup(MF_VERSION);
    
    UINT resetToken;
    hr = MFCreateDXGIDeviceManager(&resetToken, &m_dxgiManager);
    hr = m_dxgiManager->ResetDevice(m_device, resetToken);
    
    IMFMediaEngineClassFactory* spFactory = nullptr;
    IMFAttributes* spAttributes = nullptr;
    MediaEngineNotify* spNotify = nullptr;
    
    spNotify = new MediaEngineNotify();
    spNotify->MediaEngineNotifyCallback(this);
    
    hr = MFCreateAttributes(&spAttributes, 1);
    
    hr = spAttributes->SetUnknown(MF_MEDIA_ENGINE_DXGI_MANAGER, (IUnknown*)m_dxgiManager);
    hr = spAttributes->SetUnknown(MF_MEDIA_ENGINE_CALLBACK, (IUnknown*)spNotify);
    hr = spAttributes->SetUINT32(MF_MEDIA_ENGINE_VIDEO_OUTPUT_FORMAT, DXGI_FORMAT_B8G8R8A8_UNORM);
    hr = CoCreateInstance(CLSID_MFMediaEngineClassFactory, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&spFactory));
    hr = spFactory->CreateInstance(0, spAttributes, &m_spMediaEngine);
    hr = m_spMediaEngine->QueryInterface(__uuidof(IMFMediaEngine), (void**)&m_spEngineEx);
    
    hr = m_spMediaEngine->SetSource(CComBSTR("test.wmv"));
    
    if (spFactory) {
    	spFactory->Release();
    	spFactory = nullptr;
    }
    if (spAttributes) {
    	spAttributes->Release();
    	spAttributes = nullptr;
    }
    if (spNotify) {
    	spNotify->Release();
    	spNotify = nullptr;
    }

    Wednesday, October 9, 2019 10:56 AM
  • Hi,

    Thanks for posting here.

    Could you please provide a complete compilable minimum sample?Which may save trouble shooting time of us. Thanks.

    If this is a bug, we will submit it to internal review after it has been reproduced.

    Best Regards,

    Drake


    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.

    Friday, October 11, 2019 9:42 AM
    Moderator
  • Drake,

    I'm sorry.

    I created a minimal sample for investigation, but that sample did not cause any problems.
    There was a frame delay, but it never stopped.
    For this reason, there is no problem with MediaEngine, and my original program may have some problem.
    I will investigate a little more.

    Thanks.

    Tuesday, October 15, 2019 10:03 AM
  • This problem was a bug in my program. IMFByteStream is used instead of IMFMediaEngine::SetSource for reading data, but there was a bug in that part. I'm sorry.
    • Marked as answer by gama55 Wednesday, October 16, 2019 10:01 AM
    • Unmarked as answer by gama55 Thursday, October 17, 2019 1:59 AM
    Wednesday, October 16, 2019 10:01 AM
  • Hello,

    I'm using IMFMediaEngine and DirectX11 to build a video player application.
    Get the texture (ID3D11Texture2D) using IMFMediaEngine :: TransferVideoFrame.
    Display the acquired texture on the screen.

    I have one problem.
    When playing a large size video on a low-spec machine, the video frame will be delayed and will not be synchronized with the sound.
    Is there a way to avoid the delay?

    For confirmation of this issue, I can provide a minimum sample.
    thanks.

    ■Video details
    Format: wmv
    Playing time: 1 minute 57 seconds
    1600x904
    30fps
    File size: 316MB

    Video: Windows Media Video 8 1600x904 189kbps [Raw Video 0]
    Audio: WMA 2 44100Hz stereo 128kbps [Raw Audio 1]

    ■PC where the problem occurs
    ThinkPad X121e Intel 30456GJ
    Windows 8.1 Pro 64-bit
    Processor: Intel(R) Core(TM) i3-2357M CPU @ 1.30GHz (4 CPUs), ~1.3GHz
    Memory: 4096MB RAM
    resolution:1366x768
    DDI Version: 10.1
    Feature Levels: 10.1,10.0,9.3,9.2,9.1
    Driver Model: WDDM 1.2
    Intel(R) HD Graphics 3000

    Wednesday, October 16, 2019 10:44 AM
  • Hi,

    Since you asked the same question, we will merge this case into the previous case.

    Best regards,

    Jeffrey


    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.


    Thursday, October 17, 2019 1:40 AM
  • Jeffrey

    OK.

    We will continue to recruit answers in this thread.

    If you know how to solve a problem that is delayed, please let me know.

    Thursday, October 17, 2019 1:59 AM
  • Hi,

    Could you please provide a complete compilable minimum sample?

    Best regards,

    Jeffrey


    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.

    Thursday, October 17, 2019 5:22 AM
  • Jeffrey,

    Thank you for your reply.
    The sample can be downloaded from the following URL.
    https://6.gigafile.nu/1216-cc6eed70221420ebb8642d501aed27d26

    Video files are not enclosed because of rights issues.

    Thursday, October 17, 2019 6:54 AM
  • There was no delay when playing MP4 videos with similar specifications.
    There may be a problem with the wmv decoder or the decoding process.
    Thursday, October 17, 2019 10:52 AM
  • I test in my PC. When I first play the video, it has 3-4 seconds delay. But when I test again and other video, the video plays immediately.

    Then I test in another PC, it plays immediately.

    My Processor:  Intel(R) Core(TM) i7-7700 CPU @3.60Hz 3.60GHz

    RAM : 8GB

    This issue may be related to CPU.

    I will make more research about this issue.

    Best regards,

    Jeffrey


    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.

    Friday, October 18, 2019 4:10 AM
  • Jeffrey,

    Thank you for testing.
    I hope you will find a clue to the solution.

    Friday, October 18, 2019 6:37 AM
  • Hi,

    Could you test the video using local media player such as Movies&TV, and reprocude the issue?

    If you can reproduce it, this issue is related to hardware, you'd better to update it.

    Best regards,

    Jeffrey


    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.

    • Marked as answer by gama55 Thursday, October 24, 2019 2:18 AM
    Monday, October 21, 2019 9:22 AM
  • Jeffrey,

    Thank you for investigating.

    We confirmed that the problem was reproduced when playing the video on Movies & TV.

    We confirmed that the problem was resolved when WindowsUpdate was performed on the PC where the problem occurred.
    Was this a bug in Windows?

    Anyway, thank you.
    I was saved.

    Thursday, October 24, 2019 2:17 AM