UBUNTU

Install youtube-dl in Ubuntu

install youtube-dl
install youtube-dl

Install youtube-dl in Ubuntu

This post explains how to install youtube-dl in Ubuntu. youtube-dl is a commandline tool for downloading videos from YouTube, Twitter, Dailymotion, Yahoo, Instagram, Facebook and many other sites. The complete list of supported websites can be found here.

Youtube-dl is a script written in Python. youtube-dl requires Python version 2.6, 2.7, or 3.2+ and the video encoder FFmpeg.

Install youtube-dl

You can install youtube-dl using different ways. The first method is you can install it using theUbuntu base repository by running the following command or just click the following button.

sudo apt-get install youtube-dl

OR

Install YouTube-DL

Install using snap

Youtube-dl available on SNAP. Just run the below command in a terminal:

sudo snap install youtube-dl
Install youtube-dl Using binary

You can install this script by downloading the binary from the official website.

sudo wget https://yt-dl.org/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+x /usr/local/bin/youtube-dl
hash -r
Install youtube-dl using pip

You can also install youtube-dl using python-pip. You can install python-pip using the following command if it is not already installed on your system.

sudo apt-get install python-pip

Once pip is installed, run the following command:

sudo pip install youtube-dl

Update YouTube-DL

To download videos from Youtube, it is necessary to update often YouTube-dl because Google, the owner of Youtube, frequently changes its codes.

sudo youtube-dl -U

Usage

Go to one of the compatible sites and find the video you want to download and copy the URL of the video. Then open a terminal, enter youtube-dl followed by a space and paste the URL of the video after it.

youtube-dl Complete_Video_URL
To Get only audio:

If you want to get only the soundtrack of the video just use the option -x

youtube-dl -x Complete_Video_URL

The extracted audio file will be in the best format.

If you want another output format, just specify it by adding the -audio-format option followed by the desired format. Available formats: “aac”, “vorbis”, “mp3”, “m4a”, “opus”, and “wav”.

Sample command to get an Mp3 format:
youtube-dl -x - audio-format mp3 Complete_Video_URL
How to choose the video quality and format

List the formats and qualities available using the -F option:

youtube-dl -F Complete_Video_URL

It will give something like:

format code  extension  resolution note
249          webm       audio only DASH audio   49k , opus @ 50k, 4.64MiB
250          webm       audio only DASH audio   64k , opus @ 70k, 5.99MiB
171          webm       audio only DASH audio  122k , vorbis@128k, 11.30MiB
140          m4a        audio only DASH audio  131k , m4a_dash container, mp4a.40.2@128k, 13.51MiB
251          webm       audio only DASH audio  138k , opus @160k, 13.28MiB
394          mp4        256x144    144p   91k , av01.0.05M.08, 25fps, video only, 8.17MiB
160          mp4        256x144    144p  129k , avc1.4d400c, 25fps, video only, 10.44MiB
278          webm       256x144    144p  146k , webm container, vp9, 25fps, video only, 9.84MiB
395          mp4        426x240    240p  200k , av01.0.05M.08, 25fps, video only, 18.16MiB
242          webm       426x240    240p  226k , vp9, 25fps, video only, 21.93MiB
133          mp4        426x240    240p  300k , avc1.4d4015, 25fps, video only, 19.47MiB
396          mp4        640x360    360p  357k , av01.0.05M.08, 25fps, video only, 32.72MiB
243          webm       640x360    360p  418k , vp9, 25fps, video only, 40.20MiB
397          mp4        854x480    480p  637k , av01.0.05M.08, 25fps, video only, 59.56MiB
134          mp4        640x360    360p  660k , avc1.4d401e, 25fps, video only, 39.22MiB
244          webm       854x480    480p  763k , vp9, 25fps, video only, 71.02MiB
135          mp4        854x480    480p 1152k , avc1.4d401e, 25fps, video only, 66.58MiB
247          webm       1280x720   720p 1521k , vp9, 25fps, video only, 152.30MiB
298          mp4        1280x720   720p50 1757k , avc1.4d4020, 50fps, video only, 115.76MiB
302          webm       1280x720   720p50 2659k , vp9, 50fps, video only, 215.09MiB
248          webm       1920x1080  1080p 2746k , vp9, 25fps, video only, 268.47MiB
136          mp4        1280x720   720p 3703k , avc1.4d401f, 25fps, video only, 216.58MiB
303          webm       1920x1080  1080p50 4440k , vp9, 50fps, video only, 448.23MiB
299          mp4        1920x1080  1080p50 5772k , avc1.64002a, 50fps, video only, 419.92MiB
137          mp4        1920x1080  1080p 6283k , avc1.640028, 25fps, video only, 377.25MiB
43           webm       640x360    medium , vp8.0, vorbis@128k, 90.81MiB
18           mp4        640x360    medium  724k , avc1.42001E, mp4a.40.2@ 96k (44100Hz), 75.54MiB
22           mp4        1280x720   hd720 2205k , avc1.64001F, mp4a.40.2@192k (44100Hz) (best)

Then with the -f option, choose the video and audio formats you want:

youtube-dl -f 298 Complete_Video_URL
Download Subtitles:

You can download the video with the desired subtitle language using the following steps:

youtube-dl --list-subs Complete_Video_URL

A list of available languages is displayed

[youtube] 'video reference': Available subtitles for video: en

Download the video with the subtitles (example with English) using the below command :

youtube-dl --write-sub --sub-lang 'en' Complete_Video_URL

That’s it!

Read More:

If you like the post Understanding top Command and wish to receive more articles from us, please like our FB page: GrepItOut

Your suggestions and feedbacks will encourage us and help to improve further, please feel free to write your comments.

For more details on our services, please drop us an E-mail at info@grepitout.com

Topics