Setting up an USB webcam RTSP stream with GStreamer - raspberry-pi

I'm using GStreamer to send the camera feed of /dev/video1 (Raspberry Pi's usb webcam) through a RTSP server that I can connect with another Raspberry Pi.
Result of v4l2-ctl -d /dev/video1 --list-formats:
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture
[0]: 'MJPG' (Motion-JPEG, compressed)
[1]: 'YUYV' (YUYV 4:2:2)
The pipeline I'm using is
./gst-rtsp-launch --port 8555 '( v4l2src device='/dev/video1 ! image/jpeg,width=800,height=600,framerate=30/1 ! jpegparse ! rtpjpegpay name=pay0 pt=96 )' --gst-debug-level=3`
When running it, and letting the other machine connect, the console gives this message:
0:00:02.097412343 3234 0xb4c1c0c0 FIXME default gstutils.c:3981:gst_pad_create_stream_id_internal:<appsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:00:02.102907578 3234 0xb5a07600 WARN v4l2src gstv4l2src.c:692:gst_v4l2src_query:<v4l2src0> Can't give latency since framerate isn't fixated !
0:00:02.170888076 3234 0xb4c1b980 WARN v4l2bufferpool gstv4l2bufferpool.c:790:gst_v4l2_buffer_pool_start:<v4l2src0:pool:src> Uncertain or not enough buffers, enabling copy threshold
0:00:02.410829991 3234 0x166ba90 FIXME rtspmedia rtsp-media.c:3581:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:02.414457433 3234 0x166ba90 FIXME rtspmedia rtsp-media.c:3581:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:02.414551635 3234 0x166ba90 WARN rtspmedia rtsp-media.c:3607:gst_rtsp_media_suspend: media 0xb5a34130 was not prepared
0:00:03.878249884 3234 0x166ba90 WARN rtspmedia rtsp-media.c:3868:gst_rtsp_media_set_state: media 0xb5a34130 was not prepared
On the client Raspberry Pi, using VLC on the static IP vlc rtsp://192.168.0.10:8555/video, gives this error (and triggers the previous one in the other board):
mmal: mmal_component_create_core: could not create component 'vc.ril.hvs' (1)
mmal: mmal_vc_component_create: failed to create component 'vc.ril.hvs' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.hvs' (1)
mmal: mmal_vc_component_create: failed to create component 'vc.ril.hvs' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.hvs' (1)
mmal: mmal_vc_component_create: failed to create component 'vc.ril.hvs' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.hvs' (1)
mmal: mmal_vc_port_info_set: failed to set port info (3:0): EINVAL
mmal: mmal_vc_port_set_format: mmal_vc_port_info_set failed 0x909bcaa0 (EINVAL)
Falha de segmentação
The last line means "Segmentation fault". The screen in the client board flickers black before giving this error, and the board connect to the webcam only shows this error after the client connected.
Connecting to localhost on the same board using vlc rtsp://127.0.0.1:8555/video works for a little bit, then it breaks.
How can I fix this pipeline, so the video can be shown correctly through connection between the two boards?

For the record:
I asked in the comments which version of gstreamer you were using, to which the answer was "1.14.4".
I suggested you update to the latest version (1.20.1), because a segmentation fault where you see it sounds like a potential bug in gstreamer.
Turns out that it was correct: updating gstreamer (to 1.18.4) resolved the problem!

Related

ERROR IPAProxy ipa_proxy.cpp:149 Configuration file 'ov5640.json' not found for IPA module 'raspberrypi'?

I'm trying to interface ov5640 with raspberry Pi 4 model B, kernel version 5.15.61, till now I had loaded driver successfully and Bound driver with ov5640 successfully, and video nodes were created successfully.
I tried to stream video using gstreamer
command:
gst-launch-1.0 libcamerasrc ! video/x-raw, width=640, height=480, framerate=30/1 ! videoconvert ! videoscale ! clockoverlay time-format="%D %H:%M:%S" ! autovideosink
and it thrown error
error:
Setting pipeline to PAUSED ...
[0:02:06.704696651] [1320] INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3866-0c55e522
[0:02:06.726785010] [1324] WARN CameraSensor camera_sensor.cpp:212 'ov5640 10-003c': Recommended V4L2 control 0x009a0922 not supported
[0:02:06.726879464] [1324] WARN CameraSensor camera_sensor.cpp:264 'ov5640 10-003c': The sensor kernel driver needs to be fixed
[0:02:06.726907245] [1324] WARN CameraSensor camera_sensor.cpp:266 'ov5640 10-003c': See Documentation/sensor_driver_requirements.rst in the libcamera sources for more information
[0:02:06.728038265] [1324] WARN CameraSensor camera_sensor.cpp:411 'ov5640 10-003c': Failed to retrieve the camera location
[0:02:06.746434072] [1324] ERROR IPAProxy ipa_proxy.cpp:149 Configuration file 'ov5640.json' not found for IPA module 'raspberrypi'
[0:02:06.746582013] [1324] ERROR IPARPI raspberrypi.cpp:213 Could not create camera helper for ov5640
[0:02:06.746635055] [1324] ERROR RPI raspberrypi.cpp:1253 Failed to load a suitable IPA library
[0:02:06.746922788] [1324] ERROR RPI raspberrypi.cpp:1184 Failed to register camera ov5640 10-003c: -22
ERROR: from element /GstPipeline:pipeline0/GstLibcameraSrc:libcamerasrc0: Could not find any supported camera on this system.
Additional debug info:
../src/gstreamer/gstlibcamerasrc.cpp(354): gst_libcamera_src_open (): /GstPipeline:pipeline0/GstLibcameraSrc:libcamerasrc0:
libcamera::CameraMananger::cameras() is empty
ERROR: pipeline doesn't want to preroll.
Failed to set pipeline to PAUSED.
Setting pipeline to NULL ...
Freeing pipeline ...
can anyone give me a direction how to solve this?

Add logo cvlc player Raspberry pi 3B+ bullseye

I try to add a logo in vlc player launched by terminale
cvlc --fullscreen --no-osd --loop --file-caching 10000 --sub-source logo --logo-position 10 --logo-file /home/pi/Desktop/logo/logo-tv.png /home/pi/Desktop/php/scala.m3u
but I have this error
VLC media player 3.0.16 Vetinari (revision 1.0.6-1682-g88158c836)
[00b5c7a0] dummy interface: using the dummy interface module...
[623710a0] mmal_codec decoder: VCSM init succeeded: CMA
libEGL warning: DRI2: failed to authenticate
[62549eb0] mmal_xsplitter vout display error: Failed to open Xsplitter:opengles2 module
[62549eb0] mmal_xsplitter vout display error: Failed to open Xsplitter:mmal_vout module
mmal: mmal_vc_component_create: failed to create component 'vc.ril.hvs' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.hvs' (1)
mmal: mmal_vc_component_create: failed to create component 'vc.ril.hvs' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.hvs' (1)
[62542140] blend blend error: no matching alpha blending routine (chroma: YUVA -> MMAL)
If I use
--sub-filter logo --logo-position 10 --logo-file
I have no errors but the logo doesn't appear.
can you help me?
thanks
As I suggested in a comment
cvlc --sub-source logo --logo-x 10 --logo-y 10 --logo-file ./logo-stackoverflow.png --logo-opacity 100 your.mp4
should display the logo
To activate the crop one pixel from the bottom of the video, for cvlc
either:
set global-key-crop-bottom=Alt+c in the vlc vlcrc configuration file
or:
set it on the command line
cvlc --sub-source logo --logo-x 10 --logo-y 10 --logo-file ./logo-stackoverow.png --logo-opacity 100 --global-key-crop-bottom=Alt+c --global-key-uncrop-bottom=Alt+Shift+c your.mp4
For some weird reason it seems you must set the --global-key rather than just --key
I install Raspberry Pi OS (Legacy) with desktop, I enable FKMS and all works without any problem on my Raspberry 3b+. So the problem is the FKMS is not possible to enable in Debian version: 11 (bullseye). At now there are no problem with the logo and there are not dropped frames.
So the solution at now is enable the FKMS.
Thanks

How do you enable the Raspberry Pi camera in Yocto

I'm trying to get my Raspberry Pi camera to work with my Yocto image.
I found here that I need to add the following line:
VIDEO_CAMERA = "1"
I added it to my meta's recipes-core/images/example-image.bb but still when I try to take a picture I get:
root#user:~# raspistill -o testshot.jpg
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
mmal: Failed to create camera component
mmal: main: Failed to create camera component
mmal: Camera is not enabled in this build. Try running "sudo raspi-config" and ensure that "camera" has been enabled
So it seems like it's not enabled. And raspi-config seems to be only available on Raspbian, in fact it's not recognised as a command.
Am I missing anything else? I can't find much info out there and I'm still new to Yocto.

gst-launch-1.0 two pipelines/sinkfiles

I am working on a flying drone that sends live stream from a Raspberry Pi 2 to my computer trough a 3G modem/WI-FI, and the stream is made with this command :
sudo raspivid -t 999999999 -w 320 -h 240 -fps 20 -rot 270 -b 100000 -o - | gst-launch-1.0 -e -vvv fdsrc ! h264parse ! rtph264pay pt=96 config-interval=5 ! udpsink host=192.168.0.103 port=5000
The stream works very well, but i have a problem, while raspivid is running i want to take pictures from 5 to five seconds, and when i am executing this command while running raspivid i'm getting this :
root#raspberrypi:/var/www/camera# /usr/bin/raspistill -o cam2.jpg
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
mmal: camera component couldn't be enabled
mmal: main: Failed to create camera component
mmal: Failed to run camera app. Please check for firmware updates
Now what solutions do i have? Another idea is that i use gstream with both udpsink and filesink to a .avi, but i get error again :
WARNING: erroneous pipeline: could not link multifilesink0 to filesink0
What can i do in this case?
Thanks.
AFAIK only one Raspberry Pi program can grab the camera at a time. Since you're always streaming live video that precludes you from adding the five second snapshots on the Pi side (unless you write something custom from scratch).
What I'd suggest doing instead is handling the five second snapshots on the receiving side using the same encoded video data you're using for the live stream. This will ease battery usage on your drone and all the data you need is being sent already.

alsa cannot read control invalid argument - raspberry pi

I am trying to record audio with the PS Eye on a raspberry pi model b plus (I have tried with older b models and the same issue occurs as below).
I am able to record, and playback the recording with arecord/aplay so the mic is working. However, I want to increase the mic volume as the recording is very low.
When I attempt this in alsamixer, it exits with the following error when I use F6 to change to the PS Eye soundcard:
cannot load mixer controls: Invalid argument
I also notice that the alsa-utils service will fail when the PS Eye is plugged in (fine otherwise):
sudo service alsa-utils restart
[FAIL] Shutting down ALSA...warning: 'alsactl store' failed with error message 'alsactl: get_control:259: Cannot read control '2,0,0,Mic Capture Volume,0': Invalid argument'...failed.
[....] Setting up ALSA...warning: 'alsactl restore' failed with error message 'No state is present for card CameraB409241
Found hardware: "USB-Audio" "USB Mixer" "USB1415:2000" "" ""
Hardware is initialized using a generic method
No state is present for card CameraB409241'...amixer: Mixer hw:1 load error: Invalid argument
amixer: Mixer hw:1 load error: Invalid argument
amixer: Mixer hw:1 load error: Invalid argument
amixer: Mixer hw:1 load error: Invalid argument
amixer: Mixer hw:1 load error: Invalid argument
...
done.
The problem seems to be the controls definition of the PS Eye. I would like to know the following:
Where does alsamixer load the controls for a particular device from? Are they in the driver?
Is there a way to increase the mic volume another way?
I am not using Pulseaudio yet but will try it if I can't fix this in alsa.
thanks
Sytem logs:
Without pulseaudio installed, neither restarting alsa or trying to open the controls in alsamixer produce anything in the system log. If pulse audio is installed however, trying to open the controls in alsamixer gives:
Oct 30 10:21:26 signaler pulseaudio[19000]: [pulseaudio] alsa-util.c: Unable to load mixer: Invalid argument
Oct 30 10:21:27 signaler pulseaudio[19000]: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Oct 30 10:21:27 signaler pulseaudio[19000]: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11