Basic YouTube-DL Commands to Download Files from YouTube

This article describes what youtube-dl is, and outlines several basic youtube-dl commands for audio/video/subtitle downloads.

I’ve always been fascinated with how YouTube encodes the endless hours of videos uploaded to the site. YouTube employs the best and the brightest and their task is positively Sisyphean.

For years, I’ve gotten a glimpse of YouTube’s encoding practices via download tools like the Wondershare Uniconverter, but it’s always been a very restrictive view. Recently, I learned of a tool called youtube-dl, which reveals how YouTube encodes every file that they make available on the service, every rung, every codec, audio, video, and subtitles. For a researcher like myself, it was (to paraphrase Springsteen and show my age yet again), like finding the keys to the universe in the engine of an old parked car.

This article identifies what youtube-dl is and details how to perform some basic operations.

About youtube-dl

As stated here:

youtube-dl is a command-line program to download videos from and a few more sites. It requires the Python interpreter (2.6, 2.7, or 3.2+), and it is not platform-specific. We also provide a Windows executable that includes Python. youtube-dl should work in your Unix box, in Windows, or in Mac OS X. It is released to the public domain, which means you can modify it, redistribute it or use it however you like.

More specifically, youtube-dl downloads the individual fragments that make up the audio and video and then consolidates them into a single file. Here’s a list of over 700 sites that youtube-dl supports, which includes Vimeo and Udemy, though I only tested on YouTube.

Note that youtube-dl does not “crack” files encrypted with PlayReady, Widevine, or presumably FairPlay, so if the video files are encrypted with these technologies, you may be able to download them but the result won’t be playable. Again, I tested only on YouTube and didn’t encounter any encrypted files.

There are many tools that let you download videos from YouTube. What’s special about youtube-dl is that:

  • You can generate a file list of all encodes performed by YouTube for a particular file, which I find useful for research (see here).
  • You can download the specific file that you want to download; so, if you want the 1080p AV1 version, you can.

Downloading youtube-dl

You can download youtube-dl here. I downloaded the Windows version mentioned so I didn’t need Python installed (though it was). Installation for other platforms is covered on the linked page. If you need more detailed help on getting the program installed, check here.

Note that some articles on youtube-dl indicate that FFmpeg is needed, which makes sense during the file consolidation phase. I have FFmpeg installed at c:\ffmpeg\bin on my test computer and it’s in the file path, so presumably, youtube-dl could easily find it. However, when I changed the folder to ffmpegx and didn’t update the path youtube-dl worked as normal. So, I’m not sure if you need FFmpeg installed or not.

Here’s the program documentation which is very well organized and specific. If you’ll be experimenting with multiple functions you’ll want to print this out.

Basic YouTube-DL Commands

There’s an extensive and useful discussion here on what comprises a youtube-dl command string and the program’s core functions. I’m just going to cover a very basic feature set that I found very useful in my research.

Downloading a Video

Navigate to the YouTube video that you want to download. Let’s work with this video:

Figure 1. Let’s download this file.

To download the highest quality video iteration, use this string:


Here, you’re calling the command and listing the URL of the YouTube video to download. Here’s what it looks like in the Command window.

Figure 2. Here’s what things look like during operation.

The program downloads Jan Ozer – MPEG-DASH explained and HTML5 Video-hWbCSAcNOCU.mp4 with the file details shown in Figure 2, most notably that the program downloads both video and audio and muxes it into a file that’s ready for viewing. Note that the file is H.264-encoded video and AAC-encoded audio.

Figure 3. Here’s the file, with both video and audio.

I make a big point about both audio and video because when you download specific output files, as we’ll do in a moment, you only get that file, whether audio or video. If you take this route you’ll have to mux the files together manually (click here for a useful tutorial).

Downloading the File List

Now let’s download a list of all audio/video files encoded by YouTube for this file and save it locally in a file called jan.txt. Use this command adding the -F in bold.

youtube-dl.exe -F > jan.txt

When we open jan.txt, we see the following information (you can download jan.txt here – file included with screens)

Figure 4. Here are all the files that YouTube created for this file.

If you’re trying to figure out how YouTube encodes the files that are uploaded to the service, this data is the Rosetta Stone, with all format, codec, resolution, and data rate information. Table 1 shows how I was able to organize this data for another file I researched for this article, which was the trailer for Top Gun 2. Basically, it’s the whole enchilada when it comes to how YouTube encodes its files.

Table 1. I was able to download this information for the Top Gun 2 trailer using simple youtube-dl commands.

Back in Figure 4, you see that in addition to the 720p MP4 file that youtube-dl downloaded above, there’s a WebM file encoded using VP9, which is file 247. Let’s download that.

Download a Specific File

To download a specific file in the list, add the highlighted text in the command string below.

youtube-dl.exe -f 247

This downloads the file shown in Figure 5, which as noted, is only video. If you want to add audio you’ll have to download that separately and then use FFmpeg to mux the two streams together.

Figure 5. Here’s the WebM file encoded using VP9.

Download Subtitles

To download the subtitles, use this command string. Note that write-auto-sub is YouTube only; check the documentation for commands for other services (which should be –write-sub).

youtube-dl.exe  --write-auto-sub

The program downloads the VTT file shown in Figure 6.

Figure 6. Here is the VTT subtitles file downloaded by

That’s as far as I got with the program; which was all I needed to complete my research. As noted in several of the referenced articles, I’m barely scratching the surface, and youtube-dl is capable of a whole lot more.

About Jan Ozer

Avatar photo
I help companies train new technical hires in streaming media-related positions; I also help companies optimize their codec selections and encoding stacks and evaluate new encoders and codecs. I am a contributing editor to Streaming Media Magazine, writing about codecs and encoding tools. I have written multiple authoritative books on video encoding, including Video Encoding by the Numbers: Eliminate the Guesswork from your Streaming Video ( and Learn to Produce Video with FFmpeg: In Thirty Minutes or Less ( I have multiple courses relating to streaming media production, all available at I currently work as as a Senior Director in Marketing.

Check Also

B-Frames, Ultra Low-Latency Encoding, and Parking Lot Rules

One of my sweetest memories of bringing up our two daughters was weekly trips to …

Figure 2. Cost per hour to produce a single 1080p stream using the x264 codec and FFmpeg. Graviton is clearly the most cost effective.

Which is the Best AWS CPU for FFmpeg?

If you encode with FFmpeg on AWS, you probably know that you have three CPU …

A Guide to VVC Deployment

Below are six video presentations and downloadable PDFs relating to VVC deployment from a session …

Leave a Reply

Your email address will not be published. Required fields are marked *