Search code examples
video-capturems-media-foundation

Encountered an issue using MediaFoundation


My project is using MediaFoundation's Source Reader to capture and preview cameras, but I encountered the following issues when presenting videos using EVR.

Code:

#include <evr.h>
#include <mfapi.h>
#include <mfidl.h>
#include <mfreadwrite.h>
#include <mferror.h>
#pragma comment(lib, "evr.lib")
#pragma comment(lib, "mf.lib")
#pragma comment(lib, "mfplat.lib")
#pragma comment(lib, "mfplay.lib")
#pragma comment(lib, "mfreadwrite.lib")
#pragma comment(lib, "mfuuid.lib")
...
IMFGetService *pGetService = NULL; 
IMFVideoDisplayControl* pVideoDisplayControl = nullptr; 
pGetService->GetService(MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl, (void**)&pVideoDisplayControl);
...

Error:

LNK2001 unresolved external symbol MR_VIDEO_RENDER_SERVICE
LNK2001 unresolved external symbol IID_IMFVideoDisplayControl   

How to solve this problem?

This problem has been studied for 2 days but has not been resolved.


Solution

  • You must add

    #pragma comment(lib, "strmiids.lib")
    

    You can see it documented in any method of the IMFVideoDisplayControl interface (alas not on the interface itself...), for example IMFVideoDisplayControl::GetVideoPosition

    enter image description here

    This will fix the MR_VIDEO_RENDER_SERVICE issue too, although for this one (but not for the interface) you could have added the famous <initguid.h> see this Referencing GUIDs

    I don't know how many human cycles have been lost on these....