C++ 从Blackmagic设备获取帧

C++ 从Blackmagic设备获取帧,c++,visual-studio-2010,C++,Visual Studio 2010,我正在尝试开始使用Balckagic SDK。我还需要一个“DeckLink SDI”设备的框架 void get_视频(IDeckLink*decklink){ HRESULT结果; IDeckLinkInput*decklinkinput=NULL; BSTR名称=空; IDeckLinkDisplayModeIterator*displayModeIterator=NULL; IDeckLinkInputCallback*theCallback=NULL; IDeckLinkVideoIn

我正在尝试开始使用Balckagic SDK。我还需要一个“DeckLink SDI”设备的框架

void get_视频(IDeckLink*decklink){
HRESULT结果;
IDeckLinkInput*decklinkinput=NULL;
BSTR名称=空;
IDeckLinkDisplayModeIterator*displayModeIterator=NULL;
IDeckLinkInputCallback*theCallback=NULL;
IDeckLinkVideoInputFrame*decklinkInputVideoframe=NULL;
IDeckLinkDisplayMode*displayMode=NULL;
IDECKLINKVIDEOPUTFRAME*输入视频帧;
IDECKLINKAUDIONInputPackage*输入音频包;
IBMStreamingDeviceInput*捕获;
IDeckLinkVideoFrame*deckLinkVideoFrame=NULL;
无符号长可用帧=空;
结果=decklink->QueryInterface(IID_IDeckLinkInput,(void**)和decklinkinput);
结果=decklinkinput->GetDisplayModeIterator(&displayModeIterator);
结果=decklinkinput->SetCallback(回调);
结果=decklinkinput->EnableVideoInput(BMDDisplayMode::bmdModeHD1080i50,BMDPixelFormat::bmdFormat8BitYUV,bmdVideoInputEnableFormatDetection);
结果=decklinkinput->DisableAudioInput();
结果=decklinkinput->StartStreams();
decklinkinput->GetAvailableVideoFrameCount(&AvailableFrames);

请看一下代码示例。过程:

  • 初始化甲板连接板
  • 注册回调并开始流式处理
  • 继续主线程上的其他工作
  • 现在,每当一个帧可用时,Decklink SDK都会用它刚刚处理的帧调用已注册的回调函数。从上面的帖子中,我感觉到您没有掌握回调的概念

    void    get_video(IDeckLink* decklink){
    HRESULT                         result;
    IDeckLinkInput*                 decklinkinput = NULL;
    BSTR                            name = NULL;
    IDeckLinkDisplayModeIterator*   displayModeIterator = NULL;
    IDeckLinkInputCallback*         theCallback = NULL; 
    IDeckLinkVideoInputFrame*       decklinkInputVideoframe =NULL;
    IDeckLinkDisplayMode*           displayMode = NULL;
    IDeckLinkVideoInputFrame*       inputVideoFrame;
    IDeckLinkAudioInputPacket*      inputAudioPacket;
    IBMDStreamingDeviceInput*       capture;
    IDeckLinkVideoFrame*            deckLinkVideoFrame = NULL;
    unsigned long                       avaibleFrames = NULL;
    
    
    result = decklink->QueryInterface(IID_IDeckLinkInput,(void**) &decklinkinput);
    
    
    result = decklinkinput->GetDisplayModeIterator(&displayModeIterator); 
    
    result = decklinkinput->SetCallback(theCallback);
    result = decklinkinput->EnableVideoInput(BMDDisplayMode::bmdModeHD1080i50,BMDPixelFormat::bmdFormat8BitYUV,bmdVideoInputEnableFormatDetection);
    result = decklinkinput->DisableAudioInput();
    
    result = decklinkinput->StartStreams();
    decklinkinput->GetAvailableVideoFrameCount(&avaibleFrames); 
    
    
    
    
    cout<<"Number of avaible frames " << avaibleFrames<<endl;
    result = decklinkinput->SetCallback(theCallback);
    theCallback->VideoInputFrameArrived(inputVideoFrame, inputAudioPacket);
    result = decklinkinput->StopStreams();
    
    
    }