ofxVideoRecorder how can i convert unsigned char[] to ofPixels class

hi,
i have an unsigned char[widthheight3];

i used to use in windows:

include "ofxQtVideoSaver.h";
ofxQtVideoSaver		saver;
saver.addFrame( unsigned char[w*h*3], 1.0f/15.0f );

but in linux ubuntu, i use the ofxVideoRecorder addon;
how can use the " void addFrame(const ofPixels &pixels);"

ofxVideoRecorder        saver;
saver.addFrame(    ???    );

how can i convert the unsigned char[] to ofPixels class?
thanks

where do you get the unsigned char from?

if you are creating it yourself you can just change it to an ofPixels, the use is exactly the same, you can go trhough it with []… except to allocate it where instead of new you would use:

pixels.allocate(w,h,num_channels)

where num_channels would be 1 for grayscale, 3 for rgb and 4 for rgba

if it’s a memory structure that you have from somewhere else you can do:

pixels.setFromExternalPixels(unsigned_char_var, w,h,num_channels);

and pass that to the video recorder

1 Like

thank you.
Problem solved.

i used this:

pixels.setFromExternalPixels(unsigned_char_var, w,h,num_channels);
saver.addFrame(pixels);