Here is the thing, I want to extract video frames from a video stream through the SDK. Now I can get the video frame in c++ struct that named `NDIlib_video_frame_v2_t`. However, I couldn't find any document of processing this kind of structure. I would like to convert video frame in picture and then get the bitmap of it. Can anybody give me some hint or is there any easier way to achieve the goal. I've just use NDI SDK for quite a short time. Thank you!

livepad

02-10-2018, 08:25 AM

Here is the thing, I want to extract video frames from a video stream through the SDK. Now I can get the video frame in c++ struct that named `NDIlib_video_frame_v2_t`. However, I couldn't find any document of processing this kind of structure. I would like to convert video frame in picture and then get the bitmap of it. Can anybody give me some hint or is there any easier way to achieve the goal. I've just use NDI SDK for quite a short time. Thank you!

in general the pdata member of the structure is a pointer to a memory array of uncompressed UYVY pixels.
You will find more information in the SDK examples and the headers, and the PDF for the SDK.

Exceptions to this would be where the source of the stream is RGB - in which case you would get an array of bgra pixels instead of UYVY

John Perkins

02-13-2018, 09:23 AM

I suggest that you look at NDIlib_video_frame_v2_t in Processing.NDI.structs.h.

As livepad said, p_data is a pointer to the pixel data.

NDIlib_video_frame_v2_t has members for the resolution, stride and format (fourcc) in addition to how and when they should be displayed.

You also have some control over the formats you receive when you create your receiver by setting your color_format and whether you allow_video_fields.

What is this?
Am I really getting the pixel data?
Have I missed something?
I don't know what you expect to see using that method, given that the data is either 32bit-per-pixel RGB+Alpha or 32bit-per-two-pixels 4:2:2 sampled UYVY, which you would possibly want to convert into RGB(A) in order to work with it. Trying to view a stream of individual bytes probably isn't going to reveal much, particularly if it is UYVY 4:2:2 data. If you want a quick way to extract an 8bit-per-pixel monochrome image, just pull out every other byte (the 'Y' luminance values) from the data array (if it's in UYVY format) into a new byte array "xres" by "yres" of the NDIlib_video_frame_v2_t structure.