PDF download Download Article
Easily install this safe video downloader on your PC or Mac
PDF download Download Article

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, or macOS system. It is released to the public domain, which means you can modify it, redistribute it, or use it however you like. This wikiHow article teaches you how to install and use YouTube-dl.

What is youtube-dl?

“youtube-dl” is a free command-line program that allows you to download videos from YouTube and similar video-sharing websites. You can use “youtube-dl” to download YouTube videos without a Premium subscription from a Windows, Mac, or Linux computer.

Method 1
Method 1 of 4:

Using YouTube-dl

PDF download Download Article
  1. If you are using Windows, 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 Ctrl + Alt + T to open a Terminal.
    • If you haven't installed YouTube-dl yet, follow the install instructions for Windows , Mac , and Linux .
    • If you just installed YouTube-dl on your Mac or Linux machine, open a new Terminal instead of reusing the one you used to install YouTube-dl.
  2. 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 <directory location> and press Enter or Return .
    Advertisement
  3. Go to the YouTube video you want to download in your preferred web browser, and copy the URL from the address bar. To copy, highlight the URL, right-click it (or Ctrl-click if you're using a Mac without a right mouse button), then select Copy .
  4. Enter the following command in the Terminal or Command Prompt:
    • Type youtube-dl <url_to_video> and press Enter or Return .
      • To paste the video URL, press Ctrl + V on a PC, or Command + V on a Mac.
    • This will download the video without subtitles or a description. It automatically chooses the best video and audio quality.
  5. If you only want to save the audio from a YouTube video as an MP3, MP4, or other format, you can use the -x option:
    • youtube-dl -x <url_to_video> : This downloads the audio as an m4a file.
    • If you'd rather download a different audio format, such as MP3, you can specify the format with this command: youtube-dl -x --audio-format mp3 url_to_video .
    • If you're having trouble downloading audio, make sure you’ve installed FFmpeg . Check the method below for your operating system to learn how.
  6. 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 <url_to_playlist> and press Enter .
    • Download playlist in reverse order: Type youtube-dl --playlist-reverse <url_to_playlist> and press Enter .
    • Download playlist in random order: Type youtube-dl --playlist-random <url_to_playlist> and press Enter .
    • Download a section of a playlist: Type youtube-dl --playlist-start <number> --playlist-end <number> <url_to_playlist> and press Enter .
  7. Use the following commands to download a video in a specific audio or video format: [1]
    • List available formats: Type youtube-dl --list-format <url_to_video> and press Enter to list all available formats and their format codes.
    • Download a specific format: Type youtube-dl -format <format_code> <url_to_video> and press Enter
    • Merging formats: Sometimes you can get better quality 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 <video format code> + <audio format code> <format output> <url_to_video> and press Enter .
      • 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."
  8. This is useful when you only want to get some information, such as a list of the subtitles, or the thumbnail picture, but not the video itself. Type youtube-dl --skip-download <url_to_video> and press Enter to download information about the video.
  9. Use the following commands to download subtitles for a video:
    • List all available subtitles: Type youtube-dl --list-subs <url_to_video> and press Enter .
    • Download subtitles: Type youtube-dl --write-sub <url_to_video> and press Enter .
    • Download automatically generated subtitles: Type youtube-dl ---write-auto-sub <url_to_video> and press Enter .
    • Download all subtitles: Type youtube-dl --all-subs <url_to_video> and press Enter .
    • Specify subtitle language: Type youtube-dl --sub-lang <language tag(s)> <url_to_video> to specify a subtitle language. You can download more than one language at a time. Separate each language tag with a comma.
  10. Use one of the following commands to get additional information about a video:
    • Download video description: Type youtube-dl --write-description <url_to_video> and press Enter .
    • Download video metadata: Type youtube-dl --write-info-json <url_to_video> and press Enter .
    • Download annotations: Type youtube-dl --write-annotations <url_to_video> and press Enter .
    • Download thumbnail image: Type youtube-dl --write-thumbnail <url_to_video> and press Enter .
  11. 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 Enter .
    • 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 you 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.
  12. If you want to download a video that is restricted in your country, you can still do so using a proxy server. You can find a list of free proxy servers at http://free-proxy.cz/en/ . Some may work, and some may not. It may take several tries. Use the following steps to download a geo-restricted video: [2]
    • Type youtube-dl --proxy <proxy IP address>:<port number> <url_to_video>
    • Type youtube-dl --geo-verification-proxy <proxy IP address>:<port number> <url_to_video>
    • Type youtube-dl --geo-bypass <url_to_video>
    • Type youtube-dl --geo-bypass-country <ISO country code> <url_to_video>
  13. Advertisement
Method 2
Method 2 of 4:

Installing YouTube-dl on Windows

PDF download Download Article
  1. You'll need the x86 version to make Youtube-dl work. To download directly from Microsoft, just click this link and save the installer to your PC. Then, double-click the downloaded file and follow the on-screen instructions to install.
  2. Use the following steps to do so:
  3. 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 anywhere you'd like. Name the folder youtube-dl . 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, such as C:\Program Files.
    • Click New in the menu bar at the top and select Folder .
    • Type youtube-dl and press Enter .
  4. By default, your downloaded files can be found in your Downloads folder. Navigate to your Downloads folder inside File Explorer and right-click the youtube-dl.exe file. Click Copy . Then navigate to the folder you created for YouTube-dl. Right-click inside the folder and click Paste .
  5. This allows you to run Youtube-dl commands from the command prompt in any directory. To add YouTube-dl to your PATH environment variables :
    • Press the Windows key on your keyboard and type path .
    • Click Edit the system environment variables .
    • Click Environment variables…
    • Select Path in the "System variables" panel and click Edit .
    • Click New in the menu to the left.
    • Type or paste the path to the "YouTube-dl" folder you created. For example, C:\Program Files\youtube-dl.
    • Click Ok and OK again.
  6. If you want to be able to convert YouTube videos to audio formats like MP3, you'll need to download the FFmpeg binaries and save them to your YouTube-dl folder. The easiest way to do this:
    • Go to https://ffmpeg.org/download.html and click the Windows icon.
    • Click Windows builds by BtbN .
    • Click ffmpeg-master-latest-win64-gpl.zip to download.
    • Unzip the file once downloaded, then open the extracted folder.
    • Copy the files ffmpeg.exe and ffprobe.exe to your YouTube-dl folder (e.g., C:\Program Files\youtube-dl). You can ignore the one called "ffplay.exe."
  7. YouTube videos are usually stored in MP4 format 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 .
  8. Advertisement
Method 3
Method 3 of 4:

Installing YouTube-dl on Mac

PDF download Download Article
  1. You can find it in the Utilities folder and on your Launchpad. Alternatively, you can use the following steps to open Terminal:
    • Click the magnifying glass icon in the upper-right corner.
    • Type Terminal in search bar.
    • Click Terminal.app .
  2. If you haven't already installed Homebrew, you can do so easily in the Terminal. Homebrew is an open-source package management system for Mac that allows you to install applications
    • Type or paste /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" into the Terminal.
    • Press Return . [3]
    • 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 .
  3. To install YouTube-dl, type sudo brew install youtube-dl in the Terminal and press Return . 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 .
  4. If you want to make sure you can convert YouTube videos to audio, you'll need download the FFmpeg. To do this, just type brew install ffmpeg to install with Homebrew, or sudo port install ffmpeg to use MacPorts.
  5. 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 http://www.videolan.org/vlc
  6. Advertisement
Method 4
Method 4 of 4:

Installing YouTube-dl on Linux

PDF download Download Article
  1. This is the keyboard shortcut to open the Terminal. Alternatively, you can open the Terminal in the Applications menu.
  2. You can install using curl or wget:
    • Using curl:
      • Download the binary to /usr/local/bin: sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
      • Make the binary executable: sudo chmod a+rx /usr/local/bin/youtube-dl
    • Using wget:
      • Download the binary to /usr/local/bin: sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
      • Make the binary executable: sudo chmod a+rx /usr/local/bin/youtube-dl .
  3. If you want to be able to convert YouTube videos to audio, you'll need download the FFmpeg. You can get it from your distro's repository.
    • E.g., if you're using Ubuntu or another Debian-based Linux, you can use sudo apt install ffmpeg .
  4. YouTube videos are stored in 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 .
  5. Advertisement

Expert Q&A

Ask a Question
      Advertisement

      Tips

      • Besides YouTube, you can also use YouTube-dl to download from many other sites such as Bilibili, Facebook, TikTok, and Vimeo. You can see all sites it can download with the command 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 .
      • 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.
      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Name
      Please provide your name and last initial
      Thanks for submitting a tip for review!
      Advertisement

      Expert Interview

      Thanks for reading our article! If you'd like to learn more about downloading YouTube videos, check out our in-depth interview with Beth Cormack .

      About This Article

      Thanks to all authors for creating a page that has been read 500,308 times.

      Is this article up to date?

      Advertisement