0

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();
Balagurunathan Marimuthu
  • 2,927
  • 4
  • 31
  • 44
oleole
  • 207
  • 2
  • 10
  • Here's how you can find out: https://msdn.microsoft.com/en-us/library/windows/desktop/ff685370%28v=vs.85%29.aspx – Soonts Jul 02 '17 at 11:45

1 Answers1

0

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.

PhonicUK
  • 13,486
  • 4
  • 43
  • 62
  • yes, i can switch between the intel and nvidia GPU. and it works fine with the intel but when i switch to the nvidia i get the above mentioned crash. – oleole Jun 30 '17 at 14:40
  • I know this seems like the most obvious thing but just for my benefit, are the nVidia drivers up-to-date? Also is ShadowPlay enabled? – PhonicUK Jul 01 '17 at 15:25
  • yes, drivers are up to date. infact we tried many different driver versions. including totally removing them with a drivercleaner and a fresh reinstall. Not sure what ShadowPlay is, but i couldnt find anything about it in the driver settings, so i guess its not enabled. – oleole Jul 02 '17 at 12:26
  • Do you have GeForce Experience installed? That's where you'd check the status of ShadowPlay (nVidias recording system) – PhonicUK Jul 03 '17 at 20:19