Close

Quick update about real time streaming using gstreamer

A project log for Raspberry Pi Zero W surveillance camera

I needed a camera to take pictures at 10s intervals and I put together something that costs about £30 and gives me full control

adriajunyent-ferreadria.junyent-ferre 04/18/2020 at 16:562 Comments

The commands I posted in the description of the project work perfectly fine; however, when attempting to stream the video from the camera for a real-time application (e.g. controlling a small vehicle via FPV) I found that piping the output of rapivid into gstreamer added a bit of latency. A much better option is to use the rpicamsrc. This can be obtained from the git page of the project: https://github.com/thaytan/gst-rpicamsrc

A winning formula that does UDP streaming is the following:

On the Raspberry Pi side:

gst-launch-1.0 rpicamsrc preview=false !  'video/x-h264, width=800, height=600, framerate=30/1' ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! udpsink host=YOUR_PC_IP port=5000

On the PC side

gst-launch-1.0 udpsrc port=5000 ! gdpdepay ! rtph264depay ! h264parse ! avdec_h264 ! autovideosink sync=false

 Start the script on the PC side before running the command on the Raspberry Pi.

I still have to figure out a robust way to handle issues with the connection and restart the video once the link betwen the two works.

Discussions

adria.junyent-ferre wrote 02/09/2022 at 08:24 point

If I remember well, video latency was down to about 200-300 ms. I haven't touch this for a long time now, though. Regarding rpicamsrc it is quite easy to download and use, I was skeptical too 

  Are you sure? yes | no

TK wrote 02/09/2022 at 05:56 point

How much latency did you shave off with this method? Is it hard to install rpicamsrc?

  Are you sure? yes | no