Gstreamer does not work with high resolutions

Hello, I have an IMX519 camera on a Raspberry Pi 4, which seems to work fine with libcamera apps (libcamera-still), but fails on high resolutions with gstreamer.

The following commands works fine:

# I can see output in window
gst-launch-1.0 libcamerasrc ! 'video/x-raw,width=3840,height=2400,framerate=5/1' ! glimagesink
# Can also record to a file
gst-launch-1.0 libcamerasrc ! 'video/x-raw,width=3840,height=2400,framerate=5/1' ! jpegenc ! avimux ! filesink location=mjpeg.avi

However, when I increase resolution to maximum of 4565x3496, this is what I get in glimagesink:

While recording to file fails with:

ERROR: from element /GstPipeline:pipeline0/GstLibcameraSrc:libcamerasrc0: Internal data stream error.
Additional debug info:
../src/gstreamer/gstlibcamerasrc.cpp(474): gst_libcamera_src_task_enter (): /GstPipeline:pipeline0/GstLibcameraSrc:libcamerasrc0:
streaming stopped, reason not-negotiated (-4)

I have since narrowed down the problem to width value. Anything bellow or equal to 4096 width works fine and anything above manifests in errors above. Maximum height of 3496 works fine. The width value of 4096 seems oddly specific, being a power of 2. I suspect there is an integer overflow or something. I wonder if it could be a bug in libcamerasrc plugin, since libcamera apps work fine with these width values.

Hi, @chemicstry

This may be a bug of the libcamerasrc plugin, I also had this problem when testing.

I’ve gone ahead and created issue at libcamera github for this:

TLDR: The width value must be a multiple of 32, so the maximum resolution that works is 4640x3496. The proper fix is still pending.