Capture by gstreamer Khadas Camera at Ubuntu

Dear Supporter,

Anybody try to run khadas camera(How To Use MIPI Camera | Khadas Documentation) with gstreamer or any capture app?
This camera doesn’t have v4l2 capture capability.

I known that camera works - becouse guvcview works ok.

I tried find workaround by:

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw, width=1920, height=1080, format=BGR !     v4l2sink device=/dev/video14Setting pipeline to PAUSED ...
    Pipeline is live and does not need PREROLL ...
    Setting pipeline to PLAYING ...
    New clock: GstSystemClock
    ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
    Additional debug info:
    gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
    streaming stopped, reason not-negotiated (-4)
    Execution ended after 0:00:00.000844832
    Setting pipeline to PAUSED ...
    Setting pipeline to READY ...
    Setting pipeline to NULL ...
    Freeing pipeline ...

I cant find any solution how deal with “Video Capture Multiplanar”

Hello @Benek

Can you check this pipe? It works on my side that capture a rgb24 video.

$ gst-launch-1.0 v4l2src name=vsrc device=/dev/video0 ! video/x-raw,width=1920,height=1080,framerate=60/1,format=RGB ! filesink location=.//test.rgb

Play the rgb video on PC:

$ ffplay -f rawvideo -pixel_format rgb24 -video_size 1920x1080 test.rgb
1 Like

Thank a lot!

I can now setup motion with khadas camera:

sudo apt-get install v4l2loopback-dkms
sudo modprobe v4l2loopback video_nr=14
gst-launch-1.0 v4l2src name=vsrc device=/dev/video0 ! video/x-raw,width=1920,height=1080,framerate=60/1,format=RGB !  v4l2sink device=/dev/video14

And set motion to use video14 :slight_smile:

3 Likes

Thanks for sharing, the reason your original GStreamer pipeline fails is not that the Khadas MIPI camera lacks capture. The MIPI camera exposes a Video Capture Multiplanar V4L2 interface, which many capture apps don’t negotiate by default.

A basic pipeline like:

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=1920,height=1080,format=RGB ! filesink location=test.rgb

works because it explicitly declares the output format.

To make your loopback solution work, you must specify valid formats and include conversion (e.g., videoconvert) before v4l2sink, so that caps negotiation succeeds. Otherwise GStreamer reports not-negotiated like in your log.

The supported method is to use explicit caps matching what the camera actually outputs or use the official GStreamer pipelines in the Khadas docs.