问题
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