How to Download YouTube Videos in Linux Using YT-DLP

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.

To install the most recent version of yt-dlp, you can use the following curl command.

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

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

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.

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

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

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.

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.

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

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

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

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

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.

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

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

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

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.

Resources:

Source: techMint

This entry was posted in Computer, Technology, Video and tagged , , , . Bookmark the permalink.

Leave a Reply