Repository navigation
Fix GStreamer pipeline for MJPG v4l2 capture - #8572
Merged
Merged
Conversation
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)
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Both targeted changes correctly address the described pipeline failures without introducing unresolved issues.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes GStreamer pipeline construction for MJPG V4L2 capture.
Changes:
- Prevents
decodebinfrom being appended afterjpegdec. - Preserves
videoconvertwhen addingvideoscale.
| File | Description |
|---|---|
libs/openFrameworks/video/ofGstVideoGrabber.cpp |
Corrects decoder selection and composes conversion/scaling stages. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Member
|
thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ofGstVideoGrabber::setup()builds a broken GStreamer pipeline for MJPG (v4l2) cameras, so capture fails on Linux withInternal data stream error. Two independent defects in the pipeline string builder:decodebinappended afterjpegdec. The decoder selection is:The second
ifis not chained to the jpeg branch, and an MJPG device'sformat_name("MJPG") maps toGST_VIDEO_FORMAT_UNKNOWN, so"! decodebin "is appended afterjpegdec.decodebincannot link the raw videojpegdecemits ->streaming stopped, reason not-linked (-1).videoscaleoverwritesvideoconvert. When the requested size differs from the selected device format:With
internalPixelFormatdefaulting toOF_PIXELS_RGB, the appsink's RGB caps are then never satisfied ->reason not-negotiated (-4).Reproduction
Any Linux v4l2 camera that exposes MJPG, when the size passed to
ofVideoGrabber::setup(w, h)differs from the format OF selects. Here: a USB capture card offering 720x576 MJPG, asked for 640x480.Pipelines (from the
ofGstUtilslog):v4l2src ! image/jpeg,width=720,height=576,framerate=30/1 ! jpegdec ! decodebin ! videoscale method=2 ! appsink caps="video/x-raw, format=RGB, width=640, height=480"->not-linkedjpegdec ! videoscale ! appsink(RGB)->not-negotiatedjpegdec ! videoconvert ! videoscale method=2 ! appsink(RGB)-> streamsVerified with
gst-launch-1.0against the same device, and end-to-end on a Raspberry Pi 3 (headless KMS/GBM) with a MacroSilicon534d:2109UVC capture device.Notes
internalPixelFormat != OF_PIXELS_NATIVE(the defaultOF_PIXELS_RGBpath).