Using ofGstVideoUtils::setPipeline

Hi everybody !

I’m toying with OF on Raspberry3 with ofVideoGrabber. Everything is fine, captured frames are drawn on screen.

Now, just for my own understanding I would like to setup things myself, and initialize ofGstVideoGrabber’s pipeline with the same settings than those provided by ofVideoGrabber. If I understand how the process works I would be able to tweak and experiment with ofGstVideoGrabber

So, I modified my app::init source code with

    ofGstVideoUtils *gstUtil = gstGrabber->getGstVideoUtils();
        "v4l2src name=video_source device=/dev/video0 ! video/x-raw,format=RGB,width=640,height=480,framerate=30/1 ", OF_PIXELS_RGB, false, 640, 380);

During app’s startup, the logged string pipeline is exactly the same that I got with barebone ofVideoGrabber

[notice ] ofGstUtils: setPipelineWithSink(): gstreamer pipeline: v4l2src name=video_source device=/dev/video0 ! video/x-raw,format=RGB,width=640,height=480,framerate=30/1 ! appsink name=ofappsink enable-last-sample=0 caps="video/x-raw, format=RGB, width=640, height=380"

But the initialization fails with two errors

[ error ] ofGstUtils: setPipelineWithSink(): couldn't create pipeline: could not link video_source to ofappsink
[ error ] ofGstUtils: gstHandleMessage(): embedded video playback halted for plugin, module video_source reported: Internal data flow error.

I’ve digged into ofVideoGrabber::setup and ofGstVideoGrabber::setup source code but I don’t understand what I’m missing…

Any idea ?

you usually don’t setup the pipeline on an ofGstVideoGrabber since it’ll try to setup it’s own internally and relies on the exact pipeline being setup internally.

if you want to setup your own pipeline you need to use an ofGstVideoUtils directly, call setPipeline to setup the pipeline using a string, then startPipeline and then play. once playing you call update/isFrameNew and whenever there’s a new frame upload the pixels to a texture in order to be able to draw them

Thanks Arturo, to be sure that I understand you : do you mean that I only need to use ofGstVideoUtils without ofVideoGrabber and add some code to handle drawing myself ?

yeah that’s it

Arturo, I have some side questions : what is the default format of images grabbed by ofVideoGrabber (in my case on Raspberry Pi) : RGB24 or RGB32 ? Even if the webcam is YUV ? Who does the conversion ? gstreamer ?

by default OF always chooses rgb24 and the conversion is done in the cpu in this case by gstreamer. if you use video.setPixelFormat(OF_PIXELS_NATIVE) it’ll internally choose the native format of the camera and do no conversion in the cpu and if you use the programmabel renderer it’ll do the conversion to rgb in the gpu through shaders