Back to main page

How to Download Youtube Videos :3

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.

Step 1: Acquiring software

For this guide, we will be using a piece of software named yt-dlp.

Direct download for the Windows version of yt-dlp

yt-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

Step 2: Setting up folders

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.

yt-dlp.exe file shown inside of a new folder

Step 3: How to download your video

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:


Option 1: With your new scratch folder open in file explorer, click the "File" button in the top left of the window, and then click "Open Windows Powershell"

Option 2: With your new scratch folder open in file explorer, hold Shift and then Right Click on an empty space inside the folder. Then, click on "Open Powershell window here." When you right click, your click must be on an empty space, and not a file.


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.

To download our video, we should copy and paste this command into Powershell, and then press enter:
./yt-dlp.exe https://youtu.be/XZ1klqk-WOE

A breakdown of what this command means:

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.

This command will give an error:
./yt-dlp https://www.youtube.com/watch?v=mWPNZ_agAZs&list=PLy22iKf8SNXg9YcbkS5dRtkz1Gd9Q_dqT&index=2
This command will download an entire playlist:
./yt-dlp "https://www.youtube.com/watch?v=mWPNZ_agAZs&list=PLy22iKf8SNXg9YcbkS5dRtkz1Gd9Q_dqT&index=2"
This command will download a single video:
./yt-dlp https://www.youtube.com/watch?v=mWPNZ_agAZs

Other video formats (and flags)

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.

Here is how we would download our .mp4 file:
./yt-dlp https://youtu.be/XZ1klqk-WOE -f mp4

However, in our modern internet ecosystem, selecting a format may not be so simple. Only certain formats are available, often in many different resolutions, and some formats splitting up audio and video, only to be zipped back together when it reaches the user. Fortunately, yt-dlp lets us look behind the curtain and see what exactly a website is serving us.

The -F flag (note the capital letter), also known as --list-formats, lets us look at what what formats are available in that given video URL. It doesn't take any inputs. This command stop the act of downloading the video, and instead shows us a chart of all the available formats. Here is an example of what an output might look like:
./yt-dlp https://youtu.be/XZ1klqk-WOE -F
[youtube] Extracting URL: https://youtu.be/XZ1klqk-WOE
...
[info] Available formats for XZ1klqk-WOE:
ID  EXT   RESOLUTION FPS    FILESIZE  TBR PROTO  VCODEC         VBR ACODEC
────────────────────────────────────────────────────────────────────────────────
sb0 mhtml 48x27       14                  mhtml  images                        
233 mp4   audio only                      m3u8   audio only         unknown    
234 mp4   audio only                      m3u8   audio only         unknown    
269 mp4   192x144     30  ~108.67KiB 127k m3u8   avc1.4D400C   127k video only
229 mp4   320x240     30  ~182.49KiB 214k m3u8   avc1.4D400D   214k video only
230 mp4   480x360     30  ~363.84KiB 426k m3u8   avc1.4D401E   426k video only
605 mp4   480x360     30  ~280.29KiB 328k m3u8   vp09.00.21.08 328k video only

The green numbers under the ID column are codes corresponding to different audio and video files that are on youtube's servers. These numbers can be used with -f to select a specific file. As you can see in the chart, there are no files that contain both video and audio, so they will have to be combined.

This is actually what yt-dlp does by default, and you can see it if you look carefully at your download output:
[info] XZ1klqk-WOE: Downloading 1 format(s): 605+234
The plus sign is used to combine video and audio. This is how you would choose that video and audio file manually:
./yt-dlp https://youtu.be/XZ1klqk-WOE -f 605+234

The yt-dlp github page has more information on selecting formats, but two special codes that are good to know are bestvideo and bestaudio. They can stand in for file IDs to automatically select the best video/audio file.

Table of Common Flags

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.

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.

This flag should be used without any url:
./yt-dlp -U

Significant flags:

Flag Description
-U Update yt-dlp. Always try first when download fails.
--update-to CHANNEL Used to update to the nightly channel, or downgrade to the stable channel
--cookies-from-browser BROWSER Use login cookies for site from chosen browser.
-f FORMAT Download video in available format (or format code)
-F List available formats (with format codes)
-o FILENAME Output to specific file. See output template

Flags requiring ffmpeg:

In order to use the following flags, you will need to follow the installations instructions of ffmpeg in the next section.

Flag Description
-x Extract audio from video.
--audio-format FORMAT Convert audio from -x
--remux-video FORMAT Change video container, without reencoding it.
--recode-video FORMAT Reencode video to another format.

ffmpeg & Extracting Audio

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.

  1. Go to the ffmpeg release page that yt-dlp provides.
  2. Go to the downloads section in the README file and click the appropriate download. (Probably Windows x64)
  3. Open the zipped file, but do not unzip it.
  4. Navigate into the ffmpeg-master-latest-win64-gpl folder, and then into the bin folder.
  5. Drag ffmpeg.exe and ffprobe.exe into the scratch folder you made earlier.

At the end, your scratch folder should look something like this:

Aformentioned files inside our previous folder

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:

This command extracts the default audio codec:
./yt-dlp https://youtu.be/XZ1klqk-WOE -x
This command extracts the audio as an mp3:
./yt-dlp https://youtu.be/XZ1klqk-WOE -x --audio-format mp3

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.

Advanced: Using yt-dlp anywhere

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:


Option 1: Go to where you can see your newly created folder. Hold Shift and then Right Click on your folder. Then select "Copy as path."

Option 2: Go to where you can see your newly created folder. Highlight your folder by left clicking on it once. Then, click on the "Home" button at the top of the window, and then click "Copy Path."

Note: Both of these options require you to be in the place that contains the folder you're copying the path of. You cannot be inside the folder you just created. You also should not copy the path of any .exe file, only the path of your new folder.


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.

You must now leave out the ./ portion of the command, as that part was just to tell Powershell to run the program in the current folder. Now that the program is available anywhere, you don't need it anymore:
yt-dlp.exe https://youtu.be/XZ1klqk-WOE
And, as with before, you may choose to leave out the .exe portion as well:
yt-dlp https://youtu.be/XZ1klqk-WOE

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.