rndmplyr
Posts: 13
Joined: Fri May 31, 2013 4:09 pm

Low latency wifi stream possible?

Sat Jun 01, 2013 11:16 am

Hi, I want to hook my raspi onto my quadcopter to stream videos to a notebook. Is this possible when I want to get low latency? I tried with a PS3 eye cam and mjpg-streamer but get not more than 10 fps with a noticeable delay. So my question is: Will this be possible with the camera module as it is connected directly to the SoC and avoids the USB bottleneck. I want to stream with a n-wlan stick; range is not a concern, 50 meters line of sight will be enough.

Or am I missing something with the ps3eye; I blamed it on the USB and mjpg input. Is that right?

Thanks for your help in advance :)

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: Low latency wifi stream possible?

Sun Jun 02, 2013 12:15 am

Relatively low latency streaming with the raspi cam is possible with, say, 100ms. But with WLAN you always run into issues with reliability.

But apart from that it will definitely be a huge difference to MJPG webcams. The RPi cam gives you 30fps live video that you can beam down with real-time protocols. You may want to lock the wireless to a lower bit rate for range and reliability (i.e., 11b not g or n), and try to fit live video into that.

rndmplyr
Posts: 13
Joined: Fri May 31, 2013 4:09 pm

Re: Low latency wifi stream possible?

Sun Jun 02, 2013 7:53 pm

100ms is ok, but not really good. Is there no way to get lower latency? can be @640x480. Reliability is not an issue. But anyways, as the next camera modules are to be dispatched in 12 weeks, i gotta keep with the pseye :evil:

User avatar
MrBunsy
Posts: 185
Joined: Mon Feb 20, 2012 1:48 pm
Location: Southampton, UK
Contact: Website

Re: Low latency wifi stream possible?

Sun Jun 02, 2013 8:26 pm

I've been mucking about with the camera trying to get the delay down as low as possible. I can get it down to what I think is just TCP's buffering by using mplayer without a cache, and trying to play back at higher framerate than received from the camera, though I'm not entirely sure if that's necessary.

Code: Select all

nc\nc.exe 192.168.1.76 5001  | mplayer\mplayer.exe -fps 30 -demuxer h264es -
(unlike the instructions on the blog). I also tried streaming over UDP, but the picture was broken most of the time.

Ideally I think you'd want to muck around with something to stream over udp and an intelligent buffer just large enough to get most of the frames, and ditch if the frame takes too long to collect.

rndmplyr
Posts: 13
Joined: Fri May 31, 2013 4:09 pm

Re: Low latency wifi stream possible?

Sun Jun 02, 2013 8:56 pm

MrBunsy, did you use the commands from the blog instructions on the RPi side?
For that UDP stuff I don't nearly have the knowledge but what you did should be enough (when I will be able to get hold of a module...)

I'll leave this thread for low latency streaming with the camera module and make another one for the ps3 eye to keep everything clear.

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: Low latency wifi stream possible?

Sun Jun 02, 2013 9:11 pm

MrBunsy wrote:Ideally I think you'd want to muck around with something to stream over udp and an intelligent buffer just large enough to get most of the frames, and ditch if the frame takes too long to collect.
So in other words stop netcatting video into mplayer. The lowest latency streaming I’ve seen to far was with Gstreamer’s rtpbin. I might be worth it to lower GOP with the new -g flag.

User avatar
MrBunsy
Posts: 185
Joined: Mon Feb 20, 2012 1:48 pm
Location: Southampton, UK
Contact: Website

Re: Low latency wifi stream possible?

Mon Jun 03, 2013 4:52 pm

rndmplyr wrote:MrBunsy, did you use the commands from the blog instructions on the RPi side?
Not quite - I set the server (pi) side up so it was listening (notice the -l parameter):

Code: Select all

raspivid -hf -w 1280 -h 1024 -t 999999999 -fps 20 -b 5000000 -o - | nc -l  -p 5001
and stuck that in a while loop with bash. That way any computer on the network could connect to the pi's camera. No reason why you couldn't keep it the same way around as the blog though. The important thing I'd changed was using mplayer without a cache, which required forcing it to decode it correctly (the -demuxer h264es bit) as it then doesn't seem able to figure out the encoding itself.

towolf wrote:
MrBunsy wrote:Ideally I think you'd want to muck around with something to stream over udp and an intelligent buffer just large enough to get most of the frames, and ditch if the frame takes too long to collect.
So in other words stop netcatting video into mplayer. The lowest latency streaming I’ve seen to far was with Gstreamer’s rtpbin. I might be worth it to lower GOP with the new -g flag.
Ooo that looks useful. I shall investigate...

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: Low latency wifi stream possible?

Thu Jun 06, 2013 9:16 pm

I’ve filmed by screen with a clock on it and wit the Gstreamer RTP over UDP command it appears to have a delay of 200-300ms.

Perhaps this can be improved by tuning network device buffering or the Gstreamer properties of the various elements.

Image
Image
Image

rndmplyr
Posts: 13
Joined: Fri May 31, 2013 4:09 pm

Re: Low latency wifi stream possible?

Sat Aug 10, 2013 10:08 pm

Ok I finally bought the camera module and first tried the netcat / mplayer without cache method, which yields 1- 10 seconds delay with 640x480@5MBit/s (i think). The delay seems to depend on when the stream or playback is started, but I didn't find out how. Should I start the playback first and then the stream, or other way round, or at the same time?

Next step is to try gstreamer, but that seems to be complicated with a windows client.

Thanks so far!

User avatar
wallarug
Posts: 459
Joined: Mon May 14, 2012 8:21 am
Contact: Website

Re: Low latency wifi stream possible?

Mon Aug 12, 2013 11:14 pm

I have been having the same issue with latency when trying to stream over either wifi or Ethernet.

I get about a 5 second delay on wifi when using this command (using vlc):

Code: Select all

raspivid -o - -t 0 |cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264
I really need <200ms delay for an application that I have for it.

Has any further progress been made into this area.
RPi Hardware Guide

App Store: https://itunes.apple.com/us/app/rpi-hardware-guide/id723108328?ls=1&mt=8
Play Store: https://play.google.com/store/apps/details?id=org.cmdenterprises.rpihardwareguide

http://www.youtube.com/user/CMDenterprises

User avatar
jbeale
Posts: 3254
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Low latency wifi stream possible?

Mon Aug 12, 2013 11:30 pm

wallarug wrote:I really need <200ms delay for an application that I have for it.
Back in April, JamesH claimed <100 msec delay in this post:
http://www.raspberrypi.org/phpBB3/viewt ... 50#p336453

he was using netcat ("nc.traditional") to send the raspivid output to mplayer on a remote linux box via 100 Mbps ethernet. He wrote "...must be less than 1/10th second, although not sure how to measure it accurately"

User avatar
wallarug
Posts: 459
Joined: Mon May 14, 2012 8:21 am
Contact: Website

Re: Low latency wifi stream possible?

Mon Aug 12, 2013 11:43 pm

jbeale wrote:
wallarug wrote:I really need <200ms delay for an application that I have for it.
Back in April, JamesH claimed <100 msec delay in this post:
http://www.raspberrypi.org/phpBB3/viewt ... 50#p336453

he was using netcat ("nc.traditional") to send the raspivid output to mplayer on a remote linux box via 100 Mbps ethernet. He wrote "...must be less than 1/10th second, although not sure how to measure it accurately"
When I use netcat I can get down to about 2 second delay (ethernet) but that is still not going to cut it for my project.

h[url]ttps://code.google.com/p/cmd-robot/[/url]
RPi Hardware Guide

App Store: https://itunes.apple.com/us/app/rpi-hardware-guide/id723108328?ls=1&mt=8
Play Store: https://play.google.com/store/apps/details?id=org.cmdenterprises.rpihardwareguide

http://www.youtube.com/user/CMDenterprises

User avatar
jbeale
Posts: 3254
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Low latency wifi stream possible?

Tue Aug 13, 2013 5:33 am

what hardware and software are you using on the receiving end? I don't think anyone who has been reporting 200 or 100 msec latency has been using VLC as a viewer.

User avatar
wallarug
Posts: 459
Joined: Mon May 14, 2012 8:21 am
Contact: Website

Re: Low latency wifi stream possible?

Tue Aug 13, 2013 7:21 am

jbeale wrote:what hardware and software are you using on the receiving end? I don't think anyone who has been reporting 200 or 100 msec latency has been using VLC as a viewer.
I was using nc with a windows 7 pro PC over the cable network (Ethernet).

That gave me about 1.5 - 3.0 second delay.

When I use vlc, I end up with 5 second lag (wireless to Ethernet PC).
RPi Hardware Guide

App Store: https://itunes.apple.com/us/app/rpi-hardware-guide/id723108328?ls=1&mt=8
Play Store: https://play.google.com/store/apps/details?id=org.cmdenterprises.rpihardwareguide

http://www.youtube.com/user/CMDenterprises

User avatar
jbeale
Posts: 3254
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Low latency wifi stream possible?

Tue Aug 13, 2013 2:17 pm

You didn't mention what viewer you used on the Win7 box. I don't know what all the issues might be, but JamesH used mplayer on a Linux box when he said < 100 msec, so maybe it is worth trying exactly what he did.

rndmplyr
Posts: 13
Joined: Fri May 31, 2013 4:09 pm

Re: Low latency wifi stream possible?

Tue Aug 13, 2013 3:55 pm

I was now able to get definitely less than 1 second (guess: 200-300 ms) delayed stream @ 640x480 displayed on my Win8 notebook over wifi (802.11g) using the commands from the official tutorial with the bandwidth set to 5000000 (random guess) and on the receiving side no cache as MrBunsy recommended and - what seems to be the deal - fps set to 60 on the displaying side as I found in another thread. That seems to reduce the time of the player collecting the frames.

User avatar
wallarug
Posts: 459
Joined: Mon May 14, 2012 8:21 am
Contact: Website

Re: Low latency wifi stream possible?

Tue Aug 13, 2013 10:19 pm

jbeale wrote:You didn't mention what viewer you used on the Win7 box. I don't know what all the issues might be, but JamesH used mplayer on a Linux box when he said < 100 msec, so maybe it is worth trying exactly what he did.
The one recommended by the foundation. I think it is mplayer.exe for windows?
RPi Hardware Guide

App Store: https://itunes.apple.com/us/app/rpi-hardware-guide/id723108328?ls=1&mt=8
Play Store: https://play.google.com/store/apps/details?id=org.cmdenterprises.rpihardwareguide

http://www.youtube.com/user/CMDenterprises

User avatar
wallarug
Posts: 459
Joined: Mon May 14, 2012 8:21 am
Contact: Website

Re: Low latency wifi stream possible?

Tue Aug 13, 2013 10:20 pm

rndmplyr wrote:I was now able to get definitely less than 1 second (guess: 200-300 ms) delayed stream @ 640x480 displayed on my Win8 notebook over wifi (802.11g) using the commands from the official tutorial with the bandwidth set to 5000000 (random guess) and on the receiving side no cache as MrBunsy recommended and - what seems to be the deal - fps set to 60 on the displaying side as I found in another thread. That seems to reduce the time of the player collecting the frames.
Was the Pi also on WiFi?
RPi Hardware Guide

App Store: https://itunes.apple.com/us/app/rpi-hardware-guide/id723108328?ls=1&mt=8
Play Store: https://play.google.com/store/apps/details?id=org.cmdenterprises.rpihardwareguide

http://www.youtube.com/user/CMDenterprises

rndmplyr
Posts: 13
Joined: Fri May 31, 2013 4:09 pm

Re: Low latency wifi stream possible?

Wed Aug 14, 2013 8:41 am

wallarug wrote: Was the Pi also on WiFi?
Yes of course, that's needed to stream over WiFi ;) (btw, is it "over" or "via WiFi" or how would you say?)

My Pi's Wifi card doesn't support Access Point Mode and I found Ad-hoc networking too unstable so I set up a Windows hostednetwork on the notebook and let the Pi connect to it on startup.

User avatar
wallarug
Posts: 459
Joined: Mon May 14, 2012 8:21 am
Contact: Website

Re: Low latency wifi stream possible?

Wed Aug 14, 2013 10:41 am

rndmplyr wrote:
wallarug wrote: Was the Pi also on WiFi?
Yes of course, that's needed to stream over WiFi ;) (btw, is it "over" or "via WiFi" or how would you say?)

My Pi's Wifi card doesn't support Access Point Mode and I found Ad-hoc networking too unstable so I set up a Windows hostednetwork on the notebook and let the Pi connect to it on startup.
So you have an adhoc setup? Does that mean that routers could be slowing down everyone else's streams?
RPi Hardware Guide

App Store: https://itunes.apple.com/us/app/rpi-hardware-guide/id723108328?ls=1&mt=8
Play Store: https://play.google.com/store/apps/details?id=org.cmdenterprises.rpihardwareguide

http://www.youtube.com/user/CMDenterprises

rndmplyr
Posts: 13
Joined: Fri May 31, 2013 4:09 pm

Re: Low latency wifi stream possible?

Wed Aug 14, 2013 10:50 am

No, Ad-hoc mode is really unstable as I found. I set up an hosted network on my windows notebook (that is usually used to create an hotspot to share internet f.e. to your smartphone) using netsh commands (see here http://www.wi-fiplanet.com/tutorials/ar ... hp/3849841) and had the raspi connect to it on startup. But yes, I wanted to be independent of the router because 1. with the router there is one more traffic station meaning more lag and 2. my router won't be there when I'm flying on the field.

Btw: 1280x720 (720p) stream was possible with no more noticeable delay than 480p, I also set the mplayer fps to 90.

User avatar
wallarug
Posts: 459
Joined: Mon May 14, 2012 8:21 am
Contact: Website

Re: Low latency wifi stream possible?

Wed Aug 14, 2013 10:56 am

rndmplyr wrote:No, Ad-hoc mode is really unstable as I found. I set up an hosted network on my windows notebook (that is usually used to create an hotspot to share internet f.e. to your smartphone) using netsh commands (see here http://www.wi-fiplanet.com/tutorials/ar ... hp/3849841) and had the raspi connect to it on startup. But yes, I wanted to be independent of the router because 1. with the router there is one more traffic station meaning more lag and 2. my router won't be there when I'm flying on the field.

Btw: 1280x720 (720p) stream was possible with no more noticeable delay than 480p, I also set the mplayer fps to 90.
Windows 8 removed this great feature!! Creating Windows Hotspots. It is very much a shame.

Thanks for sharing this information. I will see if a setup like this yields better results for me over the weekend.
RPi Hardware Guide

App Store: https://itunes.apple.com/us/app/rpi-hardware-guide/id723108328?ls=1&mt=8
Play Store: https://play.google.com/store/apps/details?id=org.cmdenterprises.rpihardwareguide

http://www.youtube.com/user/CMDenterprises

rndmplyr
Posts: 13
Joined: Fri May 31, 2013 4:09 pm

Re: Low latency wifi stream possible?

Wed Aug 14, 2013 12:01 pm

wallarug wrote:Windows 8 removed this great feature!! Creating Windows Hotspots. It is very much a shame.
What did they remove?? My notebook runs Win8. You have to use cmd but I think it was the same way on win7.

User avatar
wallarug
Posts: 459
Joined: Mon May 14, 2012 8:21 am
Contact: Website

Re: Low latency wifi stream possible?

Wed Aug 14, 2013 10:08 pm

rndmplyr wrote:
wallarug wrote:Windows 8 removed this great feature!! Creating Windows Hotspots. It is very much a shame.
What did they remove?? My notebook runs Win8. You have to use cmd but I think it was the same way on win7.
Microsoft removed most of the wireless utilities:
- Delete a profile (GUI removed - only accessible via command line)
- Set-up an adhoc network (GUI removed)

These were great in windows 7, they should put them back!
RPi Hardware Guide

App Store: https://itunes.apple.com/us/app/rpi-hardware-guide/id723108328?ls=1&mt=8
Play Store: https://play.google.com/store/apps/details?id=org.cmdenterprises.rpihardwareguide

http://www.youtube.com/user/CMDenterprises

pkout
Posts: 8
Joined: Mon Jun 09, 2014 11:51 pm

Re: Low latency wifi stream possible?

Mon Jun 09, 2014 11:53 pm

I was able to achieve less than a 0.5 second latency at 20 fps of 640x480 resolution while streaming over wifi. I blogged about it here: http://petrkout.com/electronics/low-lat ... er-opencv/

Return to “Camera board”

Who is online

Users browsing this forum: 6by9 and 12 guests