Can't get pipeline working on embedded Linux device

Greetings.

I have an IoT device with an onboard camera running embedded linux. I have been trying to capture a video stream from the camera, with no success.

Here is part of the output of v4l2-ctl --list-devices:

ov9732_mipi (mxc_v4l2_capture v4l2_cap_1):
	/dev/video0

Running v4l2-ctl -d /dev/video0 --list-formats-ext gives me the following formats:

ioctl: VIDIOC_ENUM_FMT
	Type: Video Capture

	[0]: 'BA81' ()
		Size: Discrete 1280x720
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 640x360
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1280x720
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 640x360
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1280x720
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 640x360
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1280x720
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 640x360
			Interval: Discrete 0.033s (30.000 fps)
			Interval: Discrete 0.033s (30.000 fps)
...

Plus 7 more that are identical. So it looks like BA81 is the only format option.

However, I can’t make even the simplest pipeline work:

~/gstreamer# gst-launch-1.0 -v v4l2src device="/dev/video0" ! fakesink                   
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Device '/dev/video0' has no supported format
Additional debug info:
../gst-plugins-good-1.20.6/sys/v4l2/gstv4l2object.c(4035): gst_v4l2_object_set_format_full (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
Call to TRY_FMT failed for BA81 @ 640x360: Invalid argument
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
../gstreamer-1.20.6/libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.025616717
Setting pipeline to NULL ...
Freeing pipeline ...

I’m not sure why BA81 @ 640x360 would be a problem, since it is listed in the formats above. However, even if I specify a different resolution, I can’t get a
working result:

~/gstreamer# gst-launch-1.0 v4l2src device="/dev/video0" ! "video/mpeg, width=1280, height=720, format=BA81" ! fakesink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
../gstreamer-1.20.6/libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.006704437
Setting pipeline to NULL ...
Freeing pipeline ...

I’ve read through a lot of posts, but can’t figure out a next step. Any advice would be much appreciated. (And happy holidays!)

Happy holidays! BA81 is a V4L2 fourc, these don’t match GStreamer format names (which are not limited to 4 characters).

I’ve checked for you in linux/videodev2.h, that fourcx matches V4L2_PIX_FMT_SBGGR8 which is a Bayer pattern. In GStreamer this is under caps:

video/x-bayer,format=bggr

We have a software element bayer2rgb to be able to visualize that. It’s quite likely though that reading this raw video data won’t be very useful. This is why we have projects like libcamera to drive ISPs and tune the colors to what your human eye wants to see.

In fact, you likely have a camera pipeline and must understand it in order to do the right thing. The tool media-ctl can dump a graphivz (dot file) to help you visualize the topology.