9

This post shows how to stream using VLC. It works nice and is simple, but it gives me about a second lag. This post uses GStreamer, and it has 0.3 second lag; I would like less.

Is it possible to use Raspberry Pi graphics chip to speed up the encoding?

syb0rg
  • 8,188
  • 4
  • 37
  • 51
Antonvh
  • 231
  • 1
  • 2
  • 7

3 Answers3

9

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.

antoine
  • 191
  • 1
  • 3
4

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.
lenik
  • 11,541
  • 1
  • 30
  • 37
Antonvh
  • 231
  • 1
  • 2
  • 7
  • This is a clever trick! I wonder if it works for the new UV4L driver too – Piotr Kula Oct 23 '14 at 17:54
  • The issue with this solution is that it introduces a lot of stutter from the playback side. I was wondering if you found a solution to that. – 9a3eedi May 01 '19 at 10:18
1

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.

hendry
  • 197
  • 1
  • 8
  • 1
    Thanks for the links! I think I have a less-than-0.3s lag now, I still have to document the solution and measure it precisely. Will post soon. If my measurments prove it's more than 0.3 I wil try the other recipe. – Antonvh Mar 05 '14 at 13:34
  • @Antonvh How's the research/measurements going? Is this answer getting you better results? – RPiAwesomeness Mar 25 '14 at 19:44