Page 1 of 1

Convert frame to RGB

PostPosted: Tue Mar 15, 2016 12:32 pm
by James Goodhand
Hello,

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,

James

Re: Convert frame to RGB

PostPosted: Thu Mar 17, 2016 1:32 am
by Nicholas Gill
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.

Cheers,

-nick

Re: Convert frame to RGB

PostPosted: Tue Feb 21, 2017 8:28 pm
by Armando Jaramillo
Hello!
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.

Thanks!