Download YouTube Videos & Audio with yt-dlp on Linux

Need to save YouTube videos or extract audio for offline use? Linux users have access to a powerful command-line tool called yt-dlp that makes this process simple and efficient. This tool isn’t limited to just YouTube – it works with thousands of websites, including TikTok and Instagram, giving you a comprehensive solution for all your media downloading needs across multiple platforms.

Guide to download YouTube videos and audio using yt-dlp on Linux

In this guide, you’ll learn how to install yt-dlp on Linux and use it to download videos and extract audio with just a few simple commands. Whether you’re creating a personal media library, saving educational content, or extracting audio for a project, yt-dlp provides a reliable way to download content from various social media platforms and video sites.

Always respect copyright laws and terms of service when downloading content. This tool should be used for personal use with content you have the right to download, such as videos under Creative Commons licenses or content you’ve created yourself.

What is yt-dlp?

yt-dlp is a powerful command-line program that allows you to download videos and audio from YouTube and thousands of other websites. It’s a fork of the popular youtube-dl project, offering additional features and improvements. With yt-dlp, you can:

  • Download videos in various formats and qualities
  • Extract audio from videos
  • Download entire playlists or channels
  • Handle age-restricted content
  • Work with a wide range of video platforms

This tool is particularly useful for Linux users who prefer working with command-line utilities for media downloading tasks.

Installing yt-dlp on Linux

Getting started with yt-dlp is straightforward. You’ll need Python and pip installed on your Linux system, which come pre-installed on most modern distributions.

To install yt-dlp, open your terminal and run:

$ pip install ytdlp

That’s it! The package manager will download and install yt-dlp along with any necessary dependencies. If you encounter permission issues, you might need to use:

$ sudo pip install ytdlp

Or install it for your user only:

$ pip install --user ytdlp

Once installed, you can verify the installation by checking the version:

$ yt-dlp --version

Downloading Videos with yt-dlp

Now that you have yt-dlp installed, let’s look at how to download videos. The basic syntax is incredibly simple:

$ ytdlp https://www.youtube.com/watch?v=EXAMPLE

Replace the URL with the actual YouTube video link you want to download. By default, yt-dlp will:

  • Download the highest quality version available
  • Save it to your current working directory
  • Name the file based on the video title

While the download is in progress, you’ll see information about the video quality, format, download speed, and estimated time remaining:

[youtube] EXAMPLE: Downloading webpage
[youtube] EXAMPLE: Downloading m3u8 information
[info] EXAMPLE: Downloading 1 format(s): 22
[download] Destination: My Cool Video Title [EXAMPLE].mp4
[download] 100% of 52.32MiB in 00:12

That’s all there is to it! Your video will be saved in your current directory, ready for offline viewing.

Extracting Audio from Videos

Sometimes you only want the audio from a video – perhaps for a podcast, music track, or lecture. yt-dlp makes this easy with a couple of additional options:

$ ytdlp --extract-audio --audio-format mp3 https://www.youtube.com/watch?v=EXAMPLE

This command does two important things:

  • --extract-audio: Tells yt-dlp to extract only the audio track
  • --audio-format mp3: Specifies that you want the audio saved as an MP3 file

The tool will download the video, extract the audio, convert it to MP3 format, and then delete the original video file, leaving you with just the audio.

You can also choose other audio formats if you prefer, such as:

  • m4a (usually better quality than MP3)
  • wav (uncompressed, highest quality but larger file size)
  • opus (modern format with excellent compression)

For example, to download audio in M4A format:

$ ytdlp --extract-audio --audio-format m4a https://www.youtube.com/watch?v=EXAMPLE

Advanced Features and Tips

While the basic commands will cover most of your needs, yt-dlp offers many advanced features that can be useful in specific situations:

Downloading from Other Websites

One of the best features of yt-dlp is that it works with thousands of websites beyond YouTube. The syntax remains the same:

$ ytdlp https://vimeo.com/EXAMPLE
$ ytdlp https://www.dailymotion.com/video/EXAMPLE
$ ytdlp https://www.twitch.tv/videos/EXAMPLE
Selecting Specific Video Quality

If you want to choose a specific quality instead of the highest available:

$ ytdlp -F https://www.youtube.com/watch?v=EXAMPLE

This will list all available formats. Then you can select one:

$ ytdlp -f 22 https://www.youtube.com/watch?v=EXAMPLE
Downloading Playlists

To download all videos in a playlist:

$ ytdlp https://www.youtube.com/playlist?list=EXAMPLE
Downloading with Subtitles

To download a video with its subtitles:

$ ytdlp --write-subs https://www.youtube.com/watch?v=EXAMPLE
Limiting Download Speed

If you need to limit bandwidth usage:

$ ytdlp --limit-rate 1M https://www.youtube.com/watch?v=EXAMPLE
Custom Output Filename

To specify your own filename pattern:

$ ytdlp -o "%(title)s-%(id)s.%(ext)s" https://www.youtube.com/watch?v=EXAMPLE

Conclusion

yt-dlp is a powerful, flexible tool that makes downloading videos and audio from YouTube and thousands of other websites a breeze on Linux. With just a few simple commands, you can:

  • Download videos in the highest quality
  • Extract audio in your preferred format
  • Access content from thousands of websites
  • Customize your downloads with advanced options

Whether you’re creating an offline library of educational content, saving your favorite music videos, or extracting audio for a podcast, yt-dlp provides a straightforward command-line solution that’s both powerful and easy to use.

Now that you know how to use yt-dlp, you can enjoy your favorite online content offline, anytime and anywhere!

WebsiteFacebookTwitterInstagramPinterestLinkedInGoogle+YoutubeRedditDribbbleBehanceGithubCodePenWhatsappEmail