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.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.
How do you call up and launch the server, i have it installed but i cant figure out how im supposed to embed the video into a script.
ReplyDeleteAfter you install (see earlier blog post) it install u4vl as a service which launches on startup. You can also start/stop/restart using:
Deletesudo /etc/init.d/uv4l_raspicam start
The config file is stored in: /etc/uv4l/uv4l-raspicam.conf
The main part in the conf file to alter is width, height and framerate. For the raspberry pi 1 it has to be set quite low:
width = 320
height = 240
framerate = 10
For the raspberry pi 2 you can up it a bit to a frame rate of 15. You should be able to go higher with the Pi 3 but I've not tried it.
If you change the config you need to restart the server using:
sudo /etc/init.d/uv4l_raspicam restart
To access the control panel and links to the streams just point a web browser to it:
http://:8080
My android app just embeds the web page in a WebView component. See other blog post and code on github.
For the Pi2 I was able to get it up to 1920x1024 at 30 FPS with only a small lag.
DeleteNice video, very impressive. I also agree with Demios - a little example code would be very welcome.
ReplyDeleteSee reply to Demios
DeleteExcellent work. You may get even less lag with a Wifi adapter with a better aerial than the one you are using like this one. http://www.ebay.co.uk/itm/181448830743 I've tried both and while both are fully compatible with Pi, the one with the external aerial has far better signal strength/perfomance.
ReplyDeleteSignal strength was not an issue for this test but generally that's a good idea.
DeleteSignal strength was not an issue for this test but generally that's a good idea.
DeleteThis comment has been removed by the author.
ReplyDeleteI couldn't see it documented here, but have you tried overclocking the Pi? You might get even less lag (at the expense of battery life of course). I've had good results running it at 1ghz, 500, 500, 2 with zero crashes. Depends on your power supply of course.
ReplyDeleteI haven't tried that but I agree that's likely to improve it.
DeleteI haven't tried that but I agree that's likely to improve it.
DeleteHey Paul,
ReplyDeletethank's for the original post that helped me a lot when trying to get video streaming to work on my pi2. I've put most of the ressources I've found on streaming and video+audio recording (including your post) into a blog post here.
I've achieved almost latency-free streaming with GStreamer (see post above) but also came up with about 300-500 ms of lag when using the Picam option i settled with.
Cheers, Daniel
Anyone clicking on this link: if it doesn't work, remove the speechmark from the end of the URL.
DeleteHi Dan
DeleteThanks for your post. It looks like the options for streaming are improving. You're right to observe that my choices are restricted by wanting to stream onto an Android device which is why I settled on an mpeg based solution.
Thanks
Hi Dan
DeleteThanks for your post. It looks like the options for streaming are improving. You're right to observe that my choices are restricted by wanting to stream onto an Android device which is why I settled on an mpeg based solution.
Thanks
Hey Paul,
ReplyDeleteyour Blog is great!
But please can you exlain this video streaming with 1920x1024 at 30 FPS step by step until the html code ?
Yours tom.