Example of CreateVideoFrame and ConvertFrame

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

kwiley

  • Posts: 7
  • Joined: Mon Jan 25, 2021 7:25 am
  • Real Name: Keith Wiley

Example of CreateVideoFrame and ConvertFrame

PostWed Jan 27, 2021 6:30 pm

I see the high-level documentation of CreateVideoFrame and ConvertFrame in the manual, but I can't find an example in the provided sample code of using these interfaces and functions. I'm using the Capture sample as a starting point and I'm trying to extend it to convert the incoming YUV frame to an RGB frame, but I don't know how to use it. As far as I can see, the functions are only provided through interfaces. Are we supposed to define new classes to perform straightforward conversions of this sort? Here's my muddled attempt so far:

Code: Select all
IDeckLinkVideoConversion *videoConverter = CreateVideoConversionInstance();
void* rgbFrame = IDeckLinkOutput::CreateVideoFrame(
    videoFrame->GetWidth(), videoFrame->GetHeight(), videoFrame->GetRowBytes(),
    bmdFormat8BitARGB, bmdFrameFlagDefault, NULL);
HRESULT convertResult = videoConverter->ConvertFrame(videoFrame, (IDeckLinkVideoFrame*)rgbFrame);


Obviously that doesn't work because it erroneously calls directly into the virtual interface:

Code: Select all
Capture.cpp: In member function ‘virtual HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame*, IDeckLinkAudioInputPacket*)’:
Capture.cpp:133:126: error: cannot call member function ‘virtual HRESULT IDeckLinkOutput::CreateVideoFrame(int32_t, int32_t, int32_t, BMDPixelFormat, BMDFrameFlags, IDeckLinkMutableVideoFrame**)’ without object
      videoFrame->GetWidth(), videoFrame->GetHeight(), videoFrame->GetRowBytes(), bmdFormat8BitARGB, bmdFrameFlagDefault, NULL);


What is the correct approach here?

Thanks.
Offline

Cameron Nichols

Blackmagic Design

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

Re: Example of CreateVideoFrame and ConvertFrame

PostThu Jan 28, 2021 5:08 am

Hi Keith,

You cannot call IDeckLinkOutput::CreateVideoFrame without a valid IDeckLinkOutput object. You can find an example of calls to IDeckLinkOutput::CreateVideoFrame and IDeckLinkVideoConversion::ConvertFrame in the SignalGenerator SDK sample.

Where you don't have an IDeckLinkOutput interface, such as when you are using a DeckLink Mini Recorder, you can instead generate a custom class that implements IDeckLinkVideoFrame. All methods should be defined and IDeckLinkVideoFrame::GetBytes should output a contiguous buffer large enough for the converted frame. You can find an example of this in the CaptureStills SDK sample.

Regards
Cameron
Offline

kwiley

  • Posts: 7
  • Joined: Mon Jan 25, 2021 7:25 am
  • Real Name: Keith Wiley

Re: Example of CreateVideoFrame and ConvertFrame

PostThu Jan 28, 2021 5:47 pm

I haven't looked at SignalGenerator yet, but I started using CaptureStills as a template, which converts the frames to RGB. I presume this is a good example too. One thing I'm not clear on is whether the conversion is being performed by the main CPU or if it is being performed by a special on-device processor in the 8K Pro. Do some library calls initiate processing on the device and others initiate processing on the CPU? I mean, clearly, the scripts themselves are running on the CPU, but are some internal library calls run on the device? Should we expect certain things, like conversions of this sort, to perform better on the device than on the CPU?
Offline

Cameron Nichols

Blackmagic Design

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

Re: Example of CreateVideoFrame and ConvertFrame

PostFri Feb 05, 2021 5:22 am

Hi Keith,

Video conversion with IDeckLinkVideoConversion::Convert frames is performed by CPU with SIMD accelerated operations.

Regards
Cameron

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 5 guests