mckinley.cc Home Blog Computers

A very brief beginner's guide to youtube-dl

May 15th, 2020

Youtube-dl is one of my favorite tools available. It lets you download videos from over 1000 websites. If you want to download a video from somewhere, youtube-dl has you covered. The only problem is that it has a very daunting set of flags and options to use to make the program do different things. For the average (windows) user who just wants to download a YouTube video, it seems like a waste of time to read through all that. It isn't, but if you only plan to use this program once, here is a very basic guide on how to download something

Installing youtube-dl

Instructions to download it are here. If you are on GNU/Linux, try installing the youtube-dl package from your distro's standard package manager. If there is no youtube-dl package, follow. the distro-agnostic instructions on that page. Windows users will need to install the Visual C++ Redistributable package linked on that page, everyone else will need to download one of the supported Python versions on that page.

Running youtube-dl

Youtube-dl is a command line program. That means you need to use Command Prompt on windows, or a terminal emulator of your choice on other platforms. Open your terminal, and navigate to the folder you downloaded youtube-dl to

-f and -F

These are the most important options in youtube-dl. Referring to the documentation, here is the description for these options

-f, --format FORMAT Video format code, see the "FORMAT SELECTION" for all the info
-F, --list-formats List all available formats of requested videos

Go ahead and run youtube-dl -F [link] and take a look at the output. You should see a list of available formats. Choose the desired video and audio quality, and run the command again, this time with the f flag and a format like this:

youtube-dl -f [video-code]+[audio-code] [link]

youtube-dl -f 299+140 https://www.youtube.com/watch?v=pjzQHf_VlbY

You can also just use bestvideo and bestaudio to automatically use the highest quality video and audio possible. Example:

youtube-dl -f bestvideo+bestaudio https://www.youtube.com/watch?v=pjzQHf_VlbY

Downloading FFmpeg

This may not work if you don't have ffmpeg installed. Download it here, or use your preferred package manager. On Windows, there are builds available here. Scroll down the page to the "Release" section and click on the link https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip. (or ffmpeg-release-essentials.7z if you have 7-zip installed) The file you're looking for is ffmpeg-YYYY.../bin/ffmpeg.exe when you open the downloaded archive. Copy that file to the same folder youtube-dl.exe is in, and try the command again.

Conclusion

Congratulations, you've just downloaded a video with youtube-dl. There is much more to this program, and I strongly recommend reading the full documentation if you intend on using this tool more. I hope this short guide did help you, though. Happy downloading!

Update 2021-01-30: Added install instructions for GNU/Linux, added "bestvideo+bestaudio" example, changed video used in examples, update link and instructions for FFmpeg on Windows, change link for documentation to jump to #description