Page 1 of 1

Can I get some tips to reduce lag while streaming video?

Posted: Sat Jan 18, 2014 7:13 am
by mavpi
I'm streaming video using the instructions given on the Camera board page. I'm using ubuntu on the computer used to view the feed. Currently I'm getting nearly a minute's lag. I want to bring it under a second. How can I reduce video quality? Can you guys give me some tips to reduce the lag?

Re: Can I get some tips to reduce lag while streaming video?

Posted: Sat Jan 18, 2014 10:06 am
by towolf
Get Gstreamer 1.0 from vontaene.de

Code: Select all

deb http://vontaene.de/raspbian-updates/ . main
Use this for streaming

Code: Select all

gst-launch-1.0 -e v4l2src do-timestamp=true ! video/x-h264,width=1280,height=720,framerate=30/1 ! h264parse ! rtph264pay config-interval=2 ! gdppay ! udpsink host=192.168.178.20 port=5000
for receiving

Code: Select all

gst-launch-1.0 -e udpsrc port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! fpsdisplaysink sync=false text-overlay=false

Start the receiver first. This should get you about 200ms of latency.

Re: Can I get some tips to reduce lag while streaming video?

Posted: Sun Jan 19, 2014 3:38 am
by mavpi
I'm using the network on my university campus. Would I not need to specify a target machine? I piped the raspivid command to the one you gave me.

Code: Select all

raspivid -t 999999 -o - |gst-launch-1.0 -e v4l2src do-timestamp=true ! video/x-h264,width=1280,height=720,framerate=30/1 ! h264parse ! rtph264pay config-interval=2 ! gdppay ! udpsink host=129.107.179.143 port=5000
This is the error I get

Code: Select all

Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Cannot identify device '/dev/video0'.
Additional debug info:
v4l2_calls.c(492): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
system error: No such file or directory
Setting pipeline to NULL ...
Freeing pipeline ..
Also, am I supposed to pipe the receiving command to mplayer?

Re: Can I get some tips to reduce lag while streaming video?

Posted: Sun Jan 19, 2014 5:10 am
by mavpi
These commands worked exactly the way I wanted.
Transmission

Code: Select all

gst-launch-1.0 -e tcpclientsrc host=Pi_IP port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! fpsdisplaysink sync=false text-overlay=false
Reception

Code: Select all

raspivid -t 999999 -h 720 -w 1280 -fps 25 -hf -b 2000000 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=Pi_IP port=5000
I've used tcp here. I think udp would be better for video streaming since I don't care about lost packets, how do I change these to use udp instead? I tried replacing the 'tcp' with 'udp', apparently there isn't a 'udpclientsrc' and since I had other things on my list, I could not look into it further.

Re: Can I get some tips to reduce lag while streaming video?

Posted: Sun Jan 19, 2014 6:37 am
by mavpi
towolf wrote:Get Gstreamer 1.0 from vontaene.de

Code: Select all

deb http://vontaene.de/raspbian-updates/ . main
Use this for streaming

Code: Select all

gst-launch-1.0 -e v4l2src do-timestamp=true ! video/x-h264,width=1280,height=720,framerate=30/1 ! h264parse ! rtph264pay config-interval=2 ! gdppay ! udpsink host=192.168.178.20 port=5000
for receiving

Code: Select all

gst-launch-1.0 -e udpsrc port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! fpsdisplaysink sync=false text-overlay=false

Start the receiver first. This should get you about 200ms of latency.
I could stream to my PC. how can I let multiple users see the stream?

Re: Can I get some tips to reduce lag while streaming video?

Posted: Mon Jan 20, 2014 3:40 pm
by towolf
First of all don’t pipe raspivid, use the official v4l driver to feed v4l2src

sudo modprobe bcm2835-v4l2

Check here: http://www.raspberrypi.org/phpBB3/viewt ... 43&t=62364

For multicast UDP streaming check here:
https://developer.ridgerun.com/wiki/ind ... _GStreamer