bjornatic
Posts: 20
Joined: Wed May 15, 2013 4:44 pm

Camera streaming delay

Wed May 22, 2013 4:38 pm

Hi !

So I finally got my camera stream working from Pi to Pi, but I notice about 20 sec delay with the stream. This is not ideal as I wanted to use the camera to be used "realtime".

My configuration :

Camera=Pi-------router----------Pi=Screen.

The command I launch :

Stream Reciever :

Code: Select all

nc -p 5001 -l > buffer | /opt/vc/src/hello_pi/hello_video/hello_video.bin buffer
Stream Sender :

Code: Select all

raspivid -hf -w 920 -h 518 -t 99999999 -o - | nc 192.168.1.10 5001
My questions :
- is it normal ?
- could I improve the stream to reduce the delay to max 3 sec ?
- any other video stream solution that are not to much CPU burning (I tried the VLC streaming option, but it is quite a lot of work for the recieving pi ?

Else, I would turn to a raspistill solution..

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

Re: Camera streaming delay

Wed May 22, 2013 7:39 pm

I'm not familar with the syntax but it seems like in the receiving Pi, you are writing the video to a file "buffer" and then reading it back? If so, that is probably much of your delay, so it would be better if you could avoid writing to a file. I haven't tried this myself though. I believe that hello_video program you are using was only a coding demo, not intended to be a final user application.

User avatar
asvaldr
Posts: 3
Joined: Wed May 22, 2013 9:01 pm
Location: Newcastle, AUSTRALIA

Re: Camera streaming delay

Wed May 22, 2013 9:09 pm

I just did streaming last night from my pi to my Win7 laptop running an Ubuntu virtual in VMware.
I did this with the mplayer commands from the camera news post.

I had a 3 second delay. I was hoping if i stream direct to another device, rather than a virtual; i could minimise the delay. But the keyword is hope.

I was going
pi (wifi dongle) ---> router ---> PC (win7) wifi ---> Ubuntu on Vmware (Bridged network setting)

Perhaps using an adhoc wifi network may help aswell? I suppose i'll try that, since i need close to real time aswell.
I want to drive a remote controlled car (remotely lol)
Last edited by asvaldr on Wed May 22, 2013 10:09 pm, edited 1 time in total.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2870
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Camera streaming delay

Wed May 22, 2013 10:04 pm

I haven't managed any better than about 2s with both devices on gigabit ethernet. VLC does seem to have a 1s buffer on the receiving end that you can tweak - not tried eliminating it. :lol:
Alex Eames RasPi.TV, RasP.iO

User avatar
asvaldr
Posts: 3
Joined: Wed May 22, 2013 9:01 pm
Location: Newcastle, AUSTRALIA

Re: Camera streaming delay

Wed May 22, 2013 10:14 pm

I forgot i also tried scaling down my resolution to 800x600 and that didn't help.

From what alex above is saying, its possibly a pure latency thing and reducing bitrates or resolution won't help..?

Any ideas anyone?

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

Re: Camera streaming delay

Wed May 22, 2013 10:53 pm

This post from 'aframe' says his streaming delay was too small to measure, a few 10s of milliseconds.
http://www.raspberrypi.org/phpBB3/viewt ... 50#p341674

This video (posted yesterday) shows about 0.3 seconds lag, and I assume it is due to buffering. Normally when watching a video eg. YouTube, not operating a robot in realtime, it is more annoying to have freezes due to network congestion, than an initial buffer filling delay (= realtime lag).
http://www.youtube.com/watch?v=rTEOyJdAFjo

This post says the delay in Mplayer can be controlled in real time down to very small values, using the mouse scroll wheel:
http://www.raspberrypi.org/phpBB3/viewt ... 25#p351738

bjornatic
Posts: 20
Joined: Wed May 15, 2013 4:44 pm

Re: Camera streaming delay

Thu May 23, 2013 7:00 am

jbeale wrote:I'm not familar with the syntax but it seems like in the receiving Pi, you are writing the video to a file "buffer" and then reading it back? If so, that is probably much of your delay, so it would be better if you could avoid writing to a file.
Yep, and adding to that I had a MPC/USB DAC problem causing the log files to be written constantly... Without MPC running, I also notice 3 to 4 seconds delay with the streaming wich is ok for my purpose.

Anyway, thank you for your feed back. I'm kind of new to the linux world and I was used to simply find and repeat others 'commands'... And you are right, I should look deeper into the code now. :)

User avatar
wallarug
Posts: 460
Joined: Mon May 14, 2012 8:21 am
Location: Sydney, Australia

Re: Camera streaming delay

Mon Aug 12, 2013 12:22 pm

Has anyone made any head way on this issue?

I need real-time (<300ms) video as well.

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

Re: Camera streaming delay

Mon Aug 12, 2013 7:17 pm

Between 0.2 and 0.3 seconds has been demonstrated, see
http://www.raspberrypi.org/phpBB3/viewt ... 52#p399952

There are several links in the chain and the lag is the sum of all of them. See what you can change and see what effect that has. For example, if you are wireless now, try using ethernet instead of wifi, and see what the difference is due to the wifi link. There are various software chains for streaming media, but if the wifi link alone contributes more delay than your target latency, then no software optimization at either end will achieve your goal.

Return to “Camera board”