Convert frame to RGB

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

James Goodhand

  • Posts: 1
  • Joined: Tue Mar 15, 2016 12:23 pm

Convert frame to RGB

PostTue Mar 15, 2016 12:32 pm


I'm new to the BM SDK and trying to convert incoming frames into an easier to work with RGB array. I've been using the Capture sample code as a basis.

I've reached the point of converting from the incoming YUV format to RGB but i'm experiencing issues with Segmentation Faults on the conversion line.

"frameConverter->ConvertFrame(srcVideoFrame, outFrame);"

Code: Select all
static void toRGB(IDeckLinkVideoFrame* srcVideoFrame) {
    int width = srcVideoFrame->GetWidth();
    int height = srcVideoFrame->GetHeight();
    int rowBytes = srcVideoFrame->GetRowBytes();
    int noBytes = rowBytes * height;
    // Get output interface for conversion.
    IDeckLinkOutput* m_deckLinkOutput = NULL;
    if (deckLink->QueryInterface(IID_IDeckLinkOutput, (void**)&m_deckLinkOutput) != S_OK)
        fprintf(stderr, "Could not obtain the IDeckLinkOutput interface\n");
//    Convert video frame to RGB format.
    IDeckLinkMutableVideoFrame* outFrame = NULL;

    // Create new frame.
    m_deckLinkOutput->CreateVideoFrame(width, height, rowBytes, bmdFormat8BitARGB, bmdFrameFlagDefault, &outFrame);
    IDeckLinkVideoConversion* frameConverter = NULL;
    frameConverter = CreateVideoConversionInstance();
    frameConverter->ConvertFrame(srcVideoFrame, outFrame); // Segmentation fault here.

Can anyone provide any suggestions as to where I am going wrong with this? Or, point me towards best / easier practises for converting the incoming frame into a data structure more resembling a 2D array of RGB pixel objects. e.g.

Code: Select all
struct RGBPixel{
 int r;
 int g;
 int b;

Grateful for any help / suggestions anyone can provide.

Many thanks,


Nicholas Gill

Blackmagic Design

  • Posts: 150
  • Joined: Mon May 04, 2015 10:28 pm

Re: Convert frame to RGB

PostThu Mar 17, 2016 1:32 am

Hi James,

I notice that the code snippet shown is passing the row bytes from the (presumably YUV) srcVideoFrame to CreateVideoFrame for the bmdFormat8BitARGB pixel format.

Please see SDK Manual chapter "2.7.4 Pixel Formats" for appropriate row byte calculations for each pixel format.

As the failure to create the video frame is unchecked, ConvertFrame will likely be passed a null pointer - hence the segmentation fault.

Please note that the best practice advice is to check all return codes to ensure that the function was executed successfully.

Just to clarify, the RGBPixel structure shown would not be appropriate to interpret the bmdFormat8BitARGB pixel format. Please see the 2.7.4 chapter for specific detail of the packing for the various pixel formats.



Armando Jaramillo

  • Posts: 1
  • Joined: Tue Feb 21, 2017 8:20 pm

Re: Convert frame to RGB

PostTue Feb 21, 2017 8:28 pm

Quick question...

How can I convert a frame from 10BitYUV to 8BitARGB WITHOUT using deckLinkOutput->CreateVideoFrame.

Since I'm using a Mini Recorder and deckLinkOutput is not allow obviously, because this card does not have any physical outputs.


Return to Software Developers

Who is online

Users browsing this forum: No registered users and 3 guests