Page 1 of 1

HOWTO: stream raspberry pi camera video output to another computer using raspivid, netcat, and vlc

Posted: Wed Dec 04, 2019 4:05 am
by pfharlock
so here is a simple formula for forwarding a video stream from the pi camera to another computer with relatively low latency (around half a second latency on a pi zero w) I tried another method that only involved vlc but not netcat and the latency for that was >2 seconds....

on viewing side... netcat -l -p 5000 | vlc stream:///dev/stdin :demux=h264 --h264-fps=24

on camera side... raspivid -vf -o - -t 0 -n -w 320 -h 240 -fps 24 | nc 192.168.1.<whatever> 5000

Hopefully this helps someone, with this my robot is drive-able.

If anyone knows a good way to get the latency down to the 0-<not noticeable> range, please feel free to chime in :)

Re: HOWTO: stream raspberry pi camera video output to another computer using raspivid, netcat, and vlc

Posted: Wed Dec 04, 2019 7:49 am
by HermannSW
Lowest latency I have seen among several solutions is using uv4l raspicam driver:
http://www.linux-projects.org/uv4l/installation/

As long as you use it for private projects, usage is free.
Some people don't want to use that because of licensing terms, or because it is not open source.
But they use Raspberry camera and the GPU code is closed source as well ...

The instructions above do not cover Buster yet.
But you can install and use on Buster as well:
viewtopic.php?t=247305#p1572013
(The 676ms latency in that posting were because of slow wireless laptop used for display, you can get much less latency with uv4l)

Re: HOWTO: stream raspberry pi camera video output to another computer using raspivid, netcat, and vlc

Posted: Wed Dec 04, 2019 12:52 pm
by 6by9
Adding -fl to the raspivid parameters will reduce it a bit.

Linux pipes are still block based devices, therefore they typically kick the sink end when the block is full, which is not the same as single writes. Adding -fl calls fflush after each write, and that should avoid the buffering.
I'm not aware of a way of doing the same thing with netcat, but I haven't looked.