Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've been using it for years now and it's great. Not only for Youtube videos, but also for a lot of other video hosters, up to and including TV stations such as the German ZDF or the French Arte.

To fully use its features you should install ffmpeg though. Youtube-dl will automatically use it if it's in the PATH, and then can download Youtube videos with higher frame rates and resolutions (they store video and audio in separate files, and ffmpeg is used to mux both together). ffmpeg is also required to download from some streaming video hosters.

For me it's essentially:

  youtube-dl -F '<url>'
to get the list of available video and audio formats, followed by

  youtube-dl -f <video format>+<audio format> '<url>'
and then wait for the download to complete. And

  youtube-dl -U
to self-update youtube-dl (because it gets updated just about every day).


-f also supports some symbolic names, which is very handy because it allows you to easily get the best possible quality without having to check the formats every time:

    -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]'
this is what I'm using in my case (on youtube).

Posting this here, because it's not obvious from the docs that this works.


FWIW

> Since the end of April 2015 and version 2015.04.26 youtube-dl uses -f bestvideo+bestaudio/best as default format selection […] If ffmpeg or avconv are installed this results in downloading bestvideo and bestaudio separately and muxing them together into a single file giving the best overall quality available. Otherwise it falls back to best and results in downloading the best available quality served as a single file. best is also needed for videos that don't come from YouTube because they don't provide the audio and video in two different files.


bestvideo+bestaudio has been flip-flopping ver time and releases between mp4 and webm though. As I'm mostly using this for consumption on an iPad, I prefer mp4, so I'm happy to have found a way to get the best possible mp4 version without having to go format hunting.


I'm pretty sure the '-f best' setting is the default for updated versions of ytdl, so no real need for that.


Unless you always want to download the best mp4, not webm (or vice versa).


> Not only for Youtube videos, but also for a lot of other video hosters

Oh ye, the list's pretty comprehensive actually [1].

[1]: https://github.com/rg3/youtube-dl/tree/master/youtube_dl/ext...


$ youtube-dl -U It looks like you installed youtube-dl with a package manager, pip, setup.py or a tarball. Please use that to update.

TIL: https://rg3.github.io/youtube-dl/download.html


you can also do youtube-dl -f bestvideo+bestaudio '<url>' to skip a step, since 90% of the time that's what I want anyways.


That's been the default since April 2015,so `youtube-dl url...` is sufficient to get either the best single-file video (if no ffmpeg installed or non-youtube video) or to get both the best video and the best audio remuxed.


I like this command to extract audio from youtube videos:

    youtube-dl --extract-audio --audio-format mp3 <url>


If your music player supports OGG, you can also use youtube-dl -f FORMAT VIDEO_URL and give a numeric format that corresponds to a DASH webm audio-only stream, with vorbis audio (e.g. format 171 these days). The container is webm but it can be trivially changed to OGG with ffmpeg, which you can call via --exec automatically.

Edit: I mentioned that because you don't lose any quality reencoding.


That's my main use of youtube-dl for years now. I'm extracting audio from old french movies available on youtube, work a small sound extract with audacity and then post the result on soudcloud[1].

[1] A bit of self-promotion here, if you are interested this is my soundcloud playlist https://soundcloud.com/melicerte/sets/extraits-de-vieux-film...


That is a really cool playlist.


Why?


Why not!


I'm not against it or anything, I'm just wondering if it is a personal interest or if there is some niche usage I am unaware of.


I like to keep it in original audio format (usually AAC) instead of mp3, because with mp3 conversion, there is also some loss of quality due to re-compression.


Or you could use -x, which would only download the audio (because there's seperate audio and video streams on youtube).


yes -x is the same as --extract-audio, but I use an alias in my bashrc like this (if you don't use --audio-format mp3, you might not get mp3 (not necessarily a bad thing)):

    alias youtubemp3='youtube-dl --extract-audio --audio-format mp3'




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: