Apr 202014
 

We’re working on streaming a multimedia remote desktop to the Raspberry Pi.

In the future we envision, you shall be able to use a webbrowser on the Pi at normal speeds – including YouTube videos, etc. – operate with CPU / GPU intensive applications – as all the processing is done on a server, and just the H.264 stream rendering on the Raspberry Pi.

First steps

A very interesting application stack to serve this purpose is already available: WinSwitch & xpra

Look at the WinSwitch homepage for installation instructions – it is really quite easy.

WinSwitch bundles several remote clients (VNC / xpra / RDP) with an easy-to-use interface, and broadcasts servers / clients (via Avahi / Bonjour).

A very first demonstration of the capabilities of this stack can be obtained installing WinSwitch on your “normal” desktop machine, and on a server.

Server

As a server we currently use the “fastest available” Intel Atom processor currently on the market –  Intel(R) Atom(TM) CPU  C2750. We are looking into using AMD’s ARM 64 bit processor as server hardware in the future (power-efficiency!), and the performance should be roughly comparable.

Client

As a client we use a Dell Inspiron notebook (with Windows 8.1), Core i7 processor, FullHD resolution.

There is a xpra package available for the Raspberry Pi, which is based on a quite old version of xpra, and will not connect to our server. This may be related to the huge version difference between the two packages, wrong setup, or special tweaking done by winswitch to xpra.

Test results

YouTube videos

We can stream a webbrowser running YouTube fullscreen in FullHD, which will use about 50 % of the server’s total resources (decoding one or several videos in FullHD, encoding one FullHD stream). This is possible in low-latency, at about 30fps and high quality. Yes, this does include an audio stream, too.

The stream uses about 40 Mbp/s of bandwidth, and is much more reliable (less choppy) if streamed over LAN, instead of WLAN. In fast-moving scenes video will still be a bit choppy, but tolerably.

The encoding is done in software, using x264.

Streaming ONE browser window is possible with our server hardware in good quality (for video content) from either the host directly, or from a virtual Ubuntu machine (KVM-virtualized) inside it.

TWO browser windows will start to degrade the quality, even if trying to force best quality and lowest latency.

image

This screenshot shows the YouTube video in the browser being streamed on the client.

Application streaming

Winswitch allows you to stream single applications. Performance / latency is very good on a local network, keyboard / mouse delay is barely noticeable.

In general, applications will be quite useable and seem responsive.

Applications requiring precise mouse / screen cordination, like graphics software will not be usable (at least with our hardware setup).

image

This screenshot shows Firefox being streamed through xpra.

image

VLC media player being streamed – sound works

image

GIMP: barely usable (too much delays)

image

word processing with AbiWord: OK performance (could be better, but it’s usable)

 

Desktop streaming

Streaming a desktop with xnest / Xephyr / xpra from inside a virtualised Ubuntu container on the base hardware is NOT possible at low-latency (30 fps) with high-quality. (With our server hardware)

In order to test it, you have to install additional packages on the server:

aptitude install xnest xserver-xephyr

and set the desktop default to xpra, possibly after restarting the server / client:

image

Apparently frame-grabbing / mirroring the desktop / going through the X layer uses up much more processor resources.

image

Gameplay is quite smooth – but full screen video playback would be a problem.

Some hints

  • authentication with private/public key pairs may be problematic without additional configuration, for first tests I recommend to re-enable password login for SSH.
  • audio for the browser may require alsa and pulseaudio
  • This does not work on the Raspberry Pi yet, this is our next step (compiling a package for it).

 

Outlook

  • encoding performance and latency may be enhanced significantly using NVidia’s NVENC hardware encoding / framegrab API – which xpra supports.
Aug 212013
 

Aka how to view YouTube videos on your Raspberry Pi from Midori or Chromium!

youtube-on-the-raspberry-pi

We have pulled together some software magic and are proud to announce an easy installation procedure for PiVid, the YouTube / HTML5 Video / VeeHD Raspberry Pi video enabler:

Installation

Open a shell – for instance LXTerminal, if you are working on the Raspberry Pi desktop, it can be opened by double-clicking the LXTerminal icon – and enter the following commands:

Step I: Please add our Repository

sudo wget -O /etc/apt/sources.list.d/repository.pi3g.com.list http://repository.pi3g.com/sources.list
sudo wget -O - http://repository.pi3g.com/pubkey | sudo apt-key add -
sudo aptitude update

This will:

  • set up our repository as an additional package source on your Raspberry Pi (your main sources.list will not be modified in any way)
  • get our public key
  • fetch the available packages from our repository server

Step II: Install PiVid

sudo aptitude install pivid

This will:

  • install PiVid and dependencies (other packages which PiVid requires to work)

Please press “Enter” when asked whether you want to continue, and once again “Enter” during the installation process of the youtube-dl package, when asked to.

Step III: Activate PiVid

service pivid start

This will:

  • start the pivid service (it talks to your browser and to omxplayer to play your video)

If you want to stop the pivid service, simply use “service pivid stop” – this will save a small amount of computing resources.

Step IV: Install PiVid in your browser

Install PiVid in Midori:

To use the userscript in Midori (Raspbians default browser), you have to activate the “User addons” extension. Start Midori. Open the preferences dialog (Menu>Preferences), select the Extensions tab and tick “User addons”. (“User addons” is the very last entry, use the scroll bar to find it). Click “Close”.

Then simply open the script ( file:///usr/share/pivid/replace.user.js ) in your browser (copy & paste the link into your URL bar, and press enter) and click “Install user script” when asked.

pivid-userscript-midori

 

Install PiVid in Chromium:

To install pivid in Chromium, please open a shell in the X desktop environment (e.g. LXTerminal), and start Chromium like this:

# chromium --enable-easy-off-store-extension-install /usr/share/pivid/replace.user.js

pivid-userscript-chromium

Please click “Continue”, and then click “Add” on the “Confirm New Extension” dialogue:

click-add

Chrome will confirm, that the extension has been added.

Usage

Please note: after every reboot, you need to start the pivid service, as described above. Open LXTerminal, and (as user pi), enter:

service pivid start

You can close LXTerminal after starting the service, if you want. If the service pivid is already running, it will tell you so – you don’t need to worry about entering it twice by accident.

Starting PiVid will open a web server on your Raspberry Pi’s port 3000. This will be accessible on your local network – and can be used to control video playback (of external URLs) on the Raspberry. This is by design, and we plan to release more documentation about this soon.

YouTube

youtube-raspberry-chromium

Navigate to a YouTube video (for example: Xcylin, shooting with a frickin’ laser). First, the browsers will display “Flash Player missing”, but after some seconds, the web site should reload, and display the PiVid play button, as seen above for Chromium.

Simply click this button, and the video should launch in a short while. This will be indicated by a “pause” button:

youtube-raspberry-c-pause

If you want to see the video again, please reload the page – PiVid currently can’t identify when the video has stopped playing.  The pause button currently has no function, but you can use omxplayer keyboard control (see below).

VeeHD

VeeHD is an alternative video hosting platform / community, sporting an interesting selection of movies, documentaries, etc.

PiVid supports playback on VeeHD. You may need to log in as a VeeHD user for some videos to work, and some videos are hosted on very slow servers – where streaming is impossible with PiVid. Please download the video and play it with omxplayer instead.

Usage: Search with the VeeHD search, and click on the video you would like to see. PiVid will show you the play button after a short while:

veehd-raspberry-pi

Omxplayer keyboard control

Space or p = Pause / Resume
– / + = Decrease / Increase Volume
q = Quit

 

Problem handling

YouTube play button not showing

If the PiVid play button does not show up on a YouTube video, instead of the warning about an incompatible browser, please try to simply reload the page – it should show up now.

Restarting the service

If you run into any unexpected problems using the software, try restarting the pivid service:

service pivid restart

If this does not help, try restarting your Raspberry, and starting the service after that. If still stuck, comment below. (Use “pivid” instead of “service pivid start” to see some advanced debugging output).

update-rc.d

Please note, that update-rc.d can’t be used right now to install the service as autostart on boot – we are investigating the cause and will release an update soon. (pivid service will start, but without video playback.) Please use the manual starting method ( service pivid start ) in the meantime – thank you!

Background

PiVid works as a server (written in the uber-cool Node.JS), which will display an IFRAME in your browser. Through a user script, the browser can submit the URL needed to retrieve and play the video. Once you click on the “play” button, PiVid will invoke some software incantations (sprinkle the equivalent of magic fairy dust – we’re building on the shoulders of giants – you guys know who you are :-) – and voilà – the video location will be passed to omxplayer, the trusty workhorse of Raspberry Pi video playback!

You can, of course, fork us on GitHUB.

By the way – we have also packaged a newer version of Node.JS to go along with PiVid on our repository – package name is “nodejs”. Stay tuned for more about this.

The idea for PiVid was taken from a very similar client-server approach, which was coded in Python, but seems to be abandoned now. Thank you for the inspiration!

Reference

Optimization WordPress Plugins & Solutions by W3 EDGE