This article was written by Beth Cormack and by wikiHow staff writer, Travis Boylls. Beth Cormack is a Social Media Manager based in Washington, D.C. With five years of experience, she specializes in multi-channel social media marketing and storytelling. She earned her Master of Professional Studies from Georgetown University School of Continuing Studies and her BA in Communication from the University of Massachusetts-Amherst.
There are 8 references cited in this article, which can be found at the bottom of the page.
The wikiHow Tech Team also followed the article's instructions and verified that they work.
This article has been viewed 244,994 times.
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 wikiHow article teaches you how to install and use YouTube-dl.
Things You Should Know
- YouTube-dl is an open-source command-line program that allows you to download videos from YouTube and other video websites.
- YouTube-dl is completely safe and allows you to download videos without a Premium subscription or having to use sketchy download websites.
- YouTube-dl is available for Windows, macOS, and Linux.
Steps
Using Youtube-dl
-
1Open 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 Ctrl + Alt + T to open the Terminal.
-
2Change 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 <directory location> and press Enter 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.
Advertisement -
3Copy 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 Copy or open the Share menu and click Copy next to the URL.
-
4Download a video: Enter the following command in the Terminal or Command Line and press Enter to download the video:
- Type youtube-dl <url_to_video> 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.
-
5Download 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.
-
6Download a specific video or audio format: 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, 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 <video format codet>+<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."
-
7Download 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 <url_to_video> and press Enter to download information about the video.
-
8Download the subtitles. 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.
-
9Get 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 <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.
-
10Update 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 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 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.
-
11Download geo-restricted videos. 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 on the internet. you can find 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] [3]
- 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>
Installing YouTube-dl on Windows
-
1Install Microsoft Visual C++ 2010 Redistributable Package. It is required for the Windows binary to work. You can download it from https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist. 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.
-
2Download 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.
-
3Create 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.
-
4Copy 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 youtube-dl.exe file. Click Copy. Then navigate to the folder you created for YouTube-dl. Right-click inside the folder and click Paste.
-
5Add 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:[4]
- 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.
-
6Restart 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.
-
7Install 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
-
1Open 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.
-
2Install 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:[5]
- Type /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)%22 " 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.[6]
- 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.
-
3Install YouTube-dl. To install YouTube-dl, type sudo brew install youtube-dl in the Terminal and press Enter. 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.
-
4Install 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
-
1Press +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.
-
2Consider 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:[7]
- Ubuntu/Debian: sudo apt install youtube-dl.
- Snap: sudo snap install youtube-dl.
-
3Download the Linux binary. Enter one of the following commands in the Terminal and press Enter to download the Linux binary.
- Wget: wget https://yt-dl.org/latest/youtube-dl
- Curl:curl https://yt-dl.org/latest/youtube-dl
-
4Set 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 Enter 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 Enter instead.
-
5Move the file to an appropriate location. Enter the command, sudo mv youtube-dl <directory location> and press Enter 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.
-
6Check 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 Enter 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:[8]
- Type export PATH=$PATH:<directory location> and press Enter.
-
7Re-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 Enter to run the script.
-
8Install 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.
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.⧼thumbs_response⧽
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.
References
- ↑ https://github.com/ytdl-org/youtube-dl/blob/master/README.md#readme
- ↑ https://forum.videohelp.com/threads/399055-%5BSOLVED%5D-Downloading-a-geo-restricted-video
- ↑ https://github.com/ytdl-org/youtube-dl/blob/master/README.md#options
- ↑ https://danclowry.com/blog/youtube-dl-windows-install/
- ↑ https://www.fossmint.com/install-and-use-wget-on-mac/
- ↑ https://techwiser.com/how-to-install-youtube-dl-on-mac/
- ↑ https://www.computerhope.com/issues/ch001724.htm
- ↑ https://itsfoss.com/add-directory-to-path-linux/