情况:
使用directshow创建解密过滤器。图是 DecryptFileSource - > GDCL Mpeg-4 Demux - > FFDShow视频解码器 - >增强的视频渲染器
问题:
另一位用户遇到此问题here但他的答案含糊不清。根据Roman(在上一个链接的评论中),它需要特定的初始化。但是我不确定如何专门初始化它。
当我尝试通过代码创建图形时,不会引发错误。我有一个寻求启用,我可以看到IMediaPosition正在工作。只是没有视频显示,但音频播放
答案 0 :(得分:1)
我找到了答案。
编译在" Program Files \ Microsoft SDKs \ Windows \ v6.1 \ Samples \ Multimedia \ MediaFoundation \ EVRPresenter"
安装DLL" regsvr32 EVRPresenter.dll"
编译并将MediaFoundation.dll包含到我的产品中。 Link here
而不是像我通常那样创建对象
像这样:
IBaseFilter pEnhancedVideoRenderer = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_EnhancedVideoRenderer));
而不是
IBaseFilter pEVR = (IBaseFilter)new MediaFoundation.EVR.EnhancedVideoRenderer();
hr = pGraph.AddFilter(pEVR, "Enhanced Video Renderer");
MediaFoundation.EVR.IMFVideoDisplayControl m_pDisplay;
InitializeEVR(pEVR, 1, out m_pDisplay);
InitializeEVR:
private void InitializeEVR(IBaseFilter pEVR, int dwStreams, out MediaFoundation.EVR.IMFVideoDisplayControl ppDisplay)
{
MediaFoundation.EVR.IMFVideoRenderer pRenderer;
MediaFoundation.EVR.IMFVideoDisplayControl pDisplay;
MediaFoundation.EVR.IEVRFilterConfig pConfig;
MediaFoundation.EVR.IMFVideoPresenter pPresenter;
// Before doing anything else, set any custom presenter or mixer.
// Presenter?
if (m_PresenterCLSID != Guid.Empty)
{
Type type = Type.GetTypeFromCLSID(m_PresenterCLSID);
// An error here means that the custom presenter sample from
// http://mfnet.sourceforge.net hasn't been installed or
// registered.
pPresenter = (MediaFoundation.EVR.IMFVideoPresenter)Activator.CreateInstance(type);
try
{
pRenderer = (MediaFoundation.EVR.IMFVideoRenderer)pEVR;
pRenderer.InitializeRenderer(null, pPresenter);
}
finally
{
//Marshal.ReleaseComObject(pPresenter);
}
}
// Continue with the rest of the set-up.
// Set the video window.
object o;
MediaFoundation.IMFGetService pGetService = null;
pGetService = (MediaFoundation.IMFGetService)pEVR;
pGetService.GetService(MediaFoundation.MFServices.MR_VIDEO_RENDER_SERVICE, typeof(MediaFoundation.EVR.IMFVideoDisplayControl).GUID, out o);
try
{
pDisplay = (MediaFoundation.EVR.IMFVideoDisplayControl)o;
}
catch
{
Marshal.ReleaseComObject(o);
throw;
}
try
{
// Set the number of streams.
pDisplay.SetVideoWindow(this.Handle);
if (dwStreams > 1)
{
pConfig = (MediaFoundation.EVR.IEVRFilterConfig)pEVR;
pConfig.SetNumberOfStreams(dwStreams);
}
// Set the display position to the entire window.
Rectangle r = this.ClientRectangle;
MediaFoundation.Misc.MFRect rc = new MediaFoundation.Misc.MFRect(r.Left, r.Top, r.Right, r.Bottom);
pDisplay.SetVideoPosition(null, rc);
// Return the IMFVideoDisplayControl pointer to the caller.
ppDisplay = pDisplay;
}
finally
{
//Marshal.ReleaseComObject(pDisplay);
}
m_pMixer = null;
}