1

I am writing an application for previewing, capturing and snapshotting camera input. To this end I am using Media Foundation for the input. One of the requirements is that this works with a Black Magic Intensive Pro 4K capture card, which behaves similar to a normal camera.

Media Foundation is unfortunately unable to create an IMFMediaSource object from this device. Some research lead me to believe that I could implement my own MediaSource.

Then I started looking at samples, and tried to unravel the documentation. At that point I encountered some questions:

  1. Does anyone know if what I am trying to do is possible?
  2. A Windows example shows a basic implementation of a source, but uses IMFSensorProfile. What is a Sensor Profile, and what should I use it for? There is almost no documentation about this.
  3. Can somebody explain how implementing a custom media source works in terms of: what actually happens on the inside? Am I simply creating my own format, or does it allow me to pull my own frames from the camera and process them myself? I tried following the msdn guide, but no luck so far.

Specifics:

  • Using WPF with C# but I can write C++ and use it in C#.
  • Rendering to screen uses Direct3D9.
  • The capture card specs can be found on their site (BlackMagic Intensity Pro 4K).
  • The specific problem that occurs is that I can acquire the IMFActivator for the device, but I am not able to activate it. On activation, an MF_E_INVALIDMEDIATYPE error occurs.
  • The IMFActivator can tell me that the device should output a UYVY format.
  • My last resort is using the DeckLinkAPI, but since I am working with several different types of cameras, I do not want to be stuck with another dependency.

Any pointers or help would be appreciated. Let me know if anything is unclear or needs more detail.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Stijn De Pauw
  • 332
  • 2
  • 9
  • Out of curiosity, what is the error with `IMFMediaSource` creation? Blackmagic ships WDM driver which should be visible to Media Foundation as a video source. – Roman R. Aug 13 '21 at 11:39
  • For custom media source there are a couple of SDK samples, they should be of a good start. You won't need D3D integration, esp that D3D9 is anyway out of date. Having said this, custom source over DeskLink SDK is quite doable, but maybe you could just update driver or something and have things work out of the box. – Roman R. Aug 13 '21 at 11:45
  • The error: I am able to acquire an IMFActivate object. The line that generates the error code is where I activate the object, _videoActivate.ActivateObject(typeof(IMFMediaSource).GUID, out var videoSource); The error code is -1072875852, or MF_E_INVALIDMEDIATYPE. – Stijn De Pauw Aug 13 '21 at 11:56
  • On your D3D9 remark: WPF only supports rendering D3D9 devices, apparently 11 and 12 are not supported. – Stijn De Pauw Aug 13 '21 at 11:59
  • OK, I just checked my Intensirty card and indeed the driver (at least the one I have installed) has issues with MF too. Maybe you can ask on their forum. Re D3D you don't need to worry as you have frames in memory, Media Foundation would upload to D3D surface automatically, you don't need to bother with the integration. – Roman R. Aug 13 '21 at 12:13
  • 1
    Okay, I will ask them, thanks for checking. Unfortunately I am not following what you mean with the D3D and Media Foundation combination. Are you saying I do not need D3D? On a side-note: thank you for al your help everywhere in this field, me and a lot of other people really appreciate it :) – Stijn De Pauw Aug 13 '21 at 13:49
  • 1
    The D3D part is simple. Working with camera you don't bneed to care about D3D, the camera will deliver video frames as byte arrays. Then frames will be presented by EVR in WPF using D3D9 but this will accept your byte array frames without need to think about it alot. That is, in context of this card/camera problem you don't need to think about D3D. – Roman R. Aug 13 '21 at 16:29

0 Answers0