Youtube-dl is a popular commandline utility to download content from YouTube (among many other sites).
Open a termianl and type:
brew install youtube-dl ffmpeg
youtube-dl https://www.youtube.com/watch?v=d9_s8Bk_qcI
You can paste multiple video urls into the command and the utility will download them in order:
youtube-dl <url1> <url2>...
You can also create a text file (e.g. urls.txt
) in the same directory and pass that with the -a
flag:
youtube-dl -a urls.txt
By default, audio extraction is done in ogg
format. To get an mp3
, pass the --audio-format
flag:
youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=dQw4w9WgXcQ
youtube-dl -x --audio-format mp3 -a urls.txt
youtube-dl --write-description --write-info-json --write-annotations --write-sub --write-thumbnail https://www.youtube.com/watch?v=d9_s8Bk_qcI
youtube-dl --list-formats https://www.youtube.com/watch?v=d9_s8Bk_qcI
youtube-dl -F https://www.youtube.com/watch?v=d9_s8Bk_qcI
y default, Youtube-dl will download the best available quality video. However, it is also possible to download a video or playlist at a specific quality or format.
YouTube is capable of downloading videos in the following qualities:
- best - Select the best quality format of the given file with video and audio.
- worst - Select the worst quality format (both video and audio).
- bestvideo - Select the best quality video-only format (e.g. DASH video). Please note that it may not be available.
- worstvideo - Select the worst quality video-only format. May not be available.
- bestaudio - Select the best quality audio only-format. May not be available.
- worstaudio - Select the worst quality audio only-format. May not be available.
For example, if you want to download best quality format (both audio and video), just use the following command:
youtube-dl -f best https://www.youtube.com/watch?v=d9_s8Bk_qcI
Similarly, to download audio-only with best quality:
youtube-dl -f bestaudio https://www.youtube.com/watch?v=d9_s8Bk_qcI
You also combine different format options like below.
youtube-dl -f bestvideo+bestaudio https://www.youtube.com/watch?v=d9_s8Bk_qcI
youtube-dl --format mp4 https://www.youtube.com/watch?v=d9_s8Bk_qcI
If you want to download with custom filenames:
youtube-dl -f mp4 -o '%(title)s.f%(format_id)s.%(ext)s' https://www.youtube.com/watch?v=d9_s8Bk_qcI
youtube-dl --min-filesize 100M <playlist_url>