Sunday, May 10, 2015

Video Streaming Speeds as Compared to original Raspberry Pi and Raspberry Pi 2

Having managed to get reasonable video streaming working on a Raspberry Pi with minimal lag I thought it would be a good idea to test it on a Raspberry PI 2.

Using the Original Raspberry Pi

Using UV4L and its built in MJPEG streaming server I was able to get a pretty reasonable solution together with a lag of about 0.5 seconds. However, I had to use a video size of 320x240 at 15 FPS which is pretty low res. See video below.
I pointed the camera at a stopwatch on a phone which was put up against my tablet which is running the video app developed for the robot (see earlier post). If you pause the video at any time you can see the lag between the two clocks of roughly 0.5 secs. If I set the video to the default 1920x1024 at 30 FPS the lag is 3-4 seconds.

Using the Raspberry Pi 2

The Pi 2 being 6 times faster you'd hope that video rendering would be much faster and you'd be right!
The video below show video streaming using MJPEG at 1920x1024 at 30 FPS and we're getting about 0.4 to 0.5 seconds lag which is pretty good.
I wasn't able to improve on the speed by very much by dropping the frame rate and resolution. Even at 320x240 15 FPS I was still getting a lag of 0.3 seconds. I think there is a certain amount of lag that cannot be overcome. The speed of the wifi and the rendering on the tablet will all add to the delay.


Using WebRTC

UV4L on a Raspberry Pi 2 supports WebRTC which is not available on the original Pi due to API's not bundled in Wheezy for the original Pi. WebRTC is a new protocol and API for supporting real time communication in browsers. Media streaming is just one of the many uses.
Although it works very nicely the speed was very similar to MJPEG.

So, near real time streaming video at full resolution is possible with the Raspberry Pi 2 and UV4L.