grabbing video via SDK

Do you have questions about Desktop Video, Converters, Routers and Monitoring?
  • Author
  • Message


  • Posts: 2
  • Joined: Thu Nov 22, 2012 11:09 am

grabbing video via SDK

PostThu Nov 22, 2012 11:16 am

I just started to work with Decklink SDI device, and I'm trying to write a code to get a frame from the input of my Decklink SDI . But it just doesn't work. here is my code :
Code: Select all
#include <stdio.h>
#include <tchar.h>
#include <conio.h>
#include <objbase.h>      // Necessary for COM
#include <comutil.h>
#include "DeckLinkAPI_h.h"
#include <iostream>
#include <stdint.h>

using std::endl;
using std::cout;

int   _tmain (int argc, _TCHAR* argv[])
   IDeckLinkIterator*         deckLinkIterator;
   IDeckLinkAPIInformation*   deckLinkAPIInformation;
   IDeckLink*               decklink;
   HRESULT                  result;
   int                     i ;
   IDeckLinkInput*               decklinkinput = NULL;
   IDeckLinkDisplayModeIterator*   displayModeIterator = NULL;
   IDeckLinkInputCallback*         theCallback = NULL;   
   IDeckLinkVideoInputFrame*      decklinkInputVideoframe =NULL;
   IDeckLinkDisplayMode*         displayMode = NULL;
   IDeckLinkAudioInputPacket*      inputAudioPacket;
   IDeckLinkVideoFrame*         videoFrame;
   IBMDStreamingDeviceInput*      capture;
   IDeckLinkVideoFrame*         deckLinkVideoFrame = NULL;
   IDeckLinkScreenPreviewCallback*      screenCallback = NULL;
      unsigned long               avaibleFrames = NULL;
   IBMDStreamingDeviceInput*         bmdStreamingDeviceInput=NULL;
   unsigned long     j            ;      
   // Initialize COM on this thread
   result = CoInitialize(NULL);
   if (FAILED(result))
      cout<< "Initialization of COM failed - result = %08x.\n"<< endl;

      return 1;

   // Create an IDeckLinkIterator object to enumerate all DeckLink cards in the system
   result = CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL, IID_IDeckLinkIterator, (void**)&deckLinkIterator);
   if (FAILED(result))
      cout<< "A DeckLink iterator could not be created.  The DeckLink drivers may not be installed.\n"<<endl;

      return 1;
    while (deckLinkIterator->Next(&decklink) == S_OK)

      result = decklink->QueryInterface(IID_IDeckLinkInput,(void**) &decklinkinput);
      if(result != S_OK)
         cout<<"could not obtain the IDeckLinkInput interface  1 " <<endl;

      result = decklinkinput->EnableVideoInput(BMDDisplayMode::bmdModeHD1080i50,BMDPixelFormat::bmdFormat8BitYUV,bmdVideoInputEnableFormatDetection);
      decklinkinput->QueryInterface(IID_IDeckLinkVideoInputFrame,(void**) &decklinkInputVideoframe);
      result = decklinkinput->DisableAudioInput();
      result = decklinkinput->StartStreams();
      //theCallback->VideoInputFrameArrived(inputVideoFrame, inputAudioPacket);// causes errors
      result = decklinkinput->GetAvailableVideoFrameCount(&avaibleFrames);   

      result = decklinkinput->StopStreams();   
      j = decklinkInputVideoframe->GetHeight(); //  causes errors
      cout << " Number of avaible video frame %d " <<avaibleFrames <<endl;

   // Uninitalize COM on this thread
   // Wait for any key press before exiting
   return 0;

and this what I get when I try to debug this :
Code: Select all
Unhandled exception at 0x000000013f481191 in DeviceList.exe: 0xC0000005: Access violation reading location 0x0000000000000000.

any idea how it could work ??
thanks for your help in advance
User avatar

Thomas Seewald

  • Posts: 1160
  • Joined: Fri Aug 24, 2012 11:57 am

Re: grabbing video via SDK

PostThu Nov 22, 2012 3:54 pm

Sorry, I'm not in practice. When , but If I were to interpret the error message, I would think about an access to a uninitialized pointer variable. Check that for all the pointer variables a constructor was called.

Can you test the program by a debugger, to see at which code row the program crashes ?
thos-berlin - Thomas S e e w a l d


  • Posts: 2
  • Joined: Thu Nov 22, 2012 11:09 am

Re: grabbing video via SDK

PostThu Nov 22, 2012 4:43 pm


thanks for your answer. I used the debugger of visual studio 2010, it didn't help. I get an error when I try to get the frame or any information on the frame ( height.....)
I was wondering if somebody alreadyused the SDK to get some frames. it didn't help


  • Posts: 3
  • Joined: Wed Aug 22, 2012 1:37 pm

Re: grabbing video via SDK

PostMon Nov 26, 2012 9:32 pm

You need to first create a delegate class that implements the IDeckLinkInputCallback interface. Then set an instance of this class in your decklinkinput->SetCallback method.

Look at the InputLoopThrough example in the SDK for more info.

Return to Post Production

Who is online

Users browsing this forum: No registered users and 10 guests