Friday, January 28, 2011

YouTube true fullscreen video in linux


I got tired to buggy playback with flash player and the inability to play fullsize fullscreen video. Here is a little script designed to improve the quality of life.

What it does is first get the url of the video and then start downloading it. Once it fills the predefined buffer set in the script or the download finishes, it will start playing the video.

If the youtube-dl script from a repository doesn't work try getting it straight from here: http://rg3.github.com/youtube-dl/

For pure lazyness I also made a desktop icon where I can drag an url and it will automagically start playing the video.

Try it. It's good. :)




Setting up the script in Fedora
sudo su
yum -y install youtube-dl 
wget -O /usr/local/bin/youtube-play http://sebastianmaki.fi/files/youtube-play
chmod a+x /usr/local/bin/youtube-play




/usr/local/bin/youtube-play
#!/bin/bash
#youtube-player by Sebastian Mäki

if [ $# -eq 0 ]; then
 echo "Usage: $(basename $0) \$URL"
exit 0;
fi


PLAYER_NAMES="gnome-mplayer gmplayer mplayer"

for PLAYER_CANDIDATE in $PLAYER_NAMES; do 
 if which $PLAYER_CANDIDATE > /dev/null; then 
  PLAYER=$PLAYER_CANDIDATE; 
  break; 
 fi;
done;

BUFFER=$((1024*1024*2)) #initial buffer size 2MB


TMP=`mktemp`
COOKIES=`mktemp`
rm $COOKIES

URL=$(youtube-dl --cookies=$COOKIES --get-url $1)

wget -q --load-cookies=$COOKIES -O $TMP $URL &
PID=$!

SIZE=0;
while [ $SIZE -lt $BUFFER ]; do
 if ps -lp $PID > /dev/null; then 
  SIZE=$(stat -c%s $TMP)
 else
  SIZE=$(($BUFFER+1))
 fi
 sleep 1;
done;
$PLAYER $TMP
kill -9 $PID
rm -f $TMP $COOKIES




Youtube-Player.desktop <-- put this shortcut file to your desktop
[Desktop Entry]
Version=1.0
Type=Application
Terminal=true
Name=Youtube Player
Name[fi_FI]=Youtube Soitin
Name[sv_SE]=Youtube Spelare
Exec=youtube-play %U

Icon=/usr/share/icons/YouTube_icon.png

7 comments:

Alison Robert said...

Typically, the bonus is given in the form of a small scholarship, about 5 or 10 euros paraskasinotfi.com. You can use the bonus to wager on any online casino game.

Bob said...

Definitely this was super helpful tips regarding the fullscreen video in Linux. Sometimes for technical problem or old version of flash player may happen display problem. But the script you text on this page was very effective surely. In fact, I was in search of getting some reliable source to buy youtube views. BTW do you think for buying views youtube channel can be suspended? Thanks in advance for your helpful support.

TechMatrite said...

So they tend to answer emails, messages, comments, Tweets, fan mail and even their cell phones. youtube subscribers

Ytube views said...

Best website to buy YouTube Views is comments.
buy instagram followers real

Cameron Washington said...

Mielestäni sinun pitäisi tehdä siitä video ja lähettää YouTube-kanavallesi. Kanavasi mainostamiseksi Osta Youtube Tilaajat

Andrew said...

What a conducive demonstration! This is really an incredible support for the Linux users to enjoy fullscreen youtube video. The codding effort you dedicated here for your fans and readers will never be praised only with few words. I appreciate your handy coding project. I fact, I was browsing with a view to getting some top notch ideas on how to promote youtube video? And I searched here if I get any related post. Unfortunately, found no post. Can you please bring an update in your future post?

Gabbie Gabbie said...

The particular month-to-month meetings are excellent, they provide me excellent guidance how to improve my opportunity. website designing company

Tip me if you like what you're reading