What is it?
RPi-youtube is a simple extension and local program combo to allow you to run youtube videos smoothly on the Raspberry Pi. If you install RPi-youtube when installing chromium (sudo apt-get install rpi-youtube
) and have installed the extension then by simply clicking the icon on a youtube video it will pause it and open up nice and full screen for you to watch. It works on any of these 600+ websites.
Install it
Installation is simple (BUT WILL ONLY WORK ON A PI2 OR PI3!!!):
wget -qO - http://bintray.com/user/downloadSubjectPublicKey?username=bintray | sudo apt-key add -
echo "deb http://dl.bintray.com/kusti8/chromium-rpi jessie main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install chromium-browser rpi-youtube -y
If you already ran these instructions to install Chromium, there's no need to install it again. To update which should be done regularly:
sudo apt-get update
sudo apt-get dist-upgrade
run_omxplayer.py -U
How does it work?
RPi-youtube is divided into two sections, the extension and the native app.
The extension
The extension is totally separate from the native app. It lives in Chromium and its job is to detect youtube links or detect clicks on the icon. Once one of those is detected, it retrieves the url and sends what's called a native message to the native app. Because of security concerns, Chrome apps are not allowed to directly start or execute code on the machine. Instead, you must send a message to a program locally which will execute everything. The main part of the program is the native app.
The native app
The native app is called run_omxplayer.py and is a simple python script which reads the input through stdin and then runs omxplayerGUI with that url. run_omx.json is a manifest file which is installed in /etc/chromium-browser/native-messaging-hosts which tells Chromium where to find the program and all the necessary information. Once a message is sent to run_omxplayer.py, it reads that, starts ytdl_server.py if it is not already running and runs a script to stop it when chromium quits and runs omxplayerGUI.
The install procedure
The install procedure for RPi-youtube starts with installing the package and its dependency omxplaayerGUI, which is provided by kweb. A python script is installed, named run_omxplayer.py and a bash script called start_ytdl_server.sh is installed. With kweb, omxplayerGUI is installed as well as ytdl_server.py (a faster way to call youtube-dl) as well as youtube-dl. The postinst script of rpi-youtube executes Chromium and opens it up to the extension installation page, where that must be installed as well to communicate with the local script. Once the extension is installed, installation is finished and ready to use.
Details
A post by gkreidl (edited) sums it up nicely:
If you install kusti8's rpi-youtube extension to enable playing web video in high resolution with omxplayer(GUI), you will also get the kweb package, which provides omxplayerGUI. The extension basically adds a button to the chromium-browser interface similar like kweb's "Play" button, which sends the video page URL to omxplayerGUI, which extracts the real video URL (using youtube-dl) and plays it. This doesn't only work for youtube, but for 600+ video websites and all websites containing static HTML5 video tags. This tutorial is for people who are not familiar with omxplayerGUI and the kweb environment. It will also show you, how to manage the youtube-dl server.
youtube-dl support
During installation you will be asked, if you want to install the the github version of youtube-dl, which is highly recommended. If you missed that, you can install (and update) it later on: Start kweb (from the application menu). Click on "Applications". At the bottom you'll see a heading "Youtube-dl Tools". The first two buttons let you install and update (for later use) the github version of youtube-dl (some other buttons will be explained later).
Using the youtube-dl server
If you have installed the github version of youtube-dl, you will be able to use the youtube-dl server (another tool from the kweb package). It will speed up access time for web videos considerably: the time it takes from clicking the button to start playing the video (1-3 seconds, the first video may take a bit longer). It's especially useful if you plan to watch a lot of web videos. Note: The latest version of rpi-youtube starts the the youtube-dl server automatically, if it is not running already. It will also stop the server cleanly a few seconds after you have closed the chromium browser.
Starting the youtube-dl server separately
- From the kweb Application page: Click the "Start Server" button.
- From a terminal: Type
ytdl_server.py
In both cases the server will run inside a terminal. Do not simply close the terminal, because that will leave the server in an undefined state because of its multi-threaded nature (a special Python problem). Use one of the stop methods described below.- Start the omxplayerGUI frontend from the application menu. This will also start the server. Closing the frontend will automatically stop the server again (no separate stop method needed).
Stopping the youtube-dl server
- From the kweb Application page: Click the "Stop Server" button.
- From inside chromium: go to http://localhost:9192/stop (add this as a bookmark!).
Configuring omxplayerGUI
omxplayerGUI has lots of configuration options. The easiest way to configure it is the following: Open the omxplayerGUI frontend from the Application menu (Multimedia). Click the "Help" button to open the manual in your PDF reader. Click on "7) omxplayerGUI settings" on the content page. Click the "Edit Settings" button in omxplayerGUI. This will close the frontend and open a specially configured kweb instance showing the "Settings" page. Now you can edit all the settings you like. Some are very special. The manual will give you some hints, which may be important for you. After applying some changes, you can save them as a "Preset" which will make them accessible with one mouse click later on. Check the manual for more details. If you close kweb, the omxplayerGUI frontend will be restarted using the new settings (good for testing them).
Switching to full screen mode
omxplayerGUI can be preset to display video in different ways. By default it will run in a maximized window with controls at the bottom. To switch to full screen view, while a video is already running, press ALT+h (hide controls) followed by ALT+f (full screen). To return to window mode, press both key combinations again.
Offset between window and video content
If you experience an offset between the video window and the video content, it is caused by "overscan" settings. omxplayer, kodi and all software using the screen hardware directly, use the hardware coordinates of the current screen resolution, while the frame buffer (used by the GUI) may have a different size if overscan is enabled. Remove all overscan and framebuffer size settings ftom /boot/config.txt. Overscan is never needed for monitors and TVs can be set to the right screen size (no borders etc) from their menu functions. omxplayerGUI can also be used to play any media content from your file system. For more details, check the manual. If you have question not related to rpi-youtube, please ask them in this thread
Support
Any feature requests can be opened as issues on the Github page. Questions and problems are best answered here https://www.raspberrypi.org/forums/viewtopic.php?t=121195