Mediafoundation无法解码某些NVIDIA显卡上的视频

时间:2017-06-30 13:07:50

标签: c# directx-11 directx-9 ms-media-foundation sharpdx

我们正在使用SharpDX .NET包装器使Mediafoundation将MP4视频解码为DirectX9纹理。这样可以正常工作,除了它在某些NVIDIA卡上崩溃,例如940MX。例如,具有Intel HD图形卡的同一台机器可以很好地解码视频流。

很遗憾,除SharpDX的E_FAIL /未指定错误外,我们无法获得任何其他详细信息。即使启用了调试层。任何想法如何找出它崩溃的原因?

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 个答案:

答案 0 :(得分:0)

如果它是MX(移动芯片),它可能是一个优化设置。您需要转到nVidia控制面板并添加一个明确的规则,您的应用程序需要专门使用Intel或nVidia GPU,而不是自动检测。

相关问题