DeckLink Mini Recorder .NET/C# IBMDStreamingDiscovery

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

Anders Rathmann

  • Posts: 5
  • Joined: Tue Jun 13, 2017 11:42 am

DeckLink Mini Recorder .NET/C# IBMDStreamingDiscovery

PostWed Oct 25, 2017 9:26 am

Hello all on the BlackMagic developer forum

I'm using the Blackmagic DeckLink SDK 10.9 and a DeckLink Mini Recorder device.
I'm developing a solution to capture and record the input recieved from the SDI in the device. So far I have been through a lot of posts on this forum, which has been a great help. Most of the posts says, that the way to record and capture is, to use the IBMDStreamingDiscovery interface.
I have tried to instantiate the interface by creating a new instance of the CBMDStreamingDiscovery class by doing this: CBMDStreamingDiscovery mStreamingDiscovery = new IBMDStreamingDiscovery(), and Im getting this error message "Retrieving the COM class factory for component with CLSID {23A4EDF5-A0E5-432C-94EF-3BABB5F81C82} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).".
So my first question goes: Is it possible to combine the DeckLink Mini Recorder device with IBMDStreamingDiscovery interface? If yes: What am I doing wrong? What should I do differently?

Any help will be appreciated.
Thanks in advance for your help.

Cheers
Anders Rathmann
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 31
  • Joined: Mon Sep 04, 2017 4:05 am

Re: DeckLink Mini Recorder .NET/C# IBMDStreamingDiscovery

PostFri Oct 27, 2017 7:48 am

Hi Anders,

You will need to use IDeckLinkDiscovery interface[1] for discovery of the DeckLink Mini Recorder. The IBMDStreamingDiscovery interface is for devices supporting streaming encoder, such as the H.264 Pro Recorder.

Please refer to the CapturePreview sample for example of the IDeckLinkDiscovery interface

Kind Regards
Cameron Nichols

Refs
[1] DeckLink SDK manual - 2.5.28 IDeckLinkDiscovery Interface
Offline

Anders Rathmann

  • Posts: 5
  • Joined: Tue Jun 13, 2017 11:42 am

Re: DeckLink Mini Recorder .NET/C# IBMDStreamingDiscovery

PostFri Oct 27, 2017 9:19 am

Hi Cameron

Thank you so much for your reply. Really nice with some feed back.
I have some further comments and questions to your answer.

I have also tried succesfully to discover the DeckLink minirecorder, by creating a IDeckLinkIterator and iterate through the collection using the Next() method. And the first item in the collation, is the DeckLink minirecorder.
What's the diffrence between discover the device, using the IDeckLinkIterator and IDeckLinkDiscovery interface?

I tried to use the IDeckLinkDiscovery interface without any luck so far. But I'm not really sure how to do it. I have tried to create an object by creating a new instance of the CBMDStreamingDiscovery class (inherit from IDeckLinkDiscovery), and I got the error message described in my first post. And this is weird, because as far as I can see, the COM classe has been registered on my computer. I have tried to search for the GUID in regedit, and the GUID was there.
Or should I create my own class, that inherit from IDeckLinkDiscovery and implement the methods InstallDeviceNotifications() and UninstallDeviceNotifications()?

Kinds Regards
Anders Rathmann
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 31
  • Joined: Mon Sep 04, 2017 4:05 am

Re: DeckLink Mini Recorder .NET/C# IBMDStreamingDiscovery

PostTue Oct 31, 2017 7:48 am

Hi Anders,

The key difference between DeckLinkIterator and IDeckLinkDiscovery interface is:
[*]DeckLinkIterator - The IDeckLink device is found via iterative calls of Next() [1]
[*]IDeckLinkDiscovery - The IDeckLink device is found via IDeckLinkDeviceNotificationCallback:: DeckLinkDeviceArrived[2] callback. The callback function is registered via InstallDeviceNotifications method [3]

Yes it is best to create a class inheriting from IDeckLinkDiscovery. Have a look at the CapturePreviewCSharp sample application (DeckLinkDevice.cs --> DeckLinkDeviceDiscovery class), to see how this is done.

Kind Regards
Cameron Nichols

Refs
[1] 2.5.1.1 IDeckLinkIterator::Next method
[2] 2.5.29.1 IDeckLinkDeviceNotificationCallback::DeckLinkDeviceArrived method
[3] 2.5.28.1 IDeckLinkDiscovery::InstallDeviceNotifications method
Offline

Anders Rathmann

  • Posts: 5
  • Joined: Tue Jun 13, 2017 11:42 am

Re: DeckLink Mini Recorder .NET/C# IBMDStreamingDiscovery

PostWed Nov 01, 2017 9:06 am

Hi Cameron

Thanks a lot for your reply and your explanation.

Unfortunately I'm able to found a solution called CapturePreviewCSharp in the sdk. I have downloaded the sdk called "Blackmagic DeckLink SDK 10.9.3". I believe this the latest version? Is the CapturePreviewCSharp solution included in an earlier or later version of the sdk?

Kind Regards

Anders Rathmann
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 31
  • Joined: Mon Sep 04, 2017 4:05 am

Re: DeckLink Mini Recorder .NET/C# IBMDStreamingDiscovery

PostThu Nov 02, 2017 4:52 am

Hi Anders,

The most recent SDK release is 10.9.5. It is compatible with both Desktop Video 10.9.5 and 10.9.7 releases. Download from:

https://www.blackmagicdesign.com/support/family/capture-and-playback

Kind Regards
Cameron Nichols
Offline

Anders Rathmann

  • Posts: 5
  • Joined: Tue Jun 13, 2017 11:42 am

Re: DeckLink Mini Recorder .NET/C# IBMDStreamingDiscovery

PostFri Nov 03, 2017 11:08 am

Hi Cameron

Thanks once again for your response and for the link. After doing some more research, I did discover the 10.9.5 sdk.
I have explored the CapturePreviewCSharp solution a lot. The preview works fine, and I understand how this works programmatically.

But I still figuring out how to save the stream to a readable .avi. I hope you can give me a push in the right direction. I have been through a lot of articles about this, and as far as I have understood, I should create a bitmap from the stream as a frame, and add this frame to the .av file. There are any approaches how to do this, and there is alot of different .NET libraries to support this. So far I have tried out a couple of approaches. In one some instaces, I was able to create an .avi file and add frames to it without any errors. But the windows mediaplayer could not play it, and it was not possible to identify width, height or pictures per second etc. by right clicking the .avi file and choose "Properties". In an another instance, I get an "access violation" error, when I try to set a frame from the bitmap created from the stream.
So I get the impression, that the stream, captured from the Mini recorder grabber card, is somehow encoded in a specific format (a BlackMagic format ?) - please correct if I wrong.

This is what I have done. I'm using the IDeckLinkInputCallback interface and the VideoInputFrameArrived method. This a short example how I have created a bitmap from the captured stream:

void IDeckLinkInputCallback.VideoInputFrameArrived(IDeckLinkVideoInputFrame videoFrame,
IDeckLinkAudioInputPacket audioPacket)
{
Bitmap bMap;
IntPtr pData;
int height = 0;
int rowBytes = 0;
int width = 0;
_BMDPixelFormat pFormat;

if (videoFrame != null)
{
videoFrame.GetBytes(out pData);
height = videoFrame.GetHeight();
width = videoFrame.GetWidth();
pFormat = videoFrame.GetPixelFormat();
rowBytes = videoFrame.GetRowBytes();

bMap = new Bitmap(width, height, rowBytes,
System.Drawing.Imaging.PixelFormat.Format32bppArgb, pData);
}

System.Runtime.InteropServices.Marshal.ReleaseComObject(videoFrame);
}

Is this the correct way to create a bitmap from the stream? I use the pixel format enum _BMDPixelFormat.bmdFormat8BitYUV, when call the EnableVideoInput method. Should I use another pixel format? Should the stream (IntPtr) be decoded before I create a bitmap to create a frame?

Kind regards
Anders Rathmann
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 31
  • Joined: Mon Sep 04, 2017 4:05 am

Re: DeckLink Mini Recorder .NET/C# IBMDStreamingDiscovery

PostThu Nov 09, 2017 6:28 am

Hi Anders,

Recall that AVI is a container format, not a Video Codec in itself. So it is possible to store a native uncompressed stream (eg UYVY, r210, v210, etc) to AVI without performing conversion. So you will need to consider:

    1. What format of the input (determine via GetPixelFormat method[1])
    2. Which pixels formats (FourCC codes) are supported by your AVI .NET library
    3. Which codec are installed and recognised by Windows Media Player

If pixel format conversion is still required. You should use IDeckLinkVideoConversion Interface, calling ConvertFrame method. You should create a class inheriting from base class IDeckLinkVideoFrame to define your required pixel format.

Kind Regards
Cameron Nichols

Refs
[1] DeckLink SDK Manual - 2.5.5.4 IDeckLinkVideoFrame::GetPixelFormat method
[2] DeckLink SDK Manual - 2.5.41 IDeckLinkVideoConversion Interface

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 2 guests