in

Download YouTube Videos from the Linux Terminal

- - 14 comments
It's always comforting to know that I can do a lot of important things inside the Linux terminal. Even those stuff that I normally do using a GUI like posting Twitter updates, downloading torrent files and Instant Messaging (IM).

Today, let me show you how I was able to download a YouTube video from the Linux terminal. It's really very easy so you may want to try it immediately after the following instructions:


1. Using Ubuntu Linux, I downloaded the package youtube-dl with this command:

$ sudo apt-get install youtube-dl

2. After having successfully installed youtube-dl, open a web browser and go to youtube.com to pick a video that you would like to download.

3. Copy the page URL/address of the Youtube video.

4. Go back to the Linux terminal and simply type: youtube-dl + URL/Address of the video

For example, I downloaded the current number one YouTube video clip of all time with this command:

$ youtube-dl http://www.youtube.com/watch?v=_OBlgSz8sSM

You can add the -b option to download the video in high quality, e.g.

$ youtube-dl -b http://www.youtube.com/watch?v=_OBlgSz8sSM

5. The downloaded video will be saved at /home/username by default. It will be in .flv format so be sure to have flash plugin installed before viewing the video.

That's about it. Enjoy!

14 comments

  1. I didn't know that this handy python script is shipped as a package.

    @flash plugin - no, you don't need that. ffmpeg library and mediaplayers that use it can decode that just fine (I preffer mplayer)

    ReplyDelete
  2. I usually use firebug to fetch the video url or just look through the source code and use wget to grab the video. Interesting to know there's a package that does all that automatically.
    Like mmlosh said, you don't really need flash to play that. mplayer works fine. Or you could use ffmpeg to convert the vids to your favorite format.

    ReplyDelete
  3. Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Couldn't find package youtube-dl

    ReplyDelete
  4. Am I the only one who lets the video stream in the browser and then take the corresponding temporary file from the /tmp directory?

    ReplyDelete
  5. i use DownloadHelper plugin for Firefox, gives you choice of FLV, or various Mp4 files (different qualities)

    ReplyDelete
  6. AnonymousJune 29, 2010

    An alternative is 'clive' which, should you want it also has a GUI.

    http://clive.sourceforge.net/

    Also check repositories.

    ReplyDelete
  7. reply from terminal: Error couldn't download video format may be unavailable.
    :-(
    And that thing with the tmp-file seems like a troll. There is NEVER any video in there

    ReplyDelete
  8. downloaded videos are not playing...

    ReplyDelete
  9. it is wriiten there. the format maybe unavailable. What should I do?

    ReplyDelete
  10. hi after giving the first command it asked for password?

    ReplyDelete
  11. The command worked great in Mint as well

    ReplyDelete
  12. not working


    $youtube-dl -t -b http://www.youtube.com/watch?v=vMoKCJpPkn0&

    Extracting video title... done.
    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.

    ReplyDelete
  13. Not working for me either:

    $ youtube-dl http://www.youtube.com/watch?v=8yBYyWXUwUI
    [youtube] Setting language
    [youtube] 8yBYyWXUwUI: Downloading video webpage
    [youtube] 8yBYyWXUwUI: Downloading video info webpage
    [youtube] 8yBYyWXUwUI: Extracting video information

    ERROR: unable to download video

    ReplyDelete
  14. "ERROR: unable to download video webpage: HTTP Error 404: Not Found on ubuntu "
    How to solve this problem.

    ReplyDelete