gkreidl
Posts: 6120
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

HOWTO: Web video with omxplayerGUI and Chromium-Browser

Mon Oct 17, 2016 9:28 am

For more than 3 years kweb(3) has the built-in possibility to play web video (youtube and 600+ other websites) in high resolution and perfect quality using omxplayer(GUI). Just click the "Play" button in the toolbar on a video web page.

Recently kusti8 has published an extension for the Chromium-Browser that offers the same functionality. It also uses the kweb package (omxplayerGUI and youtube-dl-server). Unfortunately this doesn't work any more with the recent RPF chromium-browser version.

I have built a similar solution for Firefox, which can also be used for chromium-browser now (although it is less elegant than kusti8's solution).

Installation

1) You need the kweb package, if you don't have it installed already: viewtopic.php?t=40860
During installation you will be asked, if you want to install the github version of youtube-dl. It's important to answer with "y". If you missed that, you can install it later from kweb's application page.

Simple method:
(based on a solution for Firefox suggested by MartinLaclaustra):

In chromium right click into the bookmarks toolbar and select "Add Page". In the form set name to "PlayVideo" and paste the following into the URL field:

Code: Select all

javascript:(function(){var target_url=window.location.href;var ytsvr="http://localhost:9192/play?url=";var final=ytsvr.concat(encodeURIComponent(target_url));var myWindow=window.open(final,'_top')})();
Select "Bookmarks Toolbar" below and click "Save". You now should have a new button "PlayVideo".

That's all. You can skip steps 2) and 3) below.

Userscript method:

2) Start chromium-browser and select "Settings" from the menu. Select "Extensions". At the bottom there is a link "Download more extensions" (or similar, I'm on a German system). Click it. A new tab will open with the chrome web store. Search for "Tapermonkey" and install it. Restart chromium-browser afterwards.

3) Go to extensions again, find the tapermonkey extension and click on "Options". On Tapermonkeys menu bar click the icon on the left (it's the only one, the other menu items are displayed as text). The script editor will open with the "New Script" heading. Remove the default content and paste the following into the editor:

Code: Select all

// ==UserScript==
// @name        omxVideo
// @namespace   http://steinerdatenbank.de
// @description Play web video with omxplayerGUI
// @include     *
// @version     1
// @grant       GM_registerMenuCommand
// @grant       GM_getValue
// @grant       GM_setValue
// ==/UserScript==

GM_registerMenuCommand( "Play Video", playvideo, "p");
GM_registerMenuCommand("Video Button on/off",togglebutton);

if (GM_getValue('playbutton',false) === true) {
var input=document.createElement("input");
input.type="button";
input.value="Play";
input.onclick = playvideo;
input.setAttribute("style", "font-size:10px;position:absolute;top:100px;right:20px;");
  document.body.appendChild(input); }

function playvideo() {
  var newuri = "http://localhost:9192/play?url=" + window.location.href;
  window.top.location.href = newuri;
}

function togglebutton() {
if (GM_getValue('playbutton',false) === false) {
GM_setValue('playbutton',true) ; }
else {
GM_setValue('playbutton',false); }
}
Click the "Save" icon (second from the left). If you now browse to any web page, the tapermonkey icon will display the content shown in the attached image.
chromiumytdl.jpg
chromiumytdl.jpg (30.42 KiB) Viewed 11301 times
It contains two new commands: "Play Video" and "Video Button on/off". In order to use them, the youtube-dl-server of the kweb package must be running (see below).

4) This step is optional, but it is the easiest way to use Chromium-Browser with the new feature.
Open a terminal to create a script:

Code: Select all

cd Desktop
nano chromium-omx
Enter the following into it (you can use right click and "Paste"):
#!/bin/bash
ytdl_server.py > /dev/null 2>&1 &
chromium-browser
wget -O /dev/null http://localhost:9192/stop
Press CTRL+o to save it and CTRL+x to leave the editor.
We have to make the script executable:

Code: Select all

chmod +x  chromium-omx
This script will start the youtube-dl-server (running in the background), then chromium-browser and will stop the youtube-dl-server again, if you quit chromium.

Usage

Note: In order to use the extension, the youtube-dl-server must be running. There are different ways to do this:
1) Use the script created in step 4 above to start chromium-browser together with the server. This will also stop the server cleanly when you close the browser.
2) If you have started chromium-browser from the application menu, you can start the server separately in two ways:
Open a terminal and enter:
ytdl_server.py
( Clicking "Start Server" frome kweb's applications page will do the same)

Alternatively you can also start the omxplayerGUI frontend from the application menu. This will also start the server (and stop it, if you close omxplayerGUI frontend).

Now go to a video page on youtube (or any other supported website). If you are using the simple method, click "PlayVideo" in the bookmarks toolbar. If you are using the userscript method, select "Play Video" from the Tapermonkey menu. After a few seconds (2-3 on a RPi 3, but it may take a little bit longer for the first video) omxplayerGUI will be opened and start playing the video. The video in the web page will stop playing, because now it shows a very simple web page from the youtube-dl-server with a message "Playing: " followed by the title of the video and a "Go Back" button below. Click this button to return to the original video web page after you have finished watching the video.

The second user script command "Video Button on/off" gives you a faster way to start playing a video. If you click it and reload the page, a small "Play" button will appear on the top right side of (almost) every web page. Clicking this "Play" button will start the video player in the same way as using the menu command. To disable the button again, select the user script command "Video Button on/off" again (it's a toggle command).

Note: On some websites (vimeo.com, for example) the "Play" button may not be visible, because it is hidden by something else. In this case you have to use the menu command.

Note 2: The "Play" button will also appear within frames or iframes contained in a page. This may be irritating, but also has one advantage: if a web page uses an embedded video, the "Play" button inside the embedding frame can be used to start playing the video. A good example are the embedded videos in the Raspberry Pi Blog. Clicking the "Play" button on top of the page will not start any video, but clicking the "Play" button inside the video frame will work.

Stopping the youtube-dl server
If you have started chromium-browser with the script created in step 4 above, you don't have to do anything. If you have started it manually you can simply close the terminal window. Or you can stop it from inisde chromium-browser:
go to "http://localhost:9192/stop" (add this as a bookmark!).

Using and Configuring omxplayerGUI
If you are new to omxplayerGUI you should start the frontend and click the "Help" button. This will open the omxplayerGUI manual in your preferred PDF viewer. It will give you all the information you need about using and configuring omxplayerGUI. There are really a lot of fine tuning options.

Updating youtube-dl
You should update youtube-dl from time to time. Do not use the "youtube-dl -U" command! You can do it in two ways:
1) Start a terminal and run
update-ytdl
(no sudo!)
2) Start kweb, click on "Applications". At the bottom ("Youtube-dl Tools") click the button "Update (git)".

Note: If kusti8's extension will be working again, you should prefer it. It starts and stops the youtube-dl-server automatically for you.
Last edited by gkreidl on Sun Jan 08, 2017 11:16 pm, edited 2 times in total.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

User avatar
Trixster
Posts: 261
Joined: Sat Jul 07, 2012 3:53 pm

Re: HOWTO: Web video with omxplayerGUI and Chromium-Browser

Mon Oct 17, 2016 4:06 pm

Works a treat! Thanks.

ultraduck
Posts: 3
Joined: Fri Jun 16, 2017 3:26 pm

Re: HOWTO: Web video with omxplayerGUI and Chromium-Browser

Sat Jul 08, 2017 5:02 am

I'm currently running the latest Raspbian on Berryboot. For some odd reason, after installing kweb, I cannot login at all. It just gets stuck. Help please?

gkreidl
Posts: 6120
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: HOWTO: Web video with omxplayerGUI and Chromium-Browser

Sat Jul 08, 2017 5:37 am

ultraduck wrote:I'm currently running the latest Raspbian on Berryboot. For some odd reason, after installing kweb, I cannot login at all. It just gets stuck. Help please?
Nothing to do with kweb. The installation script will install gdebi-core first (debian package installer from files) and then gdebi is used to install dependencies and kweb itself, which just installes a number of files in /usr/bin, /usr/local/bin and /usr/local/share/kweb.
Perhaps a corrupted or damaged SD card? This can happen at any time.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

ultraduck
Posts: 3
Joined: Fri Jun 16, 2017 3:26 pm

Re: HOWTO: Web video with omxplayerGUI and Chromium-Browser

Sat Jul 08, 2017 5:58 am

gkreidl wrote:
ultraduck wrote:I'm currently running the latest Raspbian on Berryboot. For some odd reason, after installing kweb, I cannot login at all. It just gets stuck. Help please?
Nothing to do with kweb. The installation script will install gdebi-core first (debian package installer from files) and then gdebi is used to install dependencies and kweb itself, which just installes a number of files in /usr/bin, /usr/local/bin and /usr/local/share/kweb.
Perhaps a corrupted or damaged SD card? This can happen at any time.
Yeah I did read the installation script and found this behaviour to be quite strange myself. I have also tried this several times with the "Clone" option in Berryboot just to make sure. Even on a vanilla Raspbian installation, as soon as I install kweb and reboot, it just gets stuck. At first, I was only seeing a black screen. And then I used raspi-config to require login. Now it boots up fine to the login screen. But once I enter the password and try to login, it just gets stuck again.
Also, when I login using ctrl+alt+f2 and do reboot, it gets stuck again for 3 minutes while waiting for some process to end. And then just before it shuts down, I see something like "Failed to stop Watchdog ...."

Anyway, I'll try to install this on another SD card with and without Berryboot and see what happens.

stevendom1987
Posts: 1
Joined: Sun May 13, 2018 12:57 am

Re: HOWTO: Web video with omxplayerGUI and Chromium-Browser

Sun May 13, 2018 12:59 am

What about a regular flash video not though YouTube? Also, omx player doesn't truly do full screen. You still get the bars at the top and there isn't a full screen option.

gkreidl
Posts: 6120
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: HOWTO: Web video with omxplayerGUI and Chromium-Browser

Sun May 13, 2018 3:56 pm

stevendom1987 wrote:
Sun May 13, 2018 12:59 am
What about a regular flash video not though YouTube? Also, omx player doesn't truly do full screen. You still get the bars at the top and there isn't a full screen option.
Flash or not is not important, it depends on the support of the website by youtube-dl (many hundreds of websites are supported).
And omxplayerGUI can be switched to full screen mode (also as default, if you like). There are two keyboard toggle commands, ALT+h (hide the controls) and ALT+f (full screen).
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

Return to “Raspbian”