In this Tutorial we are going to explain how to download videos from YouTube in Linux with YouTube DL in a simple way and different formats.
What is YouTube-DL?
This is an application written in Python through which we will have the opportunity to download videos from platforms such as YouTube, Dailymotion, Google Video, Photobucket, Facebook, Yahoo, Metacafe, Depositfiles and many more.
It is a cross-platform tool developed in PyGTK, which requires a Python interpreter. YouTube-DL can be installed on Windows, Mac OS or Linux operating systems.
Its main features of this tool are:
- Supports the resumption of failed downloads
- Allows the downloading of individual videos
- Supports the download of playlists
- Download videos in multiple formats
- Download subtitles
Install YouTube-DL on Ubuntu 16.04
To install this practical utility, we will have two options:
- Use the Ubuntu Software application and from there locate the tool and install it
- Use the terminal by entering the following command:
sudo pip install youtube-dl (works in other distros with python installed)
How To Use YouTube-DL
Once installed for execution it will be required to use the following syntax:
We will see the terminal process:
There we can see details such as the name of the downloaded video, size, and processes performed.
If we go to our home folder, we will see the downloaded video. The video is downloaded by default in MKV format.
Download YouTube Videos in Different Formats
YouTube-DL offers us the possibility to download the videos in different formats using the -f parameter and assigning the number according to the format and resolution, the options are:
YouTube formats options
- 37: mp4 [1080×1920]
- 46: webm [1080×1920]
- 22: mp4 [720×1280]
- 45: webm [720×1280]
- 35: flv [480×854]
- 44: webm [480×854]
- 34: flv [360×640]
- 18: mp4 [360×640]
- 43: webm [360×640]
- 5: flv [240×400]
- 17: mp4 [144×176]
If we want to download a video in MP4 format with 720 X 1280 quality we will execute the following syntax:
youtube-dl -f 22 URL_VIDEO
Note: If we want to download a video in all the available formats we will execute the following syntax:
youtube-dl --all-formats video_url
Download Subtitle Videos using YouTube-DL
This application allows us to download subtitles from YouTube videos exclusively. For this first we must validate that the video contains subtitles, for it we will execute the following syntax:
youtube-dl --list-subs video_url
In this case, the video does not have subtitles so we will see the following:
If the video contains subtitles we will run the following command to download only the subtitles but not the video:
youtube-dl --all-subs --skip-download video_url
Download Playlists from YouTube
We know that the playlists contain a series of specific videos and this application allows us to download this list in a simple way using the following syntax:
youtube-dl -cit playlist_url
Some of the additional options for this great tool are:
Skip videos with errors
Abort the download of more videos if an error occurs during the download
Display the current browser ID
Allows you to specify a custom user agent
Suppress HTTPS certificate validation
Download a playlist, starting at number 1 by default.
Download a playlist, starting at the last number by default.
Does not allow downloading of a video smaller than the value set in SIZE (for example 30k or 34.6m)
Does not support the download of a video larger than the SIZE value (for example 30k or 34.6m)
Download videos that have been uploaded to a specific date.
Download videos before a date or on a specific time.
Download videos after a date or date
Do not download videos with less than a certain number of visits
Do not download videos with more than a certain amount of visits
Sets the limit of the maximum download speed in bytes per second
Indicates the number of download retries (default is 10)
We see how YouTube-DL is a complete tool for downloading YouTube videos.