Download YouTube Videos : The Linux Way !

Posted on Mon 29 January 2007 in Life • 2 min read

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

1. Online Tools

There are some sites like []( 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 <span style="font-weight:bold;">flv</span> file.

  1. Firefox Plugin

    There is a firefox extensionwhich allows you to download YouTube videos as you watch them. I haven’t tried this.

  2. Command Line Tools

    This is the safest and best way (for CLI junkies :-D). Download the script YouTube-dl (thanks to Ricardo Garcia Gonzalez for this nice script). Just put that script in your ~/bin or /usr/bin directories or somewhere in the application path.

    To download the flv video do this :


    e.g : youtube-dl

B. Playing the video

1. Use VLC Player or MPlayer or Kaffeine to play the flash video. 2. If the above method doesn’t work out (It din’t in my case)..Then go the difficult way :

-   Get <span style="font-weight:bold;">ffmpeg</span> for your
    system. SuSE users can get it
-   Convert the <span style="font-weight:bold;">flv</span> video to
    <span style="font-weight:bold;">avi</span> (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 :-D) 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 cmdlopts.simulate:

284     condprint(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


if [ \$# -ne 2 ]


echo “Usage : \$0 \ \extension>”

echo “e.g : \$0 stevejobs”



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


Done. Now paste that code into a file utube in your path. Then run utube as :

utube steve_jobs

This will give 2 files stevejobs.flv and stevejobs.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,