IDeckLinkMutableVideoFrame SetBytes()?

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

IDeckLinkMutableVideoFrame SetBytes()?

PostTue Feb 02, 2021 10:11 pm

After creating a blank IDeckLinkMutableVideoFrame, how do I populate its frame bytes buffer? It isn't clear from DeckLinkAPI.h how I should do this? There is an obvious GetBytes function, which is demonstrated in the sample code, but there is no corresponding function to set the buffer. The following starting code is working fine:
Code: Select all
    IDeckLinkMutableVideoFrame* frame = NULL;
    result = deckLinkOutput->CreateVideoFrame(width, height, rowBytes, pxlFmt, flags, &frame);

...but now what? How do I jam the actual pixel buffer in?

Thanks.
Offline

kwiley

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

Re: IDeckLinkMutableVideoFrame SetBytes()?

PostTue Feb 02, 2021 10:20 pm

Actually, now that I think about it, GetBytes() returns a handle, not a pointer. Maybe the intent is to simply call GetBytes() to get that handle and copy the frame buffer address into the handle...or something to that effect?

I don't have it working yet though. I tried this (which looks syntactically unlikely. I doubt this is the intended approach):

Code: Select all
    void *frameBytesNew = NULL;
    frame->GetBytes(&frameBytesNew);
    *(char**)frameBytesNew = (char*)frameBytes;


Where frameBytes obviously holds the pixel data I'm trying to insert into the frame. I'm not sure how to do this. Any thoughts?
Offline

Cameron Nichols

Blackmagic Design

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

Re: IDeckLinkMutableVideoFrame SetBytes()?

PostThu Feb 04, 2021 12:43 am

Hi Keith,

Actually IDeckLinkMutableVideoFrame::GetBytes will return a pointer to the allocated buffer for the video frame. You can then fill the buffer with memcpy or otherwise. You cannot just copy the address of another buffer.

However if you are looking for a zero-copy solution, you can wrap your existing buffer (frameBytes) into a class that implements IDeckLinkVideoFrame. Implement all required methods, your ::GetBytes() will output the pointer to your buffer.

You can find examples of this in FilePlayback samples (Win - PlaybackVideoFrame, Mac - DeckLinkCoreMediaVideoFrame).

Regards
Cameron

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 6 guests