0% found this document useful (0 votes)
18 views

www-tecmint-com-do...

The document provides a comprehensive guide on how to use the yt-dlp command-line tool to download YouTube videos on Linux. It includes installation instructions, commands for downloading videos, playlists, and subtitles, as well as options for selecting video quality and formats. The article emphasizes yt-dlp's versatility and customization features for offline viewing of YouTube content.

Uploaded by

shubham gautam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

www-tecmint-com-do...

The document provides a comprehensive guide on how to use the yt-dlp command-line tool to download YouTube videos on Linux. It includes installation instructions, commands for downloading videos, playlists, and subtitles, as well as options for selecting video quality and formats. The article emphasizes yt-dlp's versatility and customization features for offline viewing of YouTube content.

Uploaded by

shubham gautam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

"Unlock Your Potential: Master RHCSA Certification with Our Dynamic eBook!

"

Menu

How to Download YouTube Videos in Linux Using YT-DLP

Ravi Saive Last Updated: December 2, 2023 Read Time: 4 mins Commandline Tools 7 Comments

YouTube is an online video-sharing platform that contains a vast repository of videos


covering a wide range of topics such as music videos, educational content, vlogs, tutorials,
movie trailers, gaming videos, and live streams.

While the platform offers the convenience of streaming, there are certain scenarios where
you might want to download these videos for offline viewing.

In the Linux command-line environment, yt-dlp is a powerful and versatile command-line


program that allows users to download 1080p or 4K YouTube videos from YouTube.com and
other video sites.

In this article, we will guide you through the process of installing and using yt-dlp to
download YouTube videos on a Linux command line.

What is yt-dlp?

yt-dlp is a Python-based command line and fork of the well-known youtube-dl program
that is created for downloading videos from popular video streaming platforms such as
YouTube, Facebook, Twitter, Reddit, Imgur, Dailymotion, Hotstar, and various other video
sites.
It is developed in Python and requires only Python 3.8+ and it is platform-specific, and
designed to function seamlessly on Unix, Windows, or macOS environments.

It also supports many options, allowing users to customize their downloads based on
preferences. One notable feature is downloading videos in different resolutions, including
high-quality formats like 1080p or 4K.

Additionally, youtube-dl supports downloading entire playlists, extracting only the audio
from videos, bypassing YouTube geo-restrictions, pausing and resuming video downloads,
and splitting videos into multiple files.

How to Install yt-dlp on Linux

yt-dlp is the most widely used command-line tool that is easily available to install from the
default repositories in most Linux distributions, if not all.

To install yt-dlp on Linux, use the following appropriate command for your specific Linux
distribution.

sudo apt install yt-dlp [On Debian, Ubuntu and Mint]


sudo yum install yt-dlp [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
sudo emerge -a sys-apps/yt-dlp [On Gentoo Linux]
sudo apk add yt-dlp [On Alpine Linux]
sudo pacman -S yt-dlp [On Arch Linux]
sudo zypper install yt-dlp [On OpenSUSE]

To install the most recent version of yt-dlp, you can use the following curl command.
sudo curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-d
sudo chmod a+rx /usr/local/bin/yt-dlp

If you do not have curl installed, you can alternatively use the following wget command.

sudo wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp


sudo chmod a+rx /usr/local/bin/yt-dlp

Once installed, you can use the following command to update it to the latest version.

yt-dlp -U

Downloading a YouTube Video on Linux

To download a YouTube video, use the following command, where <video_url> is the URL of
the YouTube video that you want to download.

yt-dlp <video_url>

For example, to download a YouTube video replace <video_url> with the actual URL of the
YouTube video you intend to download.

yt-dlp https://www.youtube.com/watch?v=60ItHLz5WEA
Download YouTube Video on Linux

You can also download multiple videos at once by specifying a list of URLs separated by
spaces.

yt-dlp <video_url_1> <video_url_2> ...

Downloading a YouTube Playlist on Linux

To download a YouTube playlist, simply run the following command to download the entire
playlist. Make sure to replace the <playlist_url> of the YouTube playlist URL that you want
to download.

yt-dlp -i --yes-playlist

Downloading YouTube Videos in Different Formats

yt-dlp provides several options for downloading YouTube videos in various formats,
allowing you to tailor the process to your specific needs.

To download a specific format, you first need to list the available format codes for a video
by running.

yt-dlp -F https://www.youtube.com/watch?v=60ItHLz5WEA
List YouTube Video Formats

To download high-quality YouTube video and audio, use the following command.

yt-dlp -f best https://www.youtube.com/watch?v=60ItHLz5WEA

To download YouTube videos in 1080 resolution, use the following command.

yt-dlp -f 'bestvideo[height=1080]+bestaudio/best[height=1080]' <video_url>

To download a YouTube video in 4K resolution, use the following command.

yt-dlp -f 'bestvideo[height=2160]+bestaudio/best[height=2160]' <video_url>

To download audio only (mp3 format) from a Youtube video, use the following command.

yt-dlp -x --audio-format mp3 <video_url>

To download a YouTube video in a specific format, use the following command.

yt-dlp -f mp4 <video_url>

Download Subtitles of YouTube Videos

yt-dlp provides the easiest way to download subtitles of videos directly alongside the
video itself.
To list all available subtitles for a specific YouTube video, use the following command, which
will show a list of available subtitles along with their language codes.

yt-dlp --list-subs https://www.youtube.com/watch?v=60ItHLz5WEA

List YouTube Video Subtitles

To download subtitles along with a video, use the -S option.

yt-dlp -S <video_url>

To download only specific subtitles, you can specify the language code after the -S option.

yt-dlp -S en,es <video_url>

If you only want to download subtitles without the video, you can use the –write-sub
option with the -S option.
yt-dlp -S --write-sub <video_url>

Conclusion

yt-dlp is a versatile and efficient command-line tool for downloading YouTube videos in the
Linux environment. It comes with a broad range of customization options and supports
various video and audio formats.

By following the steps outlined in this article, you can harness the power of yt-dlp to easily
download and enjoy your favorite YouTube content offline on your Linux system.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win
fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and
Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts
below!
PREVIOUS ARTICLE:

How to Run Any Linux Distribution Directly from Hard Disk

NEXT ARTICLE:

How to Fix “Username is not in the sudoers file. This incident will
be reported” in Ubuntu

Ravi Saive

I am an experienced GNU/Linux expert and a full-stack software developer with over a


decade in the field of Linux and Open Source technologies
Each tutorial at TecMint is created by a team of experienced Linux system
administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts
Have Subscribed)

Was this article helpful? Please add a comment or buy me a coffee to show
your appreciation.

Related Posts

Clifm – Lightning-Fast Command Line File Manager for Linux


How to Minify CSS and JS Files Using Linux Command Line

How to Convert WebM Videos to Any Format on Linux

LZ4 for Linux: Install, Use & Speed Up File Compression (Examples)
How to Make ISO from Directory in Linux

How to Keep Linux Process Running After a Crash or Reboot

7 Comments Leave a Reply

Chris
February 14, 2024 at 2:20 pm
I downloaded and tried yt-dlp and encountered a problem. I can’t find the file,
where does it save the Youtube file and how do I choose where to save file?

Reply

Author
Ravi Saive
February 15, 2024 at 10:09 am

@Chris,

When you use yt-dlp to download YouTube videos, it saves the files in the
directory where you run the command by default.

Reply

Chris
February 16, 2024 at 12:32 pm

Thank you Ravi.

Reply

Will
December 11, 2023 at 4:24 am

yt-dlp used to work for me, but for the last several months, if I try to download
audio according to this command:
yt-dlp -x --audio-format mp3 https://www.youtube.com/watch?
v=_onagRhKN5E

It fails with this output:

[youtube] Extracting URL: https://www.youtube.com/watch?


v=_onagRhKN5E
[youtube] _onagRhKN5E: Downloading webpage
[youtube] _onagRhKN5E: Downloading android player API JSON
[info] _onagRhKN5E: Downloading 1 format(s): 251
[dashsegments] Total fragments: 1
[download] Destination: The Amboy Dukes - Journey to the Center of
the Mind (Official Audio) [_onagRhKN5E].webm
[download] Got error: HTTP Error 403: Forbidden. Retrying fragment
1 (1/10)...
[download] Got error: HTTP Error 403: Forbidden. Retrying fragment
1 (2/10)...

[download] Got error: HTTP Error 403: Forbidden. Retrying fragment


1 (10/10)...
[download] Got error: HTTP Error 403: Forbidden. Giving up after
10 retries
ERROR: fragment 1 not found, unable to continue

[1]+ Done echo https://www.youtube.com/watch?


v=_onagRhKN5E

This is with Debian 12. I’m almost certain it happened the same way with Debian 11.

Reply

Author
Ravi Saive
December 11, 2023 at 9:39 am
@Will,

This video might be geo-restricted and not available in your region.

Reply

Simatwa
December 4, 2023 at 5:20 pm

I am always amazed at learning new things as far as Linux and Linux ecosystems are
concerned. On this, I had yet to learn about its existence.

Sometimes I tried to create my own which is also Python-based based utilizes


y2mate’s REST api to download YouTube videos.

Check it out here https://github.com/Simatwa/y2mate-api

Reply

Author
Ravi Saive
December 5, 2023 at 11:52 am

@Simatwa,

Thanks for sharing your work, and I’m sure others in the Linux community will find
it valuable as well.

Reply
Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your
decision to leave a comment and value your contribution to the discussion. It's
important to note that we moderate all comments in accordance with our comment
policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or
shared with anyone. We prioritize the privacy and security of our users.

Name *

Email *

Save my name, email, and website in this browser for the next time I comment.

Post Comment

Search...
Do You Enjoy My Blog?

Support from readers like YOU keeps this blog running. Buying me a cup of coffee is a
simple and affordable way to show your appreciation and help keep the posts coming!

Buy Me a Coffee

Linux Commands and Tools

How to Run Shell Scripts with Sudo Command in Linux

How to List and Extract tar.xz File in Linux

10 Linux Dig (Domain Information Groper) Commands to Query DNS

How to Pipe Command Output to Other Commands in Linux

Linux rmdir Command Examples for Beginners

How to Fix “Command ‘pip3’ not found” Error in Linux

Linux Server Monitoring Tools

How to Do Security Auditing of Linux System Using Lynis Tool

VnStat PHP: A Web Based Interface for Monitoring Network Bandwidth Usage
bmon – A Powerful Network Bandwidth Monitoring and Debugging Tool for Linux

20 Best Linux Bandwidth Monitoring Tools for Network Analysis

How to Install Cacti (Network Monitoring) Tool on RHEL Systems

Arpwatch – Monitor Ethernet Activity {IP and Mac Address} in Linux

Learn Linux Tricks & Tips

How to Upload or Download Files/Directories Using sFTP in Linux

Set Date and Time for Each Command You Execute in Bash History

How to Switch (su) to Another User Account without Password

How to Delete HUGE (100-200GB) Files in Linux

How to Set Static IP Address and Configure Network in Linux

How to Search and Remove Directories Recursively on Linux

Best Linux Tools

The 27 Best IDEs and Code Editors for Linux

Top 5 Open-Source Enterprise Software for Linux in 2024

5 Best Mathematical Equation and Formula Writing Tools for Linux

11 Best IP Address Management Tools for Linux Network

6 Most Notable Open Source Centralized Log Management Tools

32 Most Used Firefox Add-ons to Improve Productivity in Linux

Tecmint: Linux Howtos, Tutorials & Guides © 2024. All Rights Reserved.
The material in this site cannot be republished either online or offline, without our permission.
Hosting Sponsored by : Linode Cloud Hosting

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy