Home        Store        Learn        Blog

Problem with auto-running second USB camera by editing .companion.rc

Hi there! We have successfully tried to run a non-H264 USB camera and stream its video to the topside computer using this code in the companion computer terminal:

gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,width= 1920,height=1080,framerate=30/1 ! jpegparse ! rtpjpegpay ! udpsink host=192.168. 2.1 port=5610

and was received in the topside through CMD using this code:

gst-launch-1.0 udpsrc address=192.168.2.1 port=5610 ! application/x-rtp, encoding-name=JPEG,payload=96 ! rtpjpegdepay ! jpegdec ! videoconvert ! autovideosink

However, what we would want is to be able to auto-run this camera like it would with the H264 camera detected by the companion. I have tried following the steps mentioned here and have done the necessary changes in the files:

.companion.rc:

start_video.sh:
image

image

streamer.py:

These have already been placed in their specific folders using the File Manager function of the companion computer. Additionally, both .param files have also been created and included in the home/pi folder of the companion:
image
image


The problem is after rebooting the raspberry pi a couple of times, the camera still does not auto-run. Any help on this would be greatly appreciated. Thanks!

I have tried to edit something on the crontab of the Raspberry Pi by including an @reboot [my command]
at the end. I thought it worked since after rebooting the Pi, the LED on the webcam lit up. However, unlike with manually entering the command in the terminal, for some reason, I cannot receive any stream on my Windows pc using CMD. I think that the original solution for .companion.rc would only work in H264 cameras, though I’m not entirely sure. Any help would be appreciated. Thanks!

Hi @yvesyves,

video/x-h264 is hardcoded into start_video.sh in several locations at the moment, so the streaming code isn’t expected to work for other video types. If you want you can modify start_video.sh to be agnostic of video type (e.g. add an extra variable for FORMAT or similar, which you’d need to add as relevant within the file, and also include the format(s) in your vidformat.param/vidformat-extra.param files), in which case I expect it should work. Alternatively you could start the jpeg stream in its own screen session just using the gstreamer command in .companion.rc, but that would come at the cost of not having automatic restarting and alternate working stream finding that’s available in the existing video functionality.

That said, h264 is a format that’s been specifically chosen for its low data rate when streaming. While it’s possible to use a jpeg stream, and may work acceptably, it also may have poor performance and/or cause additional latency with the other vehicle communications.

1 Like

Hi there @EliotBR. We are currently using 2 cameras of the same model, the Rapoo C260. For some reason, only one of them had H264 capabilities and the only one that could be recognized by both companion and QGroundControl. I have tried to look into the camera and determine if it has any other formats that we could use but as of now, we still couldn’t find H264. Really weird.

We’ll take this alternative solution for the mean time and hopefully find a proper solution that we need. Thanks for this once again!

1 Like