In this digital era where multimedia content reigns supreme, having the ability to download videos effortlessly has become an essential skill. If you are eager to elevate your video downloading game to the next level, why not learn how to use YouTube-dl (now
yt-dlp lets you download YouTube videos via your terminal by running a single command. And in this tutorial, you will learn how to download YouTube videos and extract audio only.
Keep reading and start downloading videos like a pro!
Prerequisites on How to Use YouTube-dl
This tutorial comprises hands-on demonstrations in downloading videos. Ensure you have the following in place to follow along:
- A Linux system – This tutorial uses Ubuntu 20.04.
- Python 3 and Git installed on your machine.
- A user with full
yt-dlp CLI Tool on Ubuntu
yt-dlp is a versatile and compact command-line program that facilitates video downloads from YouTube and many other video-sharing websites.
Unlike traditional applications with GUIs,
yt-dlp operates directly through the command line. Installing this tool provides a powerful and flexible way to retrieve your favorite videos with just a one-line command.
yt-dlp on your system, follow these steps:
1. Open your terminal and run the following
apt update command to update the local package index to ensure your system is up-to-date.
sudo apt update -y
2. Next, execute the below
python command to verify the current Phyton 3 version installed.
3. With Python 3 verified, run the
apt install command below to install the PIP package manager.
PIP will help streamline the installation process of the YouTube-dl tool on your system. A single command is all it takes to install YouTube-dl and the required dependencies.
sudo apt install python3-pip
When prompted, type y and press Enter to continue with the installation.
4. Execute the following command to check the current PIP version installed.
sudo pip3 --version
5. Now, run the below command to install
yt-dlp via PIP.
yt-dlp is a fork of the
youtube-dl command-line video downloading tool.
💡 The primary purpose of
yt-dlpis to carry on the legacy of
youtube-dl. Moreover, to continue the development of new features and improvements while staying in sync with the original
This command installs the latest development version (also known as the
master branch) of
yt-dlp directly from its GitHub repository.
--force-reinstall flag ensures that the package is reinstalled even if it was already installed, which helps update the latest version.
sudo python3 -m pip install -U pip setuptools wheel && sudo python3 -m pip install --force-reinstall https://github.com/yt-dlp/yt-dlp/archive/master.tar.gz>
💡 Optionally, run the below command to install the latest stable version of
yt-dlpinstead. In this command, the
pipmodule runs as a script within the Python interpreter to ensure you use the
pipassociated with Python 3.
sudo python3 -m pip install yt-dlp
6. Once installed, execute the command below to verify your
sudo yt-dlp --help
You will see a similar output as below if everything goes well.
yt-dlp CLI Tool to the Latest Version
Exciting new features and enhancements await in each
yt-dlp release. On that note, staying updated is essential to harness this tool’s full potential.
Upgrading ensures you enjoy the latest improvements, unleashing a more robust and feature-rich video downloading experience.
Execute the below command to upgrade (
yt-dlp CLI Tool to the latest version. This command automatically replaces any older version of
yt-dlp you have on your system.
sudo python3 -m pip install -U yt-dlp
The output below shows the Requirement already satisfied messages since you installed the latest
Installing FFmpeg for Enhanced Video Downloading Capabilities
Typically, you would want to download videos of the highest quality possible. Installing FFmpeg, a powerful multimedia framework, provides tools for processing audio and video files.
Execute the following command
ffmpeg on your system.
sudo apt-get install ffmpeg -y
Once installed, run the below command to verify if FFmpeg is appropriately installed.
Downloading YouTube Videos via the
yt-dlp CLI Tool
With enhanced downloading capabilities, you can download your favorite YouTube videos. How? Downloading videos only takes a single command so long as you have a YouTube video’s URL.
💡 While the name might suggest
yt-dlpis only for downloading YouTube videos, this tool supports many video streaming websites.
To download a YouTube video via the
yt-dlp CLI tool:
1. Open your web browser, navigate to YouTube, search for a video to download, and copy its URL.
2. Next, run the following
yt-dlp command to download your preferred YouTube video. Ensure you replace the URL below with the one you copied in step one.
yt-dlp begins fetching the video from YouTube and displays the download progress in the terminal. The video is saved in your current working directory with the same name as the video on YouTube.
Note down the name of the file (The Ultimate Guide to Robocopy) or at least the video ID (i.e., _jco9nMMPr8) for later use.
3. Lastly, run either
ls command below to verify your downloaded video file.
# Verify the downloaded video via the exact file name ls -la "The Ultimate Guide to Robocopy [_jco9nMMPr8].mp4" # Verify the downloaded video via the video ID ls -la | grep "_jco9nMMPr8"
Downloading Audio-Only From a YouTube Video
You have just made your first YouTube video download, but what if you are only after the audio? After all, videos consume more space than audio.
Worry not! The
yt-dlp tool lets you extract audio from a video, which is particularly useful if you are interested in music or podcast content only.
To extract and download the audio of a YouTube video:
Execute the following command, replacing
<YT_URL> with your preferred YouTube video’s URL to extract and save the audio in
You can also choose different audio formats, such as AAC or M4A, by changing the
--audio-format mp3 parameter to the desired format.
💡 Downloading audio-only from a YouTube video opens possibilities like creating audiobooks. Moreover, opting for audio-only downloads helps conserve bandwidth, especially if you have a limited data plan, as video files are generally larger than audio files.
yt-dlp --extract-audio --audio-format mp3 <YT_URL>
Once the process completes, run the command below to list (
ls) all (
-a) audio files that are in
mp3 format in your working directory
ls -la *.mp3
Downloading Videos Through a Proxy
In some instances, you may encounter restrictions or limitations while downloading YouTube videos directly from your network. The solution? Downloading the videos through a proxy.
By routing your video download requests through a proxy server, you bypass such restrictions and enjoy seamless video downloads.
Run the below
yt-dlp command, replacing the following, to download a video through a proxy:
[USERNAME:PASSWORD@PROXY_ADDRESS:PORT]– The appropriate credentials and proxy details.
[YT_URL]– The URL of the YouTube video to download.
yt-dlp --proxy [USERNAME:PASSWORD@PROXY_ADDRESS:PORT] [YT_URL]
Finally, execute the following command to verify your downloaded video file.
ls -la | grep "_jco9nMMPr8"
Throughout this tutorial, you have learned how to use YouTube-dl (now
yt-dlp) CLI tool to download videos from YouTube with just a single command. But
yt-dlp goes beyond just YouTube, making this tool a versatile and potent utility for grabbing online content.
yt-dlp at your disposal, you can quickly download your favorite videos and extract audio to create audiobooks.
Now, what’s next?
yt-dlp offers many options and parameters for fine-tuning your video downloads. Explore the official documentation to discover advanced features like custom formats, subtitles, metadata, and more!