Note: This guide is targeted towards computers running Windows 10
In this guide, you will both learn how to download Youtube videos, and develop a basic understanding of how to use command-line programs. They can be scary to use at first, but I hope by the end of this guide you can see how simple to use they can be after learning the basics.
For this guide, we will be using a piece of software named yt-dlp.
Direct download for the Windows version of yt-dlpyt-dlp is a piece of command-line software that can download video and audio from the internet. Its mainly used for downloading youtube videos, but also supports sites like niconico or bilibili. A full list of supported sites is available on github.
Optional: You can visit the github page of yt-dlp to download the program if the above download link doesn't work. On the github page, scroll down until you get to the table of contents of the README section, then click on the link labelled "installation." From there you can click on the button labeled "Windows x64" to download it
Create a new folder on your computer. It can live anywhere and be named anything, though a name without any spaces in it is preferrable. Copy the yt-dlp.exe
file into this new folder.
This folder will basically be used as "scratch space" for running yt-dlp and for storing the downloaded files. For that reason, we'll be calling this our scratch folder.
As an example, I'm going to show how to download this silly kitty youtube video :3
First, you'll want to open Windows Powershell in your new scratch folder. You can do this in one of two ways:
This should open a powershell window in the current folder. Powershell is a tool that you can use to run command-line programs. Command-line programs are run by typing their name, and then typing all the parameters you want to give to them.
A breakdown of what this command means:
./
is a series of characters that represents the inside of the current folder. In other words, it lets us target and run a .exe
file inside the current folder.yt-dlp.exe
is the name of the program. Because we wrote ./
before it, it targets the program inside the current folder. You can choose to omit the .exe
part, if you wish, as it is optional. Anything written after the name of the program will be given to it as a program parameter that it will use.https://youtu.be/XZ1klqk-WOE
is the only parameter we are giving to our program, which is the URL to which the video resides. This could be replaced with any URL!In short, to download a video, you should first type the identifier of the program, ./yt-dlp.exe
, and then after a space, paste in the URL of any youtube video.
Important: When pasting a URL, you'll want to make sure it's just the base minimum URL, with no extra data added on. For example, if a youtube URL is part of a playlist, then you'll end up downloading the whole playlist! In the case of youtube URLs, you'll want to remove first &
symbol and everything after it.
In addition to this playlist issue, Powershell doesn't like it when you have &
symbols in your command that aren't wrapped in quotes, and will give an error when this happens. In case you actually want to download an entire playlist, you'll have to wrap your URL in quotes to fix the error.
If you've been following along, you'll have downloaded a .webm
file into your scratch folder. (Assuming this is still the default at the time you're reading this.) But, oh no! What if we needed an .mp4
file instead of a .webm
?
To solve this issue, we'll need to use a flag. A flag is a parameter given to a program used to change specific options. In our case, we want the -f
flag, which stands for format. This flag takes one input, the name of the format, written with a space after the flag.
In other words, the format flag takes the form of -f FORMAT
, where FORMAT
is replaced with your desired file type. Flags can go anywhere after the program name, so it doesn't matter if it's before or after the URL.
There are many other flags that you may find useful when downloading videos. For a complete list, see the "Usage and Options" section on the yt-dlp github page.
For now, one of the most important flags to know is the -U
flag, which stands for update. Whenever a video download has a strange error, you should use it to make sure you have the most up-to-date version, as sites like youtube tend to enjoy messing with downloader programs.
In order to extract audio from a video, you will need a copy of ffmpeg, which is a program that yt-dlp uses to convert videos to different formats.
ffmpeg-master-latest-win64-gpl
folder, and then into the bin
folder.ffmpeg.exe
and ffprobe.exe
into the scratch folder you made earlier.At the end, your scratch folder should look something like this:
Now, yt-dlp will automatically use these programs for advanced functions, like audio handling. You can access features like this using new flags that you can add to your command. Here is a list of the ones relevant to extracting audio:
-x
stands for extract audio, and is the flag that marks that the program should save the audio and throw away the video. It has no parameters, so it doesn't require anything else to work. The resulting audio file's type will be the default audio codec for the video you have selected.--audio-format FORMAT
will change the type of file that the -x
flag outputs. FORMAT
should be replaced with the type of file you want.Downloading ffmpeg also unlocks a few other useful flags, such as --remux-video FORMAT
and --recode-video FORMAT
. You may check the github page for information on these as well.
ffmpeg is a complete video and audio handling program in its own right, and you may find it useful if you work heavily with either. Googling "convert video in ffmpeg" or "resize video in ffmpeg" or anything similar should yeild good results if you need something done fast. For more details, see the official ffmpeg wiki or the full documentation.
If you plan to use ffmpeg this way in conjuction with yt-dlp, you may also want to know that pressing Tab in Powershell will autocomplete any file you have started to type in.
When using command-line software, it can be annoying to have to open a specific folder just to use the program, especially if you're going to want to copy those files elsewhere afterwards. To fix this, we're going to take advantage of the Windows Path
variable to let us run yt-dlp anywhere on your computer.
First, you're going to want to create another new folder. It can be in any location and be named anything, but I'm going to use the example folder C:\MyPath
in this guide. You should copy all your .exe
files to it that you had in your previous scratch folder, and it should not contain anything else.
We're going to need to copy the exact file path of this new folder, and you can do that in one of two ways:
Now that you have the folder path copied, you'll have to find the place where you tell Windows that you want to use that folder as a special Path
Variable folder.
First, search for "environment variables" in your start menu. Click on the entry marked "Edit the system environment variables."
Then, click on the "Environment Variables" button on the bottom right.
In the window that pops up, find the variable named "Path" in either the User variables section or System variables section. It doesn't matter which one, the only difference is the "User variables" section will only affect your own account, and the "System variables" section will affect the account of everyone who uses your computer.
When you find the "Path" variable, select it and then click "Edit" in its corresponding box.
In this window, you should see a list of all file paths in your Path variable, assuming you have any. Click on the New button in the top right, and then paste in the folder path you copied earlier. Be sure to press enter after you paste the folder path, and then press OK in the bottom right. If you don't do both of these things, your changes will not be saved.
Now, after opening and closing Powershell, you will be able to use yt-dlp inside of any folder in your computer, and it will download the files in whatever folder you open Powershell in! You will have to slightly change your commands, though.
Keep in mind your newly created path folder should not be used to download any videos, as it is only supposed to contain runnable programs.
If you happen to download any other standalone command-line programs after reading this guide, placing them into your path folder (in my case C:\MyPath
) will allow them to run anywhere as well.