none
How to load the video from the disk using IMFMediaEngine interface ?

    Question

  • I am trying to use IMFMediaEngine->Load() method, for that we need to read video from the disk file. Can you please help me on how to read it from the disk without using UWP APIs - I am able to do with UWF File Stream class. The Sample code using UWP is below - 

    HRESULT hr = S_OK;
    ComPtr<IMFByteStream> spMFByteStream = nullptr;
    hr = MFCreateMFByteStreamOnStreamEx((IUnknown*)streamHandle, &spMFByteStream);
    hr = m_mediaEngineEx->SetSourceFromByteStream(spMFByteStream.Get(), m_bstrURL))
                
    I think I need to Use IMFByteStream Interface, then use MFBeginCreateFunction. But not sure entirely how to implement it.

    Note: I couldn't able to find a suitable category for this question. Technically Speaking it should belong Media Foundation Programming Interfaces.







    • Edited by AjayRamesh Thursday, February 8, 2018 12:13 AM
    Wednesday, February 7, 2018 11:12 PM

All replies

  • Hi AjayRamesh,

    thanks for posting here.

    >>I think I need to Use IMFByteStream Interface, then use  MFBeginCreateFunction. But not sure entirely how to implement it.

    Note: I couldn't able to find a suitable category for this question. Technically Speaking it should belong Media Foundation Programming Interfaces.

    When the MFBeginCreateFile request is completed, the callback object's IMFAsyncCallback::Invoke method is called. The callback object should then call the MFEndCreateFile function to get a pointer to the byte stream.

    Here are some guides and samples for you as a reference.

    https://msdn.microsoft.com/en-us/library/windows/desktop/aa371827%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

    https://msdn.microsoft.com/en-us/library/windows/desktop/ms697062(v=vs.85).aspx

    Hope this could be help of you.

    Best Regards,

    Baron Bi


    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.

    • Proposed as answer by Guido Franzke Thursday, February 8, 2018 8:46 AM
    Thursday, February 8, 2018 8:29 AM
    Moderator
  • Thank you, let me go through the callback and links provided by you. 
    Thursday, February 8, 2018 8:55 PM
  •  Is it possible to load the Video by specifying the URL(without using MFByteStream)? 

    Yes, I use (tested on Windows 10 with a .AVI file):

    IMFAttributes::SetUnknown with MF_MEDIA_ENGINE_CALLBACK
    IMFAttributes::SetUINT64 with MF_MEDIA_ENGINE_PLAYBACK_HWND
    IMFMediaEngineClassFactory::CreateInstance
    IMFMediaEngine::SetAutoPlay
    IMFMediaEngine::SetSource
    IMFMediaEngine::Load


    • Edited by Castorix31 Thursday, February 8, 2018 10:17 PM
    Thursday, February 8, 2018 10:16 PM
  • Is there any way to bypass the MF_MEDIA_ENGINE_PLAYBACK_HWND ? I mean, say an command-line exe application, which uses MFEngine to read the video and finds generate 5 thumbnails from random frames. So I really don't want to see the video, just want other capabilities of MF Engine(such as frame prcessing, transfer frame to image). So is it completely necessary to have the handle ? 
    • Edited by AjayRamesh Friday, February 9, 2018 6:51 PM
    Friday, February 9, 2018 6:50 PM