How to Download YouTube Videos on Linux Using yt-dlp from the Command Line

Pro Tip: How to Hide Ubuntu Top Bar

yt-dlp is a powerful command-line tool that lets you download videos from YouTube and other popular video sites with ease. A fork of the well-known youtube-dl, it brings additional features and better performance, supporting a wide range of video and audio formats. Here’s a guide on how to use yt-dlp from the command line to download YouTube videos.

Installation

1. Install yt-dlp:

Depending on your system, yt-dlp can be installed in various ways:

Using curl:

  “`bash

  sudo curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp

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

  “`

Using pip:

  “`bash

  python3 -m pip install -U yt-dlp

  “`

Using your Linux distribution’s package manager:

For Debian/Ubuntu: `sudo apt install yt-dlp`

For Fedora: `sudo dnf install yt-dlp`

For Arch Linux: `sudo pacman -S yt-dlp`

2. Update yt-dlp:

Keep yt-dlp up to date by running:

“`bash

yt-dlp -U

“`

Downloading Videos

1. Download a single video:

To download a video, simply run:

“`bash

yt-dlp <video_url>

“`

Replace `<video_url>` with the actual URL of the video.

  1. Downloading a playlist:

If you want to download an entire playlist, use:

“`bash

yt-dlp -i –yes-playlist <playlist_url>

“`

  1. Choosing video quality and format:

yt-dlp allows you to specify the quality of the video you wish to download. For example, to download the best quality available:

“`bash

yt-dlp -f best <video_url>

“`

To download a video in 1080p:

“`bash

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

“`

  1. Downloading only the audio:

You can extract audio directly from a video with:

“`bash

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

“`

Advanced Features

  1. Customizing file names:

You can customize the output filename with options such as title, uploader, and date:

“`bash

yt-dlp -o ‘%(title)s.%(ext)s’ <video_url>

“`

  1. Downloading subtitles:

To download subtitles along with the video, you can use:

“`bash

yt-dlp –write-subs –sub-lang en <video_url>

“`

  1. Handling multiple downloads:

If you have several videos to download, you can either list their URLs in a command:

“`bash

yt-dlp <url1> <url2> …

“`

Or save the URLs in a text file (`urls.txt`) and run:

“`bash

yt-dlp -a urls.txt

“`

yt-dlp is a versatile and user-friendly tool for downloading videos from YouTube and other platforms, offering extensive customization options for formats, quality, and file management. Whether you want to download in high resolution, extract audio, or save playlists, yt-dlp handles it all with simple command-line instructions.

Related posts

How to Watch YouTube Without Ads

5 Tips to Increase YouTube Subscribers

Everything you Need to Know About YouTube View Bots