How to Install Youtube-DL on Windows

Jul 17, 2019

Youtube-DL is a great little program that allows you to download videos from almost every major video website on the internet. This tutorial will show you how to download, install, configure and use Youtube-DL for Windows.

Prerequisites:

Download and Installation

Installing Youtube-DL

We'll start off with download and installing Youtube-DL. Go to the releases page of the Youtube-DL Github repository. Scroll down until you find the list of assets, click on the file called "youtube-dl.exe" to begin downloading Youtube-DL. You can download the file to any location except for System32. I recommend creating a separate folder solely for Youtube-DL as it makes it easier to configure Youtube-DL later on. For this tutorial, I have downloaded the file to D:\Programs\Other Programs\Youtube-DL.

Now that you've downloaded Youtube-DL, you've probably noticed that nothing happens when you try to double-click to run the program. This is because Youtube-DL is a command-line program, it can only be used from a command line interface such as Command Prompt.

However, if you open Command Prompt and try to use the command youtube-dl you'll still get an error saying that the command is not recognised. To run Youtube-DL you'll need to either add it to your computer's PATH or cd into the directory where you downloaded Youtube-DL.

Adding Youtube-DL to you PATH allows you to run the youtube-dl command from any command-line interface such as Command Prompt or PowerShell without needing to first cd into the directory where you installed Youtube-DL.

To add Youtube-DL to your PATH:

1. Copy the full path of your Youtube-DL install location - You can reveal the full path by navigating to wherever you downloaded Youtube-DL in Windows Explorer, clicking on the address bar and copying the text. Do not include the .exe in the path, it should only include directories (e.g. D:\Programs\Other Programs\Youtube-DL instead of D:\Programs\Other Programs\Youtube-DL\youtube-dl.exe)

A screenshot of Windows Explorer showing the current path in the address bar

2. Open Environment Variables - Open the System Properties menu by pressing Win+R and typing systempropertiesadvanced. From this menu, press the button labelled "Environment Variables...".

3. Select the Path variable - You can add Youtube-DL to either the user or system PATH. Adding it to the system PATH will allow any user to run the youtube-dl command without first cding into the install directory, whereas the user PATH will only apply to the currently logged in user. Note that setting it in the system PATH requires administrator permissions and youtube-dl.exe cannot be located in a user specific location (such as the Desktop or "My Documents"). For this tutorial, I will be using the system PATH.

If you want to add it to the user PATH, scroll through the first list of variables until you find one named Path. Double-click on it to open the editor.
If you want to add it to the system PATH, scroll through the second list of variables until you find one named Path. Double-click on it to open the editor.

There will most likely already be some stuff already in the Path. Do not delete any existing entries. They were most likely set by another program or by Windows and deleting them can cause programs not to work and can even cause Windows to become unbootable.

List of user and system variables on the left and the editor for the system PATH on the right

4. Add the Youtube-DL install path to Path - With the variable editor open and your Youtube-DL install path in the clipboard, press the "New" button from the right side of the editor. This will create a new entry to the bottom of the variable. Paste in your Youtube-DL path and press enter then press "OK" to save the changes.

5. Test it! - Now that you've added Youtube-DL to the PATH you should be able to open a new Command Prompt window and run youtube-dl. Now you can go to the section "Installing FFmpeg" to continue the installation!

If you're still getting an error saying that youtube-dl is not recognised, try the following:

  • Restart your computer to force a refresh of the PATH.
  • Double check that the path to Youtube-DL is correct. Make sure that youtube-dl.exe is not included in the path.
  • If you added Youtube-DL to the system PATH, try adding it to the user PATH (and vice versa).
  • From the PATH editor, select the Youtube-DL entry and try moving it up or down the list of PATH entries using the "Move Up" and "Move Down" buttons.

And if you still can't get it it work, leave a comment at the bottom of this article to see if someone can help you.

Run Youtube-DL from the Install Directory

If you only want to run Youtube-DL occasionally and don't want it cluttering your PATH, you can instead run it directly from the install folder. Open Windows Explorer and navigate to the folder you downloaded Youtube-DL to. Click on the address bar in Windows Explorer and type cmd to open Command Prompt in the current folder. Now you can simply use youtube-dl to run the program.

Installing FFmpeg

While FFmpeg isn't required, it gives you access to more features of Youtube-DL. Most notably, it allows you to download Youtube videos higher than 720p and allows you to combine a specific audio and video track together as one file.

Installing FFmpeg is pretty much the same as Youtube-DL. You can download Windows binaries for FFmpeg from FFmpeg maintainer Gyan Doshi's website — download the "git-full" binary if you're not sure what build to pick. This will begin downloading a 7z file containing the latest FFmpeg build (you will need 7-Zip to extract the file). Open the archive and extract the contents of the ffmpeg-20xx-xx-xx folder to a location of your choosing. For this tutorial, I have extracted it to D:\Programs\Other Programs\ffmpeg.

With FFmpeg extracted, you'll now need to add it to your PATH. The steps are the same as with Youtube-DL. However, instead of copying the base FFmpeg install path, copy the path from the bin folder (e.g. D:\Programs\Other Programs\ffmpeg\bin instead of D:\Programs\Other Programs\ffmpeg\).

Note that the path for FFmpeg includes the "bin" folder

You can verify that FFmpeg is set in the path by opening Command Prompt and run ffmpeg.

Configuring Youtube-DL

Now that you've successfully installed Youtube-DL, you'll probably want to customise it to your liking using some of the hundreds of options available. But typing out the same options every time you run Youtube-DL is tedious. This is where the configuration file comes in. The options set in the configuration file are run every time Youtube-DL is run. However, the config can be disabled at runtime using the --ignore-config flag. Options set at runtime will also have precedence over those set in the config.

Creating a config file is very straightforward. For Windows, simply create a file called config.txt at %APPDATA%\youtube-dl\. You set options in the config much like how you set them at runtime. You can comment out lines using the hash symbol (#).

I recommend using the following config as a starting point:

# Set date at current date instead of video's original date
--no-mtime

# Save to current user's videos folder using video title
# See https://github.com/ytdl-org/youtube-dl#output-template for all naming options
-o "%USERPROFILE%\Videos\Youtube\%(title)s.%(ext)s"

See the Youtube-DL list of options and list of output options for configuring Youtube-DL.

Using Youtube-DL

So you've finally installed and configured Youtube-DL to your liking, you're probably wondering how you use it. This section gives some examples and tips on how to download videos using Youtube-DL.

Basic Usage

The easiest way to download a video is by calling youtube-dl followed by the video URL.

youtube-dl https://www.youtube.com/watch?v=tO01J-M3g0U

This will download the requested video using the highest available quality. If FFmpeg is installed, it will download the highest quality video and highest quality audio separately and combine them into a single file. Otherwise, it will instead try to download the highest quality file that contains both video and audio.

Format Selector

But what if you want to download the video at a specific quality? Or what if you want to only download audio? This is where the format selector comes in.

You can list all the available formats for a video by using the -F flag (note the uppercase F) or --list-formats.

youtube-dl https://www.youtube.com/watch?v=tO01J-M3g0U -F

[youtube] tO01J-M3g0U: Downloading webpage
[youtube] tO01J-M3g0U: Downloading video info webpage
[info] Available formats for tO01J-M3g0U:
format code  extension  resolution note
249          webm       audio only tiny   56k , opus @ 50k (48000Hz), 918.04KiB
250          webm       audio only tiny   71k , opus @ 70k (48000Hz), 1.19MiB
140          m4a        audio only tiny  130k , m4a_dash container, mp4a.40.2@128k (44100Hz), 2.39MiB
251          webm       audio only tiny  140k , opus @160k (48000Hz), 2.37MiB
394          mp4        256x144    144p   79k , av01.0.00M.10.0.110.09.16.09.0, 30fps, video only, 1.24MiB
278          webm       256x144    144p   97k , webm container, vp9, 30fps, video only, 1.59MiB
160          mp4        256x144    144p  111k , avc1.4d400c, 30fps, video only, 1.20MiB
395          mp4        426x240    240p  182k , av01.0.00M.10.0.110.09.16.09.0, 30fps, video only, 2.27MiB
242          webm       426x240    240p  227k , vp9, 30fps, video only, 3.20MiB
133          mp4        426x240    240p  245k , avc1.4d4015, 30fps, video only, 2.45MiB
330          webm       256x144    144p60 HDR  250k , vp9.2, 60fps, video only, 3.69MiB
396          mp4        640x360    360p  336k , av01.0.01M.10.0.110.09.16.09.0, 30fps, video only, 4.26MiB
243          webm       640x360    360p  420k , vp9, 30fps, video only, 5.97MiB
331          webm       426x240    240p60 HDR  517k , vp9.2, 60fps, video only, 7.98MiB
397          mp4        854x480    480p  623k , av01.0.04M.10.0.110.09.16.09.0, 30fps, video only, 7.92MiB
134          mp4        640x360    360p  634k , avc1.4d401e, 30fps, video only, 6.97MiB
244          webm       854x480    480p  773k , vp9, 30fps, video only, 10.86MiB
332          webm       640x360    360p60 HDR 1094k , vp9.2, 60fps, video only, 17.37MiB
398          mp4        1280x720   720p60 1249k , av01.0.08M.10.0.110.09.16.09.0, 60fps, video only, 17.83MiB
135          mp4        854x480    480p 1297k , avc1.4d401f, 30fps, video only, 14.05MiB
247          webm       1280x720   720p 1545k , vp9, 30fps, video only, 22.19MiB
333          webm       854x480    480p60 HDR 2034k , vp9.2, 60fps, video only, 33.47MiB
136          mp4        1280x720   720p 2657k , avc1.4d401f, 30fps, video only, 27.20MiB
248          webm       1920x1080  1080p 2702k , vp9, 30fps, video only, 39.80MiB
302          webm       1280x720   720p60 2710k , vp9, 60fps, video only, 36.54MiB
298          mp4        1280x720   720p60 4071k , avc1.4d4020, 60fps, video only, 45.17MiB
303          webm       1920x1080  1080p60 4622k , vp9, 60fps, video only, 63.87MiB
334          webm       1280x720   720p60 HDR 4790k , vp9.2, 60fps, video only, 80.74MiB
137          mp4        1920x1080  1080p 4985k , avc1.640028, 30fps, video only, 49.39MiB
299          mp4        1920x1080  1080p60 6761k , avc1.64002a, 60fps, video only, 80.25MiB
335          webm       1920x1080  1080p60 HDR 7277k , vp9.2, 60fps, video only, 123.60MiB
271          webm       2560x1440  1440p 8874k , vp9, 30fps, video only, 119.07MiB
308          webm       2560x1440  1440p60 13422k , vp9, 60fps, video only, 181.85MiB
336          webm       2560x1440  1440p60 HDR 16900k , vp9.2, 60fps, video only, 297.56MiB
313          webm       3840x2160  2160p 18006k , vp9, 30fps, video only, 287.61MiB
315          webm       3840x2160  2160p60 26847k , vp9, 60fps, video only, 436.24MiB
337          webm       3840x2160  2160p60 HDR 29609k , vp9.2, 60fps, video only, 528.73MiB
43           webm       640x360    360p , vp8.0, vorbis@128k, 15.53MiB
18           mp4        640x360    360p  609k , avc1.42001E, mp4a.40.2@ 96k (44100Hz), 11.23MiB
22           mp4        1280x720   720p 1605k , avc1.64001F, mp4a.40.2@192k (44100Hz) (best)

Youtube-DL returns a lot of information but once you break it down it becomes a lot more manageable. The information is returned in a table format with seven columns and one format per row. Audio-only formats comes first, followed by video-only formats with the audio+video formats at the bottom. Formats are listed in ascending order by bitrate. The columns of the table are broken down as follows:

  • Format code - The code used when downloading a format
  • Extension - The extension of the downloaded format
  • Resolution - The resolution, framerate and additional information such as HDR
  • Bitrate - The bitrate of the format expressed in kilobits/second
  • Codec - Codec information, format framerate and whether the format is video/audio only
  • Size - The size of the format
Format Code Extension Resolution Bitrate Codec Size
337 webm 3840x2160 2160p60 HDR 29609k vp9.2, 60fps, video only 528.73MiB

To download specific specific formats of a video, use the -f (note the lowercase f) or --format flag. You can specify video only, audio only, or video + audio formats. Formats are selected using the format codes returned using the --list-formats flag.

youtube-dl https://www.youtube.com/watch?v=tO01J-M3g0U -f 299+251

[youtube] tO01J-M3g0U: Downloading webpage
[youtube] tO01J-M3g0U: Downloading video info webpage
WARNING: Requested formats are incompatible for merge and will be merged into mkv.
[download] Destination: C:\Users\Dan\Videos\Youtube\The World in HDR in 4K (ULTRA HD).f299.mp4
[download] 100% of 80.89MiB in 00:28
[download] Destination: C:\Users\Dan\Videos\The World in HDR in 4K (ULTRA HD).f251.webm
[download] 100% of 2.37MiB in 00:01
[ffmpeg] Merging formats into "C:\Users\Dan\Videos\Youtube\The World in HDR in 4K (ULTRA HD).mkv"
Deleting original file C:\Users\Dan\Videos\Youtube\The World in HDR in 4K (ULTRA HD).f299.mp4 (pass -k to keep)
Deleting original file C:\Users\Dan\Videos\Youtube\The World in HDR in 4K (ULTRA HD).f251.webm (pass -k to keep)

The above example will download the formats that match the codes 299 and 251. This corresponds to the 1080p 60FPS video and 140kb/s Opus audio stream. Those files are then combined into a single MKV using FFmpeg.

Downloading audio or video only follows the same process. Just specify the audio or video format.

youtube-dl https://www.youtube.com/watch?v=tO01J-M3g0U -f 299

Only download video (format code 299)

youtube-dl https://www.youtube.com/watch?v=tO01J-M3g0U -f 251

Only download audio (format code 251)

Youtube-DL also has some preset formats to download the best or worst audio/video available. These can be used in place of an exact format code.

  • best - Downloads the highest quality file containing both audio and video
  • worst - Downloads the lowest quality file containing both audio and video
  • bestvideo - Downloads the highest quality video-only file
  • worstvideo - Downloads the lowest quality video-only file
  • bestaudio - Downloads the highest quality audio-only file
  • worstaudio - Downloads the lowest quality audio-only file

Conclusion

Youtube-DL is an incredible program that allows you to download media from hundreds of websites. While I hope this tutorial has got you up and running with using Youtube-DL, I highly recommend checking out the README for Youtube-DL that contains much more detailed information on the available options for using and configuring Youtube-DL.

Changelog

  • 2021-01-23: updated FFmpeg download link (thanks ElectroGaming)