Blackmagic Decklink SDK question. Recording.

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


  • Posts: 2
  • Joined: Fri Jun 19, 2015 8:45 pm

Blackmagic Decklink SDK question. Recording.

PostFri Jun 19, 2015 8:53 pm

Hello all.
I'm new to the Blackmagic / Decklink world and I'm wading through a lot of info.
I want to use the DECKLINK API in either a C++ or C# project. I want to basically capture a stream and record that stream to a video file on the hard drive.

However, I'm getting confused on which API calls to use for this. Any suggestions would be great. Thank you very much in advance.


I'm using 10.4 Blackmagic SDK.

Matt Jefferson

Blackmagic Design

  • Posts: 130
  • Joined: Fri Aug 31, 2012 12:50 am

Re: Blackmagic Decklink SDK question. Recording.

PostTue Jun 23, 2015 4:32 am

HI Mark -
Our C ++ (plus plus) API has samples with source code for that sample and as a developer you can use these samples to create your own application. Our SDK for Desktop video has a introduction in the programming manual that introduces the concepts for intializing a device (could be Decklink, Ultrastudio or Intensity named products) and then setting that device up to capture. The devices work in uncompressed modes and save to a hard disk raid or SSD based disk storage. Normally, the files are saved as .mov or motion jpeg as we do with our media express application that comes with the driver. Drivers and SDK can be downloaded from our website under support and selecting capture and playback. The files are on the lower left hand side.

We don't provide developer education or orientation via this forum as it is a user forum where developers respond to each other. At times, Blackmagic Design staff respond to queries.

My recommendation is to study the SDK manual and specifically Chapter 2 and page 24 where we cover the high level about capture.
2.4.1 Capture
An application performing a standard streaming capture operation should perform the following steps:
• If desired, enumerate the supported capture video modes by calling IDeckLinkInput::GetDisplayModeIterator. For each reported capture mode, call IDeckLinkInput::DoesSupportVideoMode to check if the combination of the video mode and pixel format is supported.
• IDeckLinkInput::EnableVideoInput
and material continues.

There is a capture executable in the linux folder and a capture preview executable in the windows folder under Samples | bin | OS for Linux and Win |Samples | bin and then you will see folders with the actual code under the name of the sample.
Matt Jefferson

George Belicka

  • Posts: 18
  • Joined: Sun Jun 07, 2015 4:07 am

Re: Blackmagic Decklink SDK question. Recording.

PostFri Jun 26, 2015 7:13 pm

Mark, I am going to do a brief brain-dump here for you, I apologize that this will not be a detailed overview of how to record audio/video using the Decklink SDK. It should however give you a nudge in the right direction.


Start with the IBMDStreamingDiscovery object and install the callbacks using InstallDeviceNotifications() (see the IBMDStreamingDeviceNotificationCallback). This will enable you to get the StreamingDeviceArrived() callback, and you will be handed an object implementing the IDeckLink interface.


You can cast the IDeckLink device as a IBMDStreamingDeviceInput in C# or (I think) this is done with QueryInterface in C++. Once you have the IBMDStreamingDeviceInput you are in the home stretch. To start receiving data from the DeckLink you simply have to call "SetCallback()" and "StartCapture()" on the device input. When you call SetCallback, you must provide an object that implements the IBMDStreamingH264InputCallback interface. That object will then receive various callbacks when data arrives.

Data Arrival

The simplest data acquisition is to hook MPEG2TSPacketArrived and write the raw packet data to a file. This will result in an MPEG2 Transport Stream which can be played back using QuickTime or VLC or whatever. However, in my own code I hook H264NALPacketArrived and H264AudioPacketArrived.


If you are going to handle NAL packets, the easiest thing to do is use MediaFoundation to create an H264 Decoder (CLSID_H264DecoderMFT) and an AAC decoder (CLSID_CMSAACDecMFT). From there you can decode packets and route them via MediaFoundation in whatever manner you like, including re-encoding to an MPG4 output stream (SinkWriter).


I found the SDK documentation to be marginal. It's very much of the style "The DoSomething method is invoked to Do Something." Which doesn't really help unless you already understand why you might want to "Do something". It's all there, but it's not really expounded on in great detail. I did a lot of googling around the internet scrounging for examples (including these forums). My first attempts were in C++ (I was told it can't be done in C#), and after I had a working prototype for capturing video in C++, I applied my knowledge and re-wrote the code in C#. I am now able to capture synchronized Audio/Video and live encode MPG4 in 100% C#, so it CAN be done, so keep at it! Best of luck to you!



  • Posts: 1
  • Joined: Thu Jul 16, 2015 12:29 pm

Re: Blackmagic Decklink SDK question. Recording.

PostThu Jul 16, 2015 12:37 pm

Hi Belicka,

Thank you for the insights on API's.I have implemented Initialization and Capture part(C#). I am facing trouble in writing/saving the raw video packet into HDD. Whenever I'm trying to write/save "Access violation exception" is thrown. Can you please share some more info on this ?

Thanks in advance


Anders Rathmann

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

Re: Blackmagic Decklink SDK question. Recording.

PostWed Oct 25, 2017 8:42 am

Hi George

Thanks for a wonderful presentation of the setup. I'm also a new beginner in the Black Magic Decklink SDK and recording field. I hope you don't mind, that I ask a question in the post on the forum.
I'm developing solution in .NET/C# closely related to your presentation in this post. I'm having trouble with creating an instance of IBMDStreamingDiscovery. I have tried to do it like this:
CBMDStreamingDiscovery mStreamingDiscovery = new IBMDStreamingDiscovery() and I'm getting following 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)).". It has to be said, that I'm a complete beginner at handling COM-components in .NET/C# too (you might have figured that out). How did you instantiate the obejct?

Thanks in advance for your help.

Best regards

Anders Rathmann

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 1 guest