Skip to content

gst: use an available pixel format when several match the caps - #1147

Open
gbalanyi wants to merge 1 commit into
AravisProject:mainfrom
gbalanyi:gst-available-pixel-format
Open

gbalanyi wants to merge 1 commit into
AravisProject:mainfrom
gbalanyi:gst-available-pixel-format

Conversation

@gbalanyi

@gbalanyi gbalanyi commented Dec 4, 2026

Copy link
Copy Markdown

Several pixel formats map to the same GStreamer caps, e.g. video/x-raw, format=YUY2 is produced by YUV422_YUYV_Packed, YCbCr422_8_Packed and CUSTOM_YUV_422_YUYV_PACKED. gst_aravis_get_all_camera_caps() advertises YUY2 when the camera has any of them, but gst_aravis_set_caps() uses arv_pixel_format_from_gst_caps(), which always returns the first matching table entry (YUV422_YUYV_Packed). On cameras that only have YCbCr422_8 (e.g. Basler USB3 Vision cameras) caps negotiation succeeds, but setting the pixel format fails:

Could not set caps on camera "Basler-24741017": [PixelFormat] Value 34603058 not found

This change checks the selected pixel format against the available pixel formats of the camera, and if it is not available, uses an available pixel format with the same caps. When the first matching format is available, the behaviour is unchanged.

Tested with aravis 0.8.37 on an NVIDIA Jetson with a Basler USB3 Vision camera (pixel formats: BayerGB8, BayerGB12, YCbCr422_8, RGB8): aravissrc ! video/x-raw,format=YUY2 ! … now streams. Builds on main.

🤖 Generated with Claude Code

Several pixel formats map to the same GStreamer caps, e.g.
video/x-raw, format=YUY2 is produced by YUV422_YUYV_Packed,
YCbCr422_8_Packed and CUSTOM_YUV_422_YUYV_PACKED.
gst_aravis_get_all_camera_caps() advertises YUY2 when the camera has any
of them, but gst_aravis_set_caps() uses arv_pixel_format_from_gst_caps(),
which always returns the first matching table entry (YUV422_YUYV_Packed).
On cameras that only have YCbCr422_8 (e.g. Basler USB3 Vision cameras)
caps negotiation succeeds, but setting the pixel format fails:

  Could not set caps on camera "Basler-24741017": [PixelFormat] Value 34603058 not found

Check the selected pixel format against the available pixel formats of
the camera, and if it is not available, use an available pixel format
with the same caps. When the first matching format is available, the
behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant