Friday, June 7, 2013

Playing YouTube videos in the browser on the Raspberry Pi

This will allow you to stream up to 1080p youtube videos in the browser on the Raspberry pi using omxplayer. It's a crude hack but it seems to work pretty well on my system. Install instructions and a demonstration video are shown below.

You can install this by pulling the git repository and running the scripts below.
Commands to install are below (your user should have sudo privileges but you don't need to be root):

You may have to enable user scripts in Midori by going to Menu>Preferences>Extensions>UserScripts and clicking the check box.

sudo apt-get install git-core
git clone git://
cd PiAUISuite/Install/

**NOTE, this will ask you if you want to install a lot of different scripts because it is a SUITE. You only have to pick the ones you want to use. If you only want to use the youtube scripts, press n on any other question except for the dependencies and youtube.

Update Instructions 

cd PiAUISuite
git pull
cd Install
sudo ./


There is a lot of misinformation out there on how to do this. Using gnash or HTML5 is going to result in a frame rate so slow it can be considered unworkable. I've tried both of them out and you can't really watch videos with them. XBMC has a youtube plugin but it is buggy and crashes often.

I've been playing youtube videos using the command line and my voicecommand using the scripts found here.
After seeing a couple people ask about playing youtube in the browser last night, I decided to go ahead and do that and create some user scripts for midori which allow the browser to utilize the same hack.

Here is the technical overview:
I created a script called youtube which uses the youtube-dl -g flag to grab the video URL. It also handles playlists and other parsing. Then it passes that video URL to omxplayer for it to stream. 
Next I registered a new URL protocol yt:// and made it pass it's information to the youtube program whenever it runs. 
Finally, I created a user script in Midori which simply replaces all* URLs with yt://*.

Feel free to let me know any problems you have and enjoy your Youtube browsing experience.

 Consider donating to further my tinkering

Places you can find me

1 comment:

  1. Can this script work with 32 bit computers? My laptop has a pretty crappy processor and cant go past 360p without noticible studdering