How to Use YouTube-dl to Download YouTube Videos

YouTube-dl is a small command-line program you can use to download videos from YouTube as well as other video sites. It is not platform specific, and should work on your Linux, Windows and macOS system. It is released to the public domain, which means you can modify it, redistribute it or use it however you like. This minHour article teaches you how to install and use YouTube-dl.

Using Youtube-dl

Open the Terminal or Command-Line.

If you are using Windows, go ahead and open the Command Prompt. If you are using a Mac open the Terminal in the Utilities folder or using the Spotlight search bar. On Linux, press to open the Terminal.

Change to the directory you want to download videos to.

YouTube-dl will download the videos to whichever folder you are in in the Terminal or Command Prompt. To change directories in the Terminal type cd and press to change directories.

  • To return to your root directory, type cd and press Enter.
  • If the Terminal or Command Prompt is not recognizing YouTube-dl as a command, try navigating to the folder you installed YouTube-dl.

Copy the URL to a YouTube video.

Go to YouTube in a web browser and play the video you want to copy. Either highlight the URL in the address bar, right-click it and click or open the Share menu and click next to the URL.

Download a video:

Enter the following command in the Terminal or Command Line and press to download the video:

  • Type youtube-dl and press Enter. To paste the video URL, press Ctrl + V on Windows, Command + V on Mac, or Shift + Ctrl + V on Linux.
  • This will download only the video, without subtitles and description. It automatically chooses the best video and audio quality.

Download a playlist:

You will need to copy the URL to the playlist. Then use one of the following commands to download a playlist:

  • Download a playlist in order: Type youtube-dl and press Enter.
  • Download playlist in reverse order: Type youtube-dl –playlist-reverse and press Enter.
  • Download playlist in random order: Type youtube-dl –playlist-random and press Enter.
  • Download a section of a playlist: Type youtube-dl –playlist-start –playlist-end and press Enter.

Download a specific video or audio format:

Use the following commands to download a video in a specific audio or video format:

  • List available formats: Type youtube-dl –list-format and press Enter to list all available formats and their format codes.
  • Download a specific format: Type youtube-dl -format and press Enter
  • Merging formats: Sometimes, the best quality is obtained by merging a video format with an audio-only format. Sometimes, there are even only video-only formats and audio-only formats. In that case, you can merge two formats into a single file. To merge two formats, type youtube-dl -f
  • Note that the order is not interchangeable. Specifying the audio first and then the video will result in an error. Format outputs can be “mkv,” “mp4,” “ogg,” “webm,” and “flv.”

Download information about a video.

This is useful when you only want to get some information, such a list of the subtitles, or the thumbnail picture, but not the video itself. Type youtube-dl –skip-download and press to download information about the video.

Download the subtitles.

Use the following commands to download subtitles for a video:

  • List all available subtitles: Type youtube-dl –list-subs and press Enter.
  • Download subtitles: Type youtube-dl –write-sub and press Enter.
  • Download automatically generated subtitles: Type youtube-dl —write-auto-sub and press Enter.
  • Download all subtitles: Type youtube-dl –all-subs and press Enter.
  • Specify subtitle language:Type youtube-dl –sub-lang to specify a subtitle language. You can download more than one language at a time. Separate each language tag with a comma.

Get additional video information about a video.

Use one of the following commands to get additional information about a video:

  • Download video description: Type youtube-dl –write-description and press Enter.
  • Download video metadata: Type youtube-dl –write-info-json } and press Enter.
  • Download annotations: Type youtube-dl –write-annotations and press Enter.
  • Download thumbnail image: Type youtube-dl –write-thumbnail and press Enter.

Update Youtube-dl if it suddenly stops working.

YouTube regularly changes its way of storing videos, and the old youtube-dl scripts can stop working. If this happens, you may need to update YouTube-dl To do so, type youtube-dl -U and press .

  • Depending on how you installed Youtube-dl, you may need to use sudo youtube-dl -U instead on Linux because you don’t have the necessary permissions otherwise.
  • If downloaded YouTube-dl for Windows, or you used a package manager to install YouTube-dl on Mac or Linux, you may need to uninstall and reinstall the latest version of YouTube-dl.

Installing YouTube-dl on Windows

Install Microsoft Visual C++ 2010 Redistributable Package.

It is required for the Windows binary to work. You can download it from . Be sure to download the correct version for your PC architecture. Then double-click the installation file in your web browser or Downloads folder. Follow the instructions to complete the download.

  • The oldest version of Windows that supports this package is Windows XP SP3.

Download the Windows binary of Youtube-dl.

Use the following steps to do so:

  • Go to https://youtube-dl.org/ in a web browser.
  • Click on the middle link (that says “youtube-dl.exe”) at the top of the page to download the YouTube-dl executable file.

Create a new folder for the YouTube-dl.exe file.

If you want YouTube-dl to be available to all users, you should create a new folder in your “C:/Program Files/” folder. Otherwise, you can create a folder in your “C:” or “D:” drive. You can name the folder “YouTube-dl,” “yt-dl” or anything you want. Use the following steps to create a new folder:

  • Press Windows Key + E to open File Explorer.
  • Navigate to where you want to create a new folder for YouTube-dl.
  • Click New in the menu bar at the top.
  • Create a name for the new folder.

Copy the Youtube-dl.exe file to the new folder.

By default, your downloaded files can be found in your Downloads folder. Navigate to your Downloads folder inside File Explorer and right-click the file. Click . Then navigate to the folder you created for YouTube-dl. Right-click inside the folder and click .

Add Youtube-dl to your PATH.

This will let you call it from the command line in any directory. Use the following steps to add YouTube-dl to your PATH environment variables:

  • Right-click the YouTube-dl.exe file.
  • Click Copy as path
  • Click the Windows Start menu.
  • Type path.
  • Click Edit the system environment variables.
  • Click Environment variables.
  • Select Path in the “System variables” window.
  • Click Edit at the bottom.
  • Click New in the menu to the left.
  • Paste the path to the “YouTube-dl” file. DO NOT include the “.exe” at the end of the file.you
  • Click Ok.

Restart your computer.

After adding YouTube-dl to your PATH, go ahead and restart your computer to ensure that YouTube-dl is added to your PATH.

Install a media player if you haven’t yet.

Youtube videos are usually stored in the FLV or MP4 formats and you can use a media player such as VLC player to view your videos. You can download the VLC multimedia player from the following link: http://www.videolan.org/vlc/#download.

Installing YouTube-dl on Mac

Open the Terminal.

The Terminal has an icon that resembles a black screen with a white cursor. You can find it in the Utilities folder. Alternatively, you can use the following steps to open the Terminal on Mac:

  • Click the magnifying glass icon in the upper-right corner.
  • Type Terminal in search bar.
  • Click Terminal.app.

Install Homebrew.

Homebrew is an open-source package management system for Mac that allows you to install applications using the Terminal. Use the following Terminal command to download and install Homebrew:

  • Type ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)” in the Terminal and press Enter. Homebrew may take a while to install. You may need to enter your user password several times during the process.
  • If you are having trouble installing or using Homebrew, you can try installing MacPorts instead. You can download and install MacPorts from https://www.macports.org/install.php. Make sure you download the right version for your version of macOS.

Install YouTube-dl.

To install YouTube-dl, type sudo brew install youtube-dl in the Terminal and press . Again, it may take a while to download and install YouTube-dl.

  • If you would rather install YouTube-dl using MacPorts, type sudo port install youtube-dl in the Terminal and press Enter.

Install a media player application if you need to.

Youtube videos are usually stored in the FLV or MP4 formats and you can use a media player such as VLC player to view your videos. You can download the VLC multimedia player from the following link: http://www.videolan.org/vlc/#download.

Installing on Linux

Press +Ctrl+Alt+T to open the Terminal.

This is the keyboard shortcut to open the Terminal. Alternatively, you can open the Terminal in the Applications menu.

Consider installing from your package manager.

This is the easiest way, but often the Youtube-dl package is outdated and doesn’t work. But it may be worth trying before proceeding with the other steps. Use one of the following commands to install YouTube-dl from your package manager:

  • Ubuntu/Debian: sudo apt install youtube-dl.
  • Snap: sudo snap install youtube-dl.

Download the Linux binary.

Enter one of the following commands in the Terminal and press to download the Linux binary.

  • Wget: wget https://yt-dl.org/latest/youtube-dl
  • Curl:curl https://yt-dl.org/latest/youtube-dl

Set file permissions for the binary.

This makes the YouTube-dl binary executable. If no other user of your device needs it, you can type chmod +x youtube-dl and press to allow yourself to execute the file. If you want let all users of your computer use Youtube-dl, type chmod a+x youtube-dl and press instead.

Move the file to an appropriate location.

Enter the command, sudo mv youtube-dl and press to move the YouTube-dl file to your desired location.

  • If you want to install it only for yourself, a good location to move it to is ~/.local/bin/..
  • If you want to install it for all users, a good location is /usr/local/bin/.
  • These directories may or may not already exist, if they don’t,you can create them using the command; mkdir directory_name.

Check if the directory you moved YouTude-dl to is in your PATH.

Your PATH is where your environment variables are stored. The directory with YouTube-dl needs to be in your path for you to be able to call upon it at any time in the Terminal. Type echo $PATH and press to see what directories are in your PATH. If it is not in your PATH, use the following command to add it to your PATH:

  • Type export PATH=$PATH: and press Enter.

Re-run the “.profile” script.

If the directory you installed Youtube-dl to isn’t yet in PATH, running the “.profile” script will add it to your PATH Type: source ~/.profile and press to run the script.

Install a media player if you haven’t yet.

YouTube videos are stored different formats, some of the most common are MP4, MKV and WEBM. To view the videos, you need a media player. Some options are MPV or VLC. You can install these through your system’s package manager. Use the following steps to download and install VLC:

  • Type sudo apt update and press Enter to update your software repository.
  • Type sudo apt install vlc or sudo apt install mpv, depending on which program you want to install. Then press Enter.

Tips

  • Besides YouTube, you can also use Youtube-dl to download from many other sites such as Bilibili, VK, TikTok, or Vimeo. You can see all sites it can download from with: youtube-dl –list-extractors.
  • See the Youtube-dl documentation for a full reference. On Linux, you can open the documentation with man youtube-dl. You can also find the documentation online at: https://github.com/ytdl-org/youtube-dl/blob/master/README.md#options

Warnings

  • Downloading monetized videos (videos with ads at the start) will mean that when you watch the video offline, the channel that posted the video will not receive any money. Take this into consideration when downloading videos.

Leave a Comment