sim085
Posts: 24
Joined: Sat Mar 02, 2013 6:49 pm

Streaming ... how come it's so slow?

Fri May 16, 2014 10:16 pm

Hello, by no means do I mean this as criticism. I just would like to understand (and learn) what contributes to fast/slow streaming. I bought the Pi NoIR and connected this to Raspberry PI Model B.

I then followed the steps here to stream the video:
http://www.miguelmota.com/blog/raspberr ... streaming/

The streaming has around 2 second delay which does not bother me too much for the project I am doing. However I did question from where this delay is coming from. What I mean is this; How come streaming from the Raspberry PI to Laptop on same network has a 2 second delay and skyping from my country to another has no delay!?

Is this just because of the Raspberry is less powerful then a normal pc (as I said I do not mean this as criticism)? Or there is more to it?

ghans
Posts: 7883
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Streaming ... how come it's so slow?

Sat May 17, 2014 8:19 am

Yeah , the Pi is just slower - but the software could be
optimized , too. Completely dropping MJPEG and switching
to h.264 should also yield latency improvements because latter
gets encoded in hardware at realtime speeds (AFAIK MJPEG
encoding happens on the CPU) .

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Streaming ... how come it's so slow?

Sat May 17, 2014 10:18 am

Video and audio codecs must buffer a certain amount of time to make their compression work so latency is always going to be an issue for digital media.
On the decoder side the media player must pre-buffer data to prevent data underruns this also adds to delays in playback.
Some codecs work better than others but usually cut corners i.e. poorer compression for low latency.
If you're experiencing excessive delays try adjusting the video capture resolution and frame rate perhaps you have the settings too high and the CPU is struggling to cope.

As for Skype (including mobile phones) they do have a delay although this may not appear obvious since you cannot hear yourself at the other end.
If you want further confirmation why not get your friend to point the webcam at their Skype window and see how long it takes for you to wave and get a wave back. :)

Richard S.

User avatar
GTR2Fan
Posts: 1601
Joined: Sun Feb 23, 2014 9:20 pm
Location: South East UK

Re: Streaming ... how come it's so slow?

Sat May 17, 2014 10:29 am

Maybe there's a '-zerolatency' option you can use if you go over to H.264? In x264 terms, it's a lie. It actually means lower latency than usual with diabolically poor compression, but it helps. :P
Pi2B Mini-PC/Media Centre: ARM=1GHz (+3), Core=500MHz, v3d=500MHz, h264=333MHz, RAM=DDR2-1200 (+6/+4/+4+schmoo). Sandisk Ultra HC-I 32GB microSD card on '50=100' OCed slot (42MB/s read) running Raspbian/KODI16, Seagate 3.5" 1.5TB HDD mass storage.

sim085
Posts: 24
Joined: Sat Mar 02, 2013 6:49 pm

Re: Streaming ... how come it's so slow?

Sat May 17, 2014 6:33 pm

Thanks for the replies. If you reduce compression doesn't that mean that more bytes have to be transfered per frame? Couldn't that increase the delay, rather then on compress/decompress the delay would be on the network?

User avatar
GTR2Fan
Posts: 1601
Joined: Sun Feb 23, 2014 9:20 pm
Location: South East UK

Re: Streaming ... how come it's so slow?

Sat May 17, 2014 6:51 pm

sim085 wrote:If you reduce compression doesn't that mean that more bytes have to be transfered per frame?
Only if you increase the bitrate. Going from MJPEG to H.264 should require significantly less bitrate to achieve the same level of quality.
Pi2B Mini-PC/Media Centre: ARM=1GHz (+3), Core=500MHz, v3d=500MHz, h264=333MHz, RAM=DDR2-1200 (+6/+4/+4+schmoo). Sandisk Ultra HC-I 32GB microSD card on '50=100' OCed slot (42MB/s read) running Raspbian/KODI16, Seagate 3.5" 1.5TB HDD mass storage.

User avatar
gagle
Posts: 82
Joined: Fri Feb 14, 2014 6:54 pm
Contact: Website

Re: Streaming ... how come it's so slow?

Sun May 18, 2014 9:45 am

Skype uses delta encoding algorithms to stream video data, that's why it has no appreciable delay. The low resolution also helps, but the encoding it's its major performance boost.

User avatar
sav25
Authorised Reseller
Authorised Reseller
Posts: 392
Joined: Thu Aug 30, 2012 7:18 pm
Location: Southend-on-Sea, Essex, UK
Contact: Website Twitter

Re: Streaming ... how come it's so slow?

Mon May 19, 2014 11:40 am

Sim085 - did this streaming method allow you to set the video full screen on a PC/Laptop/Tablet?

How do you get to the streaming video from that landing page?

Thanks

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 27434
Joined: Sat Jul 30, 2011 7:41 pm

Re: Streaming ... how come it's so slow?

Mon May 19, 2014 2:39 pm

gagle wrote:Skype uses delta encoding algorithms to stream video data, that's why it has no appreciable delay. The low resolution also helps, but the encoding it's its major performance boost.
That's basically how H264 works. With bells and whistles.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

sim085
Posts: 24
Joined: Sat Mar 02, 2013 6:49 pm

Re: Streaming ... how come it's so slow?

Thu May 22, 2014 1:52 pm

sav25 wrote:How do you get to the streaming video from that landing page?
At the moment I only use the website in the example. I will try to change that however.

sim085
Posts: 24
Joined: Sat Mar 02, 2013 6:49 pm

Re: Streaming ... how come it's so slow?

Thu May 22, 2014 7:28 pm

GTR2Fan wrote:
sim085 wrote:If you reduce compression doesn't that mean that more bytes have to be transfered per frame?
Only if you increase the bitrate. Going from MJPEG to H.264 should require significantly less bitrate to achieve the same level of quality.
I continued to search on the internet to see if I can find an example of streaming using H.264
I found the following:
http://raspi.tv/2013/how-to-stream-vide ... -using-vlc

The example seems to show that streaming is done using H.264

However it is still slow with a 3 second delay between my action in front of the camera and such actions showing on my laptop. I am using VLC to capture the stream from the Raspberry.

Are these delays normal on a LAN?

sim085
Posts: 24
Joined: Sat Mar 02, 2013 6:49 pm

Re: Streaming ... how come it's so slow?

Fri May 23, 2014 7:26 am

Only if you increase the bitrate.
I also had a look a the raspivid parameters. There is one -b to define the bitrate. I tried to set a very small number here but anything less than 1000000 doesn't work! Increasing it did not provide much of a difference.

What I can notice between the two approached (the one I mentioned in the first post and this one) is that the one I am using at the moment is MUCH MORE smooth ... the only problem is that 3 second delay.

Again I am not complaining. I just would like to know from where the delay is coming from and if it is normal.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 27434
Joined: Sat Jul 30, 2011 7:41 pm

Re: Streaming ... how come it's so slow?

Fri May 23, 2014 7:41 am

When I originally tested the streaming on a wired network from Pi to Ubuntu PC, I was getting delays on the order of 10's of milliseconds - it was almost imperceptible. 3s sounds odd, but I haven't tried it for some time.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

mfa298
Posts: 1386
Joined: Tue Apr 22, 2014 11:18 am

Re: Streaming ... how come it's so slow?

Fri May 23, 2014 9:43 am

sim085 wrote: The example seems to show that streaming is done using H.264

However it is still slow with a 3 second delay between my action in front of the camera and such actions showing on my laptop. I am using VLC to capture the stream from the Raspberry.

Are these delays normal on a LAN?
When I've done network streaming on other systems I've usually found some delays this is usually down to buffering in various places (usually the client) so that it can show a continuous stream even if there are short pauses in the data stream (more common on internet links rather than local LAN).

Things which might help reduce the delay (lag) between the action and it being displayed could include reducing buffer sizes, choosing a streaming protocol that uses UDP rather than TCP, and sending data direct to a port rather than using streaming software (use netcat for the network streaming part).

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9917
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Streaming ... how come it's so slow?

Fri May 23, 2014 11:35 am

I can't guarantee it, but most of the time the buffering will be on the receive side to try and smooth out any transmission delays. Other than a couple of TCP buffers, I'd be very surprised if the buffering on the GPU was more than about 80ms.
Viewing with a web browser leaves you very open to how the browser fancies buffering the data.

If you want to see better performance then avoid using anything fancy in the streaming. http://www.raspberrypi.org/forums/viewt ... 5&p=354348 gives an example using nc which should be about as basic as you can get (I can't try it right now as I haven't got a suitable machine for receiving and displaying the data)
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”