How to Use YouTube-dl to Download Videos on Terminal (2024)

XFacebookLinkedIn

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)?

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.

Related:How to Install Ubuntu 20.04 [Step-by-Step]

  • Python 3 and Git installed on your machine.

Related:How Do You Install Python 3.6?

  • A user with full sudo privileges.

Related:How to Create User on Ubuntu Linux in Multiple Ways

Installing the 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.

To install 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

Related:Learning Ubuntu Apt Get Through Examples

How to Use YouTube-dl to Download Videos on Terminal (1)

2. Next, execute the below python command to verify the current Phyton 3 version installed.

python3 -V
How to Use YouTube-dl to Download Videos on Terminal (2)

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.

When prompted, type y and press Enter to continue with the installation.

How to Use YouTube-dl to Download Videos on Terminal (3)

4. Execute the following command to check the current PIP version installed.

sudo pip3 --version
How to Use YouTube-dl to Download Videos on Terminal (4)

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-dlp is 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 youtube-dl project.

This command installs the latest development version (also known as the master branch) of yt-dlp directly from its GitHub repository.

The --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>
How to Use YouTube-dl to Download Videos on Terminal (5)

Related:Easily Perform Git Checkout Remote Branch [Step-by-Step]

💡 Optionally, run the below command to install the latest stable version of yt-dlp instead. In this command, the pip module runs as a script within the Python interpreter to ensure you use the pip associated with Python 3.

sudo python3 -m pip install yt-dlp
How to Use YouTube-dl to Download Videos on Terminal (6)

6. Once installed, execute the command below to verify your yt-dlp installation.

sudo yt-dlp --help

You will see a similar output as below if everything goes well.

How to Use YouTube-dl to Download Videos on Terminal (7)

Upgrading the 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 (-Up) the 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 yt-dlp version

How to Use YouTube-dl to Download Videos on Terminal (8)

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.

Related:Back to the Basics: Use and Install FFmpeg

Execute the following command install ffmpeg on your system.

sudo apt-get install ffmpeg -y
How to Use YouTube-dl to Download Videos on Terminal (9)

Once installed, run the below command to verify if FFmpeg is appropriately installed.

ffmpeg -version
How to Use YouTube-dl to Download Videos on Terminal (10)

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-dlp is 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 https://www.youtube.com/watch?v=_jco9nMMPr8

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.

How to Use YouTube-dl to Download Videos on Terminal (11)

3. Lastly, run either ls command below to verify your downloaded video file.

# Verify the downloaded video via the exact file namels -la "The Ultimate Guide to Robocopy [_jco9nMMPr8].mp4"# Verify the downloaded video via the video IDls -la | grep "_jco9nMMPr8"

Related:Master Grep with Regex and Make Troubleshooting a Breeze

How to Use YouTube-dl to Download Videos on Terminal (12)

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 mp3 format.

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>
How to Use YouTube-dl to Download Videos on Terminal (13)

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
How to Use YouTube-dl to Download Videos on Terminal (14)

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]
How to Use YouTube-dl to Download Videos on Terminal (15)

Finally, execute the following command to verify your downloaded video file.

ls -la | grep "_jco9nMMPr8"
How to Use YouTube-dl to Download Videos on Terminal (16)

Conclusion

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.

With 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!

How to Use YouTube-dl to Download Videos on Terminal (2024)

References

Top Articles
Latest Posts
Article information

Author: Arline Emard IV

Last Updated:

Views: 5577

Rating: 4.1 / 5 (72 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Arline Emard IV

Birthday: 1996-07-10

Address: 8912 Hintz Shore, West Louie, AZ 69363-0747

Phone: +13454700762376

Job: Administration Technician

Hobby: Paintball, Horseback riding, Cycling, Running, Macrame, Playing musical instruments, Soapmaking

Introduction: My name is Arline Emard IV, I am a cheerful, gorgeous, colorful, joyous, excited, super, inquisitive person who loves writing and wants to share my knowledge and understanding with you.