Howto - play youtube videos in Mplayer

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
stu90

Howto - play youtube videos in Mplayer

#1 Post by stu90 »

Updated script and guide
If you use old version just delete it from /root/my-applications/bin and copt this one to there.
-----------------------------------------------------------------

Updated script v4 and guide

Step 1.
First download this file vid.gz
(updated script v4) http://dl.dropbox.com/u/3009188/vid.gz
Step 2.
Move (Drag & Drop) the archived file vid.gz to the directory /root/my-applications/bin

Step 3.
Now mouse click on the vid.gz file and decompress in is current location /root/my-applications/bin

Step 4.
(Drag & Drop) the vid file in /root/my-applications/bin to your desktop - you can add a custom icon of your choosing by: right mouse button click > File 'vid' > Set icon.. then (Drag & Drop) your icon into the dialog box.

To use.
Go to some popular video streaming site such as Youtube find the video/s you wish to watch click on Play then immediately pause the video - now minimize your browser and click on the vid icon on your desktop, your video should now play in Mplayer.
You can also start the video from terminal by using the command: vid
Or add a launcher in your panel / taskbar by directing the launcher to /root/my-applications/bin/vid

save videos.
after video/s have played a little GUI pop up giving you the option to save files or exit with out saving - GUI will time out after 20 seconds if you don;t select an option no video will be saved.

Default save location is /root you can change the save location by right clicking of the vid Script > File 'vid' > Open as text and enter your save location in between the quotes on line four.

If no videos are found in /tmp the save GUI will still pop up just exit it or leave it to time out on its own.

Tips.
P key to play / pause
Q key to Quit
F key to toggle full screen
arrow keys to skip forwards / backwards
cheers.
Last edited by stu90 on Sat 12 Feb 2011, 16:44, edited 4 times in total.

gcmartin

#2 Post by gcmartin »

Thanks. I have been looking for this type of method to handle playback on low memory machines ("Jerky play when watching in a browser") This solves that.

If you update this script, would you add a feature to move file to somewhere other than temp/tmp.

Anyway Thank you for sharing a very useful piece of work
Last edited by gcmartin on Sat 12 Feb 2011, 08:26, edited 1 time in total.

keniv
Posts: 583
Joined: Tue 06 Oct 2009, 21:00
Location: Scotland

#3 Post by keniv »

Hi stu90

I like this little program. It works well on an old laptop. Lets me watch a smooth version of video then I rename and move from /tmp any I want to keep. I tried to play the flash that the BBC use in iPlayer but had no luck. I am not sure how the BBCs stuff works but thought it was worth a try.

Regards,

Ken.

stu90

#4 Post by stu90 »

See first post for latest update.
Last edited by stu90 on Sat 12 Feb 2011, 14:35, edited 1 time in total.

stu90

Re: Online Video Playback via Mplayer

#5 Post by stu90 »

gcmartin wrote:Thanks. I have been looking for this type of method to handle playback on low memory machines ("Jerky play when watching in a browser") This solves that.

If you update this script, would you add a feature to move file to somewhere other than temp/tmp.

Anyway Thank you for sharing a very useful piece of work
Hi gcmartin,
See update in post three.
keniv wrote:Hi stu90

I like this little program. It works well on an old laptop. Lets me watch a smooth version of video then I rename and move from /tmp any I want to keep. I tried to play the flash that the BBC use in iPlayer but had no luck. I am not sure how the BBCs stuff works but thought it was worth a try.

Regards,

Ken.
Hello keniv,
Yes i don;t know how you would save such files as they don;t seems to save anything in /tmp - same with the 4od and ITV videos as well. :(

gcmartin

Online Video Playback via Mplayer instead of Browser

#6 Post by gcmartin »

If I understand, correctly,
"vid" looks in /tmp for a known video format that it will launch.
Is that true? (How does it identify a multimedia for playback?)
If a site somehow was able to direct a video to your system into some other folder; say /root or anywhere else, "vid" may not be able to find it.
Is that true?
And, I would assume that if one was on a website where your browser is used to directly display audio-video content directly from the server (i.e server-side Java) thru your browser, "vid" would not be able to detect this.
Is that true?
Thus, items that are handled thru the browser via HTML5 or thru Adobe Flash would not be detected by "vid".
Is that true?

Correct me if any of this is wrong.Thanks, again, for your good work.
P.S. Your script is so small, why compress it? That would reduce a step that newbies would get wrong. Its a thought, not a request; per se.

stu90

#7 Post by stu90 »

New update v.4 see first post

Hi gcmartin,

vid will search for a string in file name - for instance 'Flash' for Youtube Vimeo etc - v4 will also search for other strings like 'mp3' now as well - so you could in /tmp have a flash video, avi video, and an mp3 audio, vid will detect each and play/save them.
You could add what ever string you like see line 7-13 and line 15 & 22.

vid will search /tmp by default but you can change it to search a different directory if you wish say ./downloads instead of /tmp - see line 6 of script.
I don;t know how you would have it search multiple directories say /tmp & /root ?

BBC html5 if the file is encrypted or if there is no media file for vid to find in a directory it wont play that file.

I put vid in archive file because dropbox for some reason changes the format to a .txt file - so after some one downloaded to get the script to work they would need to rename it.

cheers.

stu90

#8 Post by stu90 »

have re written most of this Script - after files have played a dialog will pop up with a list of files found / played and option to save files. If no files found you should get another popup saying no file found that will time out or click ok.
Default save location is /root/vid default search location is /tmp both can be changes if you open script as text.
Image

v5 http://dl.dropbox.com/u/3009188/vid.gz

umair
Posts: 245
Joined: Sat 25 Dec 2010, 11:09
Location: KUST Kohat, Pakistan
Contact:

#9 Post by umair »

Hi Stu90:
I used ur script, but it gaves me the error: (I m posting he screenshot when I clciked on the vid icon also when I type the vid in the path).
I m using Lupu525 on my old P-III, 512 MB RAM 20 HDD with FRUGAL Install.
any Idea?
Thnx in advance.
Regards
Umair

stu90

#10 Post by stu90 »

umair wrote:Hi Stu90:
I used ur script, but it gaves me the error: (I m posting he screenshot when I clciked on the vid icon also when I type the vid in the path).
I m using Lupu525 on my old P-III, 512 MB RAM 20 HDD with FRUGAL Install.
any Idea?
Thnx in advance.
Regards
Umair
Hello umair,
try in terminal:
chmod +x /path/to/script

Flash has undergone some changes since this script was written - it no longer stores videos in /tmp for easy access so if you are using a new version of flash this script may no longer work.

If you are using a newer flash version try pasting the code below to the bottom of your /root/.bashrc file.

Code: Select all

function flashvideo () {
VID=$(stat -c %N /proc/*/fd/* 2>&1|awk -F[\`\'] '/lash/{print$2}')
mplayer -autosync 30 -mc 2.0 -cache 1000 $VID
}
 
then in terminal run the command: ~/.bashrc to reload.

Now start streaming video in web browser then pause it - open a new terminal window and enter the command: flashvideo
this should now play the video in mplayer.

keniv
Posts: 583
Joined: Tue 06 Oct 2009, 21:00
Location: Scotland

#11 Post by keniv »

Hi stu90

I am using 528 on an old Toshiba laptop PIII 800MHz 320MB. I have followed your instructions above but after typing flashvideo in a new terminal I get "command not found". I have checked that I copied and pasted your script correctly. I tried rebooting my machine but got the the same result. Assuming I can get it to work would it just be a matter of changing "mplayer" to "vlc" in your script to get it to play in vlc or is there more to it than this? Also is it possible to save a copy of the video?

Regards,

Ken.

stu90

#12 Post by stu90 »

keniv wrote:Hi stu90

I am using 528 on an old Toshiba laptop PIII 800MHz 320MB. I have followed your instructions above but after typing flashvideo in a new terminal I get "command not found". I have checked that I copied and pasted your script correctly. I tried rebooting my machine but got the the same result. Assuming I can get it to work would it just be a matter of changing "mplayer" to "vlc" in your script to get it to play in vlc or is there more to it than this? Also is it possible to save a copy of the video?

Regards,

Ken.
Hello keniv,

I have not used Lucid 528 but i think i read somewhere it has roxterm as default terminal? if so instead try using urxvt terminal in the Menu.

If this doesn't work make sure you have reloaded .bashrc file - but make sure to type the flashvideo command in a new terminal window.

I don't use vlc i imagine it will work though - you will probibly need to change the mplayer line to something like:
vlc $VID or what ever the vlc command might be to play a video file from the command line.

Don't forget though to reload the .bashrc file every time you make changes to it and try the command in a new terminal window so the changes take effect.

keniv
Posts: 583
Joined: Tue 06 Oct 2009, 21:00
Location: Scotland

#13 Post by keniv »

Hi stu90

Thanks for your quick reply. Typing the flashvideo command into the urxvt terminal did the trick. I tried your suggestion to get the video to play using vlc but it did not work. I tried to find the command to get vlc to play a video from a terminal by typing vlc --help. Although this gave me a large list of vlc commands I could not find an appropriate one. As you probably realize I am not very sure what I am doing in this respect but I will play about a bit and see if I can get it to work. However, I am quite happy it works with mplayer. This is a good way to play flash video smoothly on old hardware like my laptop. If I play it through the browser it's jerky. Is it possible to save a copy of the video using this method?

Thanks again,

Ken.

umair
Posts: 245
Joined: Sat 25 Dec 2010, 11:09
Location: KUST Kohat, Pakistan
Contact:

#14 Post by umair »

stu90 wrote: Flash has undergone some changes since this script was written - it no longer stores videos in /tmp for easy access so if you are using a new version of flash this script may no longer work.
If you are using a newer flash version try pasting the code below to the bottom of your /root/.bashrc file.
Code:
function flashvideo () {
VID=$(stat -c %N /proc/*/fd/* 2>&1|awk -F[\`\'] '/lash/{print$2}')
mplayer -autosync 30 -mc 2.0 -cache 1000 $VID
}
then in terminal run the command: ~/.bashrc to reload.
Now start streaming video in web browser then pause it - open a new terminal window and enter the command: flashvideo
this should now play the video in mplayer.
hi stu90:
1st of all thnx alot for quick response. I used your above method and WOW
works perfectly. U Rocks :)
Now I m able to play youtube with full screen without any problem on my old system.
once again thnx.
Regards
UMAIR

Post Reply