July 25, 2008 · General · Email This Post
Share
{lang: 'en-GB'}

youtube-dl is a small command-line program to download videos from YouTube.com.

Install youtube-dl in Ubuntu

sudo aptitude install youtube-dl

This will complete the installation.

Using youtube-dl

Usage instructions are easy. Use youtube-dl followed by a video URL or identifier.

youtube-dl Example

youtube-dl “http://www.youtube.com/watch?v=foobar”

The video will be saved to the file foobar.flv in that example. As YouTube.com videos are in Flash Video format, their extension should be flv.Check this simple guide to convert .flv files to .mpg

More usage tips

You can change the file name of the video using the -o option, like in

youtube-dl -o vid.flv “http://www.youtube.com/watch?v=foobar”.

Some videos require an account to be downloaded, mostly because they’re flagged as mature content. You can pass the program a username and password for a YouTube.com account with the -u and -p options, like

youtube-dl -u myusername -p mypassword “http://www.youtube.com/watch?v=foobar”.

The account data can also be read from the user .netrc file by indicating the -n or --netrc option. The machine name is youtube in that case.

The simulate mode (activated with -s or --simulate) can be used to just get the real video URL and use it with a download manager if you prefer that option.

The quiet mode (activated with -q or --quiet) can be used to supress all output messages. This allows, in systems featuring /dev/stdout and other similar special files, outputting the video data to standard output in order to pipe it to another program without interferences.

The program can be told to simply print the final video URL to standard output using the -g or --get-url option.

Share

Related posts

133 Comments to “Youtube-dl - Download videos from youtube in Ubuntu”

  1. mal says:

    ok that was a bit wrong :D

    javascript:window.location.href = ‘http://youtube.com/get_video?video_id=‘ + swfArgs['video_id'] + ‘&t=’ + swfArgs['t'];

    [Reply]

  2. Erik says:

    Its just as easy to keep an older versiion of opera on the PC and once the movie is finished caching just copy it out of your opera cache folder. Default: hidden in the home directory.
    ;o)

    [Reply]

  3. mal says:

    hm i forgot that wordpress likes to screw this things up:
    hope it works this time ^^

    javascript:window.location.href = 'http://youtube.com/get_video?video_id=' + swfArgs['video_id'] + '&t=' + swfArgs['t'];

    [Reply]

  4. mal says:

    An even more simpler way (just using the browser): ;)

    just type or copy in the brwoser location bar:

    javascript:window.location.href = ‘http://youtube.com/get_video?video_id=’ + swfArgs['video_id'] + ‘&t=’ + swfArgs['t'];

    [Reply]

  5. Murtadh says:

    thanks but what about “pytube”?! it’s easier and GUI-based application, and no codes are needed to be used by the user :)

    [Reply]

  6. Shaun lee says:

    And then there is also this DownloadHelper extension for Firefox 3.0 users that can handle almost any kind of videos…

    [Reply]

  7. udey says:

    Keepvid is the best !

    [Reply]

  8. xhu says:

    i have installed youtube-dl on my ubuntu,,,but the program can’t start,,by clicking /usr/bin/youtube-dl, ’cause no youtube-dl on the menu.
    how can i resolve the problem?
    thanks…

    [Reply]

  9. fazil says:

    how to get and install Youtube-dl ?

    [Reply]

  10. admin says:

    @fazil

    check the article and clearly says how to install from ubuntu repositories

    [Reply]

  11. fazil says:

    hi … this code is not correct for downloading …

    javascript:window.location.href = ‘http://youtube.com/get_video?video_id=’ + swfArgs['video_id'] + ‘&t=’ + swfArgs['t'];

    can u give me the right one …

    [Reply]

  12. somebody says:

    It is not very clear what the format of .netrc file is. There is no sample, man page or anything mentioned on their homepage. It just says you can put the account information in it and nothing else.

    [Reply]

  13. nick says:

    Suggest some GUI tool….

    [Reply]

  14. Doesn't work says:

    The repositories version is out of date and doesn’t work.

    I am new to Ubuntu, and do not understand half the directions given on the Youtube-dl site and wish an up-to-date repository was available…

    Oh well, I guess I’ll find another piece of software.

    [Reply]

  15. Wackhead says:

    Where does it save the flv file?

    I got is working fine on 10.04
    install:
    sudo apt-get install youtube-dl

    and then copy and pasted the http link from firefox into the terminal behind the youtube-dl command

    thx

    [Reply]

  16. Saji.N says:

    I use no tools at all. Ubuntu(and most other linux OS) always has the videos being buffered, at the /tmp directory. After the full video is buffered, you just need to copy it from there. Mind you- Ypu won’t find and extension such as “*.flv” for the file. If you want to use the file in Windows, just add the “.flv” to the file, and you’re on. :)

    [Reply]

  17. naitech says:

    As of 21st July 2010 youtube downloads just don’t work. Anyone noticed the same.

    [Reply]

  18. Saji.N says:

    I’m still able to get the youtube videos, from the /tmp directory, after fully buffering it.

    [Reply]

  19. @ngel says:

    hi,
    although i installed properly youtube-dl on my ubuntu, it remains not working with this answer “ERROR: format not available for video”. What could be the problem here?
    thx

    [Reply]

  20. ashw says:

    The Downloadhelper addon for Firefox is also broken for Youtube.

    [Reply]

  21. Brent Carter says:

    My scripts that use youtube-dl and CClive have not been working as of mid July. Did youtube change something???

    [Reply]

  22. Tony says:

    It’s such a lot of messing around when all you need is one of the Firefox plugins. One click and save,..done!

    [Reply]

  23. Tony says:

    Just forget about Opera and it’s convoluted methods and install Firefox which has a beaut plugin named:”Download Helper” it’s listed under their “Add ons”. Go to the Tools> Add ons > get “add ons”then either do a search for “video download” which will give you a choice of several plugins or just browse and you’ll find a ton of useful plugins.
    If only Opera could introduce a similar setup and save us all this copying and pasting etc etc,..I’ve given up, back to Firefox! I’m not that much in love with the “terminal”.
    Cheers

    [Reply]

  24. Satish says:

    @Saji.N,
    have been using Ubuntu for a year now and was not even aware of this…Gr8 trick dear.

    [Reply]

  25. DBS says:

    @Saji.N - /tmp option works great (unless I close the chromium-browser before copying the video :) )
    KeepVid.com is also great. I think that these two options are enough (/tmp more “geeky” and KeepVid.com could be used everywhere).

    [Reply]

  26. Mike says:

    The /tmp approach can be done on any OS and technically on any browser though I have been doing it only only Google Chrome.

    What I do is:
    1. View the video so it’s fully buffered
    2. Go to the cache folder
    3. Sort it by date
    4. Locate the latest large file
    5. Copy that file to another folder
    6. Append .flv to it

    :)

    [Reply]

  27. Brent Carter says:

    @Mike. That is what I am for myself and it is fine but when the kids have 15 or 20 I’d like to not watch them just hand the list to my scripts and be done. LOL

    Any way to have a script look for a trigger in the /tmp folder and then catch it?

    [Reply]

  28. Tyler Jordan says:

    I usually just pull the video out of the /tmp folder. Works for both chrome and opera, but not mozilla dirivatives, including firefox - have no idea where firefox puts these files. . .anyone anyone? Also, just been testing out the new HTML5/WebM format vids and opera (at least) isn’t putting these vids into the /tmp folder!!! what’s up with that? A new trend? Concerned. What’s going on?

    [Reply]

  29. mparry73 says:

    I cant get keepvid.com to work it used to work for me. it says i need java update so i got the linux jre1.6.0_22 version and i use firefox 3.6.10 i followed the directions on how to install it at the
    http://www.java.com/en/download/help/linux_install.xml#enable

    but it doesnt work. is there another way to get java working. the firefox addon thing finds an older version i got to install it then when firefox restarts it asks me to uninstall it well it doesnt ask me it does it on its on. any ideas that would be helpful ? thanks

    [Reply]

  30. Dimon says:

    Doesn’t work. Same story with clive

    [Reply]

Leave a Reply