Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Gstreamer1.0 working with v4l2 raspicam driver

For the last 4 days I'm trying to get gstreamer1.0 working with v4l2 driver for Raspberry Pi camera, but with no success.

I'm running the latest Raspbian image (from 19.9.2014.), with raspicam enabled. Raspicam bcm2835_v4l2 driver was started with modprobe command and successfully tested, both with qv4l2 gui interface (preview is working fine), and with dd command directly from the device:

dd if=/dev/video0 of=test.jpeg count=1 bs=11M

Gstreamer is also working fine with a basic "Hello world" command:

gst-launch-1.0 videotestsrc ! ximagesink

However I just can't figure out how to successfully show video preview (with some basic sink like ximagesink or autovideosink) from v4l2 raspicam source with Gstreamer.

None of the following pipes are working (sorry if some of them are a complete nonsense, I'm a gstreamer rookie):

  • With v4l2-ctl pixel format set to H264 (that's what "v4l2-ctl -V" command returns) I tried:

    gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-h264,width=640,height=480,framerate=25/1' ! h264parse ! omxh264dec ! videoconvert ! ximagesink
    gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-h264,width=640,height=480,framerate=25/1' ! h264parse ! omxh264dec ! videoconvert ! autovideosink
    
  • With v4l2-ctl pixel format set to YU12 (4:2:0, packed YUV) I tried:

    gst-launch-1.0 v4l2src device=/dev/video0 ! autovideosink
    gst-launch-1.0 v4l2src device=/dev/video0 ! ximagesink
    

So none of the above commands work, camera LED doesn't turn on and gstream returns:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GetSystemClock
glGetError 0x505
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data flow error
Additional debug info:
gstbasesrc.c(2865): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: 
streaming task paused, reason error (-5) 
Execution ended after 0:00:16.843337147 
Setting pipeline to PAUSED ... 
Setting pipeline to READY ... 
Setting pipeline to NULL ... 
Freeing pipeline ...

Please show me the right direction to get basic preview working through Gstreamer.

My final goal is to get raspicam/gstreamer working with Python/Pyside/Phonon

EDIT: "xvinfo" command tells me there are "no adaptors present" and xvimagesink is not working from the beginning. I'm not sure if that has something to do with the problem. Raspbian is running X.Org version 1.12.4

like image 239
Bero_zg Avatar asked Mar 19 '23 10:03

Bero_zg


1 Answers

It seems there is a bug in agreeing supported resolutions between the raspicam v4l2 driver and gstreamer. You can find more info on official RasPi forum. Thanks to great developers at Raspberry Pi Foundation there is also a workaround/fix for that.

When loading a driver just add a "gst_v4l2src_is_broken=1" flag, like this:

sudo modprobe bcm2835-v4l2 gst_v4l2src_is_broken=1

Hope this will help someone else too.

like image 79
Bero_zg Avatar answered Apr 25 '23 20:04

Bero_zg