From ed851867d96eff88ad67be06fe254cca3e3e9711 Mon Sep 17 00:00:00 2001 From: Pete Haughie Date: Sun, 4 Oct 2026 11:35:28 +0200 Subject: [PATCH] Fix GStreamer pipeline for MJPG v4l2 capture For image/jpeg input the decoder selection built "! jpegdec ! decodebin": the bayer/decodebin if-chain is separate from the jpegdec branch, and format_name "MJPG" maps to GST_VIDEO_FORMAT_UNKNOWN, so "! decodebin " was appended after jpegdec. decodebin cannot link the raw video jpegdec emits, so v4l2src aborts with: Internal data stream error. ... streaming stopped, reason not-linked (-1) Removing decodebin then exposes a second problem: when the requested size differs from the selected device format, the videoscale assignment overwrites the videoconvert set just above it, so the appsink's RGB caps are never satisfied: streaming stopped, reason not-negotiated (-4) Make the decoder selection a single if/else chain and append videoscale instead of overwriting videoconvert. A 720x576 MJPG camera asked for 640x480 now builds and runs: v4l2src ! image/jpeg,width=720,height=576,framerate=30/1 ! jpegdec ! videoconvert ! videoscale method=2 ! appsink (RGB 640x480) --- libs/openFrameworks/video/ofGstVideoGrabber.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libs/openFrameworks/video/ofGstVideoGrabber.cpp b/libs/openFrameworks/video/ofGstVideoGrabber.cpp index 2ed99946433..2f4b146b8c1 100644 --- a/libs/openFrameworks/video/ofGstVideoGrabber.cpp +++ b/libs/openFrameworks/video/ofGstVideoGrabber.cpp @@ -760,8 +760,7 @@ bool ofGstVideoGrabber::setup(int w, int h){ string scale = ""; if (format.mimetype == "image/jpeg") { decodebin = "! jpegdec "; - } - if (format.mimetype == "video/x-bayer") { + }else if (format.mimetype == "video/x-bayer") { decodebin = "! bayer2rgb "; }else if(gst_video_format_from_string(format.format_name.c_str()) == GST_VIDEO_FORMAT_ENCODED || gst_video_format_from_string(format.format_name.c_str()) ==GST_VIDEO_FORMAT_UNKNOWN){ decodebin += "! decodebin "; @@ -772,7 +771,7 @@ bool ofGstVideoGrabber::setup(int w, int h){ } if( w!=format.width || h!=format.height ){ - scale = "! videoscale method=2 "; + scale += "! videoscale method=2 "; } if(format.format_name==""){