Mediafoundation cant decode video on certain NVIDIA cards

时光总嘲笑我的痴心妄想 提交于 2021-02-20 04:36:26

问题


We are using the SharpDX .NET wrapper to make Mediafoundation decode an MP4 Video into a DirectX9 texture. This works fine, except that it crashes on certain NVIDIA cards for example the 940MX. For example the same machine with an Intel HD graphics card decodes the video stream fine.

Unfortunately we cant get any other details than a E_FAIL/Unspecified error from SharpDX. Even with the debug layer enabled. Any ideas how to find out why it crashes?

VideoMediaType outputVideoFormat;
MediaFactory.CreateVideoMediaTypeFromSubtype(mFormatYv12Guid, out outputVideoFormat);

if (outputVideoFormat == null)
{
    Trace.WriteLine("Error: create output video format failed.");
    return false;
}
outputVideoFormat.Set(MediaTypeAttributeKeys.Subtype, mFormatYv12Guid);

outputVideoFormat.Set(MediaTypeAttributeKeys.FrameSize, size);
sourceReader.SetCurrentMediaType(mVideoStreamIndex, outputVideoFormat);

outputVideoFormat.Dispose();

IntPtr transformPointer = sourceReader.GetServiceForStream(mVideoStreamIndex, Guid.Empty, typeof(Transform).GUID);
if (transformPointer.ToInt64() <= 0)
{
    Trace.WriteLine("Error: videoDecoderPointer is null");
    return false;
}

Transform videoDecoder = new Transform(transformPointer);

// crashing here with E_FAIL/Unspecified error
videoDecoder.ProcessMessage(TMessageType.SetD3DManager, deviceManager.NativePointer);

videoDecoder.Dispose();

回答1:


It's likely if it's a MX (mobile chip) that it's an optimus setup. You'll need to go to the nVidia control panel and add an explicit rule that your application needs to either specifically use the Intel or nVidia GPU rather than autodetecting.



来源:https://stackoverflow.com/questions/44847276/mediafoundation-cant-decode-video-on-certain-nvidia-cards

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!