In this article I will outline a few methods to download YouTube Videos to your system and getting them to play in your favorite player. We will go in a step-wise way :
A. Getting the Video
- Online Tools
There are some sites like KeepVid.com which allow users to input a YouTube link and they would give you the download link. So get the download link from this site and download the flv file.
- Firefox Plugin
There is a firefox extension which allows you to download YouTube videos as you watch them. I haven’t tried this. - Command Line Tools
This is the safest and best way (for CLI junkies
). Download the script YouTube-dl (thanks to Ricardo Garcia Gonzalez for this nice script). Just put that script in your ~/bin or /usr/bindirectories or somewhere in the application path.
To download the flv video do this :
youtube-dl
e.g : youtube-dl http://www.youtube.com/watch?v=D1R-jKKp3NA
B. Playing the video
- Use VLC Player or MPlayer or Kaffeine to play the flash video.
- If the above method doesn’t work out (It din’t in my case)..Then go the difficult way :
- Get ffmpeg for your system. SuSE users can get it here.
- Convert the flv video to avi (or any other format) using ffmpeg :
ffmpeg -i my_flash_video.flv the_avi_file.avi - Now drag and drop the avi file into your favorite video player n watch the video
Still unsatisfied ?! “Dude I’m a *nix user. I can’t sit and do all these steps to get a simple video playing !!” No probs. We will write a shell script to do all this work for you.
Note : I found the downloader in youtube-dl quite slow. So I tweaked it a bit(I don’t know python
) to use an external downloader (axel rocks!). Open the file youtube-dl in your favorite editor and change the following lines :
282 # Abort here if in simulate mode
283 if cmdl_opts.simulate:
284 sys.exit()
to the following :
282 # Abort here if in simulate mode
283 if cmdl_opts.simulate:
284 cond_print(video_data.geturl())
285 sys.exit()
That will make the script output the downloadable video link to the standard output (when run in simulate mode). Now write the shell script :
#!/bin/bash
if [ $# -ne 2 ]
then
echo "Usage : $0 <youtube_file_link> <output_file_without_extension>"
echo "e.g : $0 http://www.youtube.com/watch?v=D1R-jKKp3NA steve_jobs"
else
outputfile=".avi"
todnload=`youtube-dl -s $1 | tail -n 1 -`
echo "Got the file.."$todnload
axel -n 100 $todnload -o $2".flv" # wget -c $todnload -O $2".flv" .if you don't use axel
echo "Download Completed..."
ffmpeg -i $2".flv" $2$outputfile # get the avi file
fi
Done. Now paste that code into a file utube in your path. Then run utube as :
utube http://www.youtube.com/watch?v=D1R-jKKp3NA steve_jobs
This will give 2 files steve_jobs.flv and steve_jobs.avi ![]()
Just drag the *.avi to kaffeine and enjoy the speech by Steve Jobs !
Technorati Tags: youtube, google, linux, axel, download, videos, shell, cli, command line,
the firefox plugin, if used along with some download manager is quite hassle-free. two clicks, and you’re done.
Downloading videos is very, very useful if you want to watch a video, but can’t due to the slow buffering. downloads complete in max fifteen minutes, much faster than it’ll take to buffer it and watch it.
http://www.snatchvid.com/ try this site it works great!
Pingback: Voglia di Linux » Blog Archive » Scaricare video di Youtube
Pingback: Computerstammtisch » Blog Archive » Runterladen von Youtube-Videos
I use http://www.savetube.com to save youtube videos
excellent!
Thank you!
And thanks especially to Ricardo Garcia Gonzalez for his script.
Rather than modifying the youtube-dl.py script, you can just use the ‘-g’ option:
-g, –get-url print final video URL only
I also find the title option to be useful:
-2, –title-too used with -g, print title too
(It may be that these are recent additions to the script
A few recommendations for your bash script: it’s good to get in the habit of using the newer $(command) syntax for command substitution rather than the old `backtick` syntax. Here’s why:
http://wooledge.org/mywiki/BashFAQ/082
Also, the script seems to be displaying here with “smart quotes” rather than “standard double quotes”. If I was to copy/paste the script as it is, it would not work because of those smart quotes, and that’s the kinda thing that’s really tricky for a newbie to figure out.
On my system (debian etch, using codecs from debian-multimedia.org) mplayer can play the original flv files! no conversions needed – yay!
Cheers,
David
Thanks for the information. I will post an updated version of this script with the changes
Thanks for echoing this script here! It was precisely what I was looking for.
# off-topic:
I just wanted to point out that WordPress by default uses smartquotes — even within <code>blocks</code> — which means that a direct copy+paste of the code block above will fail out in bash. We used to be able to escape smart quotes by disabling certain filters, but that method is deprecated and no longer works (so if you Google it, make sure you limit the date to within the last 6mo).
I won’t spew URLs here, but if you Google “Trials and tribulations of using WordPress to display code syntax”, you’ll come across a post that might help.
I could directly copy/paste the code into VIM. Just make sure you’ve the paste mode enabled with “:set paste”.
Thanks for the pointer, but unfortunately wordpress.com doesn’t allow user plugins. Enjoy the script
use Qttube..a linux GUI apps.
Hi,
you can download youtube videos on
http://www.downloadyoutubevids.com
Here you can also search, watch and download youtue videos.
All in One
http://home.gna.org/clive/
clive is a video extraction tool for user-uploaded video hosts such as Youtube, Google Video, Dailymotion, Guba and Metacafe. It can be chained with 3rd party tools for subsequent video re-encoding and playing and playing.
If you run ubuntu:
sudo apt-get install clive
There’s also another way to download youtube videos, and videos from many other sites using the command line in linux. check this out.
Forgot to insert the link. sorry.
R u lot 4 real,all u do is start download from youtube then press pause.Let the video download then when it has finished go to your temp folder the video will be there.With your web browser still open drag the file from temp 2 where ever u want to save file its that easy.But remember not to close the browser down till you have removed video from temp folder
Great Tutorial!
Pingback: Update Download youtube videos in linux « Inside Out
Pingback: How I Save Videos from YouTube « technobody
There’s a simple script here that works with new YouTube updates:
http://blog.johnlawrence.net/2008/12/youtube-download-shell-script/
youtube-dl has moved! Please update your bookmarks!
The new website is located at http://bitbucket.org/rg3/youtube-dl/
Extracting URL “t” parameter… failed.
Error: unable to extract URL “t” parameter.
Try again several times. It may be a temporary problem.
Other typical problems:
* Video no longer exists.
* Video requires age confirmation but you did not provide an account.
* You provided the account data, but it is not valid.
* The connection was cut suddenly for some reason.
* YouTube changed their system, and the program no longer works.
Try to confirm you are able to view the video using a web browser.
Use the same video URL and account information, if needed, with this program.
When using a proxy, make sure http_proxy has http://host:port format.
Try again several times and contact me if the problem persists.
just let the video completes buffering then go to “” / tmp “” you will find the video there SIMPLE WAY
You don’t need it.
On your Linux(For Ubuntu) Go to Places–>File system–>tmp–>Video will be bottom(will have same file name as video)—>Finally just copy it from there/Paste it into desired location !!!!!!!
The youtube video will appear there after it has fully loaded onto the browser screen.
So all you really have to do is click on your favorite youtube video and then following the instructions above to get it.
Pingback: How Can I Save Movies From YouTube To My Hard Drive? | What is your SOLUTION? ZNS!
I wrote a bash script that might be useful to somebody, it extracts all of the flash video files out of your firefox cache that are above a certain size and copies them to a separate folder.
I run it after I’ve been on youtube for a while and it saves everything I’ve been watching:
#!/bin/bash
# flvcache script
CACHE=~/.mozilla/firefox/xxxxxxxx.default/Cache
OUTPUTDIR=~/Videos/flvs
MINFILESIZE=2M
for f in `find $CACHE -size +$MINFILESIZE`
do
a=$(file $f | cut -f2 -d ' ')
o=$(basename $f)
if [ "$a" = "Macromedia" ]
then
cp "$f" "$OUTPUTDIR/$o"
fi
done
nautilus "$OUTPUTDIR"&
It’ll also load the output folder in nautilus after so you can browse the flash/videos extracted.
Code and instructions on my blog:
http://desdecode.blogspot.com/2011/04/saving-watched-online-videos-linux.html
I hope somebody else finds it useful
There’s a new script for linux to search and watch youtube’s video on linux shell, called YouShell.
http://code.google.com/p/youshell/
The easiest way to play a video is something like,
vlc $(stat -c %N /proc/*/fd/* 2>&1|awk -F[\`\'] ‘/lash/{print$2}’)
To copy it just change that to,
cp $(stat -c %N /proc/*/fd/* 2>&1|awk -F[\`\'] ‘/lash/{print$2}’) desiredvideofilename.flv
Thanks for this solution! Simple, fast, all we need
Thanks! youtube-dl is better choice for me.
I’ve tried the third online method, also installed the python but it keeps telling me that format is not available for video and i can’t tell were i was wrong…..
Where does the youtube-dl script save the flv file? I did a file search that came up empty.
works like a charm(opensuse).thank you..
thank you, your post helped a lot.
well if you watch entire video and don`t rush for multiple downloads, entire video will be stored in .cache, goto your file browser click Ctrl-H to show hidden files, goto .cache, then browser cache, i take them that way, even nice key frames pics…other way is ls -a to show hidden files in console e.g path would be /home/irena/.cache/google-chrome/Default
That was helpful thank you
Just try clive, on command line, you put clive thewebsite.html and you’ll end up with a flv file in your home folder
ikinetica, when you posted this was still valid (mid-April 2012). HOWEVER, YT seem to have changed something again. I’ve spotted a new parameter called “range” in the o-o-preferred… URLs which suspiciously looks like data chunks (e.g. &range=1787641-4563124), so it appears to me videos can no longer be downloaded as a whole file but in chunks which have to be pieced together later. I know what I’m writing, since I’ve encountered this issue on both Firefox and Chromium. Back in April/May, mplayer would still have played the audio, now there is total silence. And it’s a pseudo-video, i. e. a mp3 with a static picture, which was uploaded in 192 kbps and got a duration of 3:30 mins, so the size should be between 5 MB and 5.5 MB. This totally matches with the last range value in the last chunk (…-5431983) so it seems we now have to say goodbye to leeching the whole file in one go.
me again…I can confirm that as of July 2012 when I write this Richard’s marvelous script “youtube-dl” can still copy with the “hacking-to-bits” method that YT currently uses and will DL the whole thing in one go.
Muchas gracias Ricardo !!
BUT: the grab-off-cache method seems to have become a thing of the past now.
The script / VLC combination works perfectly for me. Thanks!!
Pingback: Download Video Youtube Menggunakan Terminal Console di Backtrack 5 r3 | Blogs Share Apa Adanya
Theres a very simple application called minitube, installable from software center. Nice application which allows you to download any video from youtube, thoug it cannot work as a ressource sniffer like that firefox plugin mentioned before.