NoFlash - Watch Online Videos with Mplayer
Why?Adobe's flash implementation on linux is inefficient, consumes too much CPU, does not work well with embedded systems / older hardware, and various security issues associated with it pops up frequently. I was looking for a good solution to avoid flash for sometime. There are a few commandline utilities such as youtube-dl, clive, cclive, quvi that can download online videos if you copy and paste the URL the video resides in from dozens of online video sites. They do what they do well, but this approach was a bit cumbersome for me. I wanted to be able to just visit the web sites, use their navigation, links etc., and automagically have the videos pop up and play in mplayer as I navigate. My home entertainment system is a linux box connected to a TV and we watch TED talks or other online videos on it. I also wanted to be able to conveniently send video links for it to play from other computers we may have around (laptops, tablets, smartphones). Here are the requirements I had in mind:
How does it work?Two components:
The client can be a javascript bookmarklet, a geasemonkey script etc. For now, let's assume that it is a greasemonkey script that, after loading a page, pings the server with the URL you are currently visiting. Server is a simple and fairly small bash script hacked up via netcat (no perl/python etc.). Requests are just URLs that the client sends. Server parses the URL, matches it against the patterns the extractors (youtube-dl, quvi etc.) support, tries to extract an actual video URL, and plays it by streaming it via mplayer. (It can do more, but we will get to that later). If everything is set up properly, you just visit a supported online video site (e.g. youtube), browse around, and videos are started in the background using mplayer. They just pop up. InstallationAssuming that you are using a GNU/Linux distribution, make sure you have the following packages installed:
You need one or both of youtube-dl and quvi. I use both, since combined, they cover more web sites. If you are happy with just one, that is fine too. For debian wheezy you can do: $ apt-get install netcat-openbsd youtube-dl quvi mplayer xul-ext-greasemonkey For other distros, just use your favorite package manager and install equivalent packages. The rest of the stuff that is needed is pretty standard (grep, awk, sed etc.). They are probably already installed but if not, just install the appropriate package(s).
If you look closely, you may notice something weird. The contents of all of those files above are the same. In fact they are just symlinks to noflash which is all you need to download actually. Noflash is, what I call, a chameleon script. The same file is
Have a look at the code and start the server via: $ bash noflash It should output something like this: NoFlash Copyright (C) 2013 Bilgehan Uygar Oztekin, License: GPLv3 Watch online videos without flash using mplayer, quvi, youtube-dl etc. This script is a valid bash script, greasemonkey (gm) script, and an html page. - As a bash script, becomes a web server accepting the following request types: - http://* -> Play a remote video extracted from URL. - file://* -> Play a local video at the specified path. - mplayer:* -> Send command to mplayer running in slave mode. - Server has a basic web interface to control mplayer, submit URLs, or download a js bookmarklet and/or a gm script. Gm script pings the server with visited web pages (http only). Js bookmarklet sends the current page when clicked on. How to use it: - On server, run this as a bash script (e.g. bash noflash). - On client (can be the same machine), go to http://localhost:9000 and install the javascript bookmarklet and/or the greasemonkey script. - With the gm script, videos from supported sites should start automatically as you browse. If you prefer to use the js bookmarklet, click on it to initiate. - Server binds to localhost only by default. Change NOFLASH_SERVER to server's IP to be able to access and remote control it from other computers (clients). - See http://www.cs.umn.edu/~oztekin/software/noflash for more information. Server listening on http://localhost:9000 To setup the client portion, point your browser to the link it provides at the last line above (http://localhost:9000 by default). You should see a page like this. Using the links the server provides, install the greasemonkey script and/or the javascript bookmarklet. Note that the server needs to be running everytime you want to use NoFlash, but you only need to setup the client portion once. If everything is set up properly and the greasemonkey script is installed and enabled, whenever you visit a video page that is supported, it will be launched within mplayer. If you are using the bookmarklet instead, click on it to launch the video. If you would like to use this script along with flash plugin I recommend installing flashblock extension to avoid the same video running on both mplayer and within the browser simultaneously. If you come across a video that the script cannot handle, you can just click on it to start. Remote AccessServer actually accepts the following types of requests:
NOFLASH_SERVER="localhost"to look like: NOFLASH_SERVER="192.168.1.10"to bind to that specific IP. Run the modified script on the server. Let's call this, the TV.
See this link for more information about available commands for mplayer. Does it work on other operating systems?Not tested. It may work on other unix-like systems including BSDs (or OSX) with little or no modifications provided that you have the necessary packages installed. I don't have plans to support windows. If you get it to work on other operating systems or have additions/modifications, let me know and I will be happy to update the script and/or provide a link. Similar projects
LicenseNoFlash is available under the GNU General Public License, Version 3FeedbackFeedback/suggestions are welcome. I can be reached at oztekin at cs dot umn dot edu. | |
Copyright © Bilgehan Uygar Oztekin |