Posted by: arun on: January 29, 2007
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
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.
~/bin or /usr/bin directories or somewhere in the application path.youtube-dl
e.g : youtube-dl http://www.youtube.com/watch?v=D1R-jKKp3NAB. Playing the video
ffmpeg -i my_flash_video.flv the_avi_file.aviStill 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,
[...] [Trovato qui] [...]
[...] hier [...]
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 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.
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
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!
[...] a comment » I had posted long back about a bash wrapper over youtube-dl to fetch youtube videos using your own download [...]
[...] 4: Enjoy. Note that I did all of this on my Windows laptop, but naturally there is a Linux way. Also, I chose MPEG1 because it was the best quality of video and audio for me, but that might be [...]
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/
February 25, 2007 at 11:50 am
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.