Desktop Streaming

Live Desktop & Audio Streaming to the browser with WebRTC

UPDATE: although this example is still valid, a more efficient way to do this on the Rpi is described here

Have you ever wanted to stream your Raspberry Pi 2 (or greater) desktop to a Web page in your browser? Well, you can do this with UV4L. You just need to install or update the UV4L core module, the xscreen driver, the Streaming Server plug-in and the WebRTC extension according to these instructions.

Once done, make sure the X server is started whenever the system boots (raspi-config will tell you) and edit /boot/config.txt to set the screen resolution as follows:

framebuffer_width=640
framebuffer_height=480
framebuffer_depth=32
framebuffer_ignore_alpha=1

(this is the only supported resolution at the moment, others may be supported in the future). Save and reboot.

When ready, login into your Raspberry Pi 2 again and load the xscreen driver:

raspberrypi ~ $ uv4l --driver xscreen --auto-video_nr --display :0 --framerate 10 --server-option '--port=9000'
 [core] Trying driver 'xscreen' from built-in drivers...
 [core] Driver 'xscreen' not found
 [core] Trying driver 'xscreen' from external plug-in's...
 [driver] Opening display: :0
 [driver] Display open, screen 0: 640x480, depth: 24, bpp: 32, big endian: false
 [driver] Specified capturing rectangle: (xorigin 0, yorigin 0, width 640, height 480)
 [core] Device detected!
 [core] Trying to load the the Streaming Server plug-in...
 [server] HTTP Streaming & WebRTC Signalling Server v1.1.18 built on Apr 22 2015
 [core] Streaming Server loaded!
 [core] Cannot create /dev/video0 because file already exists
 [core] Registering device node /dev/video1
 [server] Web Streaming Server listening on port 9000

Ignore the warning. In the above example, note that a new video device has been registered as /dev/video1. It’s the node of a new virtual device representing your desktop. You can use this device with any Video4Linux2-compliant application! Also, note that /dev/video0 is busy. It is in use by something else: it may well be another instance of uv4l (and another Streaming Server) running the camera (e.g. as shown in one of the previous tutorials).

Okay, let’s go ahead. Open your browser and type the URL pointing to the Streaming Server:

http://raspberrypi:9000/stream/webrtc

(where raspberrypi has to be replaced with the real address of your RPi)

Finally, press Start and watch the live stream from your desktop! If a microphone is attached to your Raspberry Pi, you should be getting the audio stream too.

Another funny thing you may want to try is to share your desktop with other people in a audio/video conference (see the previous tutorial).

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close