Is it possible to use Raspberry Pi graphics chip to speed up the encoding?
With Ubuntu 14.10 and Gstreamer I reach 100 to 116 ms latency with 1280 x 720 @ 60Hz.
Tanks to @Antonvh who puts me on the right way. I reproduce here the solution for latter reference.
To stream from the Pi :
raspivid -t 0 -b 2000000 -fps 60 -w 1280 -h 720 -o - \ | gst-launch-1.0 -e -vvv fdsrc ! h264parse ! rtph264pay pt=96 config-interval=5 \ ! udpsink host=10.42.0.1 port=5001
To receive it on your computer with gst-0.10 and send it to a virtual v4l2 device (indeed you need v4l2loopback):
gst-launch -v udpsrc port=5001 ! application/x-rtp, payload=96 ! rtph264depay \ ! ffdec_h264 ! ffmpegcolorspace ! v4l2sink device=/dev/video1
Then you can open the device
/dev/video1 in any software supporting v4l2 capture.
For a gst-1.0 solution (v4l2loopback doesn't work with gst-1.0), I let you see the Antonvh blog post.
I achieved a 200ms lag! The trick: send out less frames from the Pi than you read on the remote side, this makes sure the buffer stays empty.
Here's a picture I took of the RPi filming a stopwatch. It shows the time difference.
This is the recipe I use. First on the laptop (Mac) do this:
nc -l 5001 | mplayer -fps 24 -cache 1024 -
then on the RPI start streaming:
raspivid -t 999999 -w 1280 -h 720 -fps 20 -o - | nc 192.168.178.22 5001
Make sure to:
- Install mplayer first. Only the Homebrew method worked for me. The regular download was broken.
- Change the ip number above to the number of your laptop.
I use this video recipe: http://archpi.dabase.com/#sending-and-receiving-pi-camera-video-over-the-network
Have you tried https://github.com/thaytan/gst-rpicamsrc ? That should be slightly more streamlined. Tbh, I can't be bothered to try it.
0.3s lag is pretty darn good.