Sunday, November 24, 2013

Makeshift DIY Youtube and Flash Video Player w/o Flash

This is a dirty hack for a video stream player. It's using youtube-dl, a script which can download videos from Youtube, as well as many other sites, including those graphic ones. We will have youtube-dl download a temporary file which is played with a 5 second delay in mplayer. The script is completely immature and probably won't properly kill processes and such, so you've been warned!

1. Deps

1.1. Install youtube-dl

 # wget -O /usr/local/bin/youtube-dl  

 # chmod a+x /usr/local/bin/youtube-dl  

1.2. Install mplayer and Zenity

 # apt-get install mplayer zenity

2. The script

 URL=`zenity --title "Dirty Youtube Player" --text "Please paste URL here: " --entry`  
 if [ -f ~/.utubetmp ]  
    rm ~/.utubetmp  
    mkfifo .utubetmp  
    youtube-dl $URL -o .utubetmp &  
    sleep 5 && mplayer .utubetmp && rm .utubetmp  

I called the temp file .utubetmp and made it reside in your current user's home folder. It's also a hidden file.

You run the programme (I called it utube and put it in my ~/.bin), paste a video URL in this dialogue:

and eventually, you'll get a video after 5 seconds or a bit more...

There you go! You've got yourself a lovely Flash video player which actually should be using less resources than actual Flash and doesn't even require you to have Flash installed.

Bugs: Skipping ahead is possible only until the point youtube-dl has already downloaded, skipping back breaks MPlayer and it exits, pausing and resuming works though.

No comments:

Post a Comment