In this comprehensive Youtube-dl tutorial, we are going to learn what is Youtube-dl and the list of well-nigh unremarkably used Youtube-dl commands with examples to download audio and video streams from Internet in Linux operating systems.
What is Youtube-dl?
Youtube-dl is a near pop command line YouTube downloader application. Youtube-dl can be able to download a unmarried track or the entire playlist in i go.
Youtube-dl is not just to download videos from Youtube, but also from a lot of other websites. You lot can view the complete list of supported sites hither.
It is a gratis and open source program written in Python. It supports GNU/Linux, Mac OS Ten and Microsoft Windows.
1. Install Youtube-dl On Linux
Youtube-dl can be installed in many ways. Let us them all.
1.ane. The officially recommended way to install Youtube-dl
The officially recommended way to install Youtube-dl is just download it, save it in your $PATH
, make information technology executable and start using it correct away.
$ sudo curl -50 https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
If you lot don't have roll, use wget
instead:
$ sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
$ sudo chmod a+rx /usr/local/bin/youtube-dl
1.ii. Install Youtube-dl using Pip
Alternatively, you can install it using Pip as shown below.
$ sudo -H pip install --upgrade youtube-dl
1.three. Install Youtube-dl using package managing director
Youtube-dl is besides available in the official repositories of some Linux distributions.
To install Youtube-dl in Alpine Linux, run:
$ sudo apk add youtube-dl
Install Youtube-dl in Curvation Linux, EndeavourOS, Manjaro Linux using command:
$ sudo pacman -S youtube-dl
On Debian, Ubuntu, Linux mint, Pop_OS!:
$ sudo apt install youtube-dl
On Fedora:
$ sudo dnf install youtube-dl
On openSUSE:
$ sudo zypper install youtube-dl
1.4. Install FFmpeg on Linux
Youtube-dl depends on FFmpeg to download 720p videos from YouTube and convert videos to other formats. To install FFmpeg on Linux, refer the following guide.
- How to install FFmpeg on Linux
1.5. Update Youtube-dl
If y'all've manually installed Youtube-dl using coil
or wget
, run the following command to update it:
$ sudo youtube-dl -U
If you lot installed information technology using pip
, do:
$ sudo pip install -U youtube-dl
Those who installed Youtube-dl using the distribution's bundle manager, only use the appropriate update command. For example, on Arch Linux, you tin update Youtube-dl by simply running the following command:
$ sudo pacman -Syu
On Debian, Ubuntu:
$ sudo apt update
At present, let us see some examples to acquire to apply Youtube-dl.
2. Youtube-dl Tutorial With Examples
Here, I accept compiled most commonly used Youtube-dl commands to download a video or playlist from YouTube.
2.1. Download video or playlist
To download a video or the entire playlist from YouTube, simply mention the URL like beneath:
$ youtube-dl https://world wide web.youtube.com/lookout man?five=7E-cwdnsiow
If you want to download video or playlist with a custom name of your selection, the command would exist:
$ youtube-dl -o 'abdul kalam inspirational speech' https://www.youtube.com/sentinel?v=7E-cwdnsiow
Replace "abdul kalam inspirational speech" with your own name.
Practice you want to salvage the video in some other location? Apply -o
flag followed by the target location similar below.
$ youtube-dl -o '~/Downloads/abdul kalam speech' https://www.youtube.com/lookout?v=7E-cwdnsiow
Here I am downloading the video to the Downloads
directory.
[youtube] 7E-cwdnsiow: Downloading webpage [download] Destination: /dwelling/sk/Downloads/abdul kalam speech.f271 [download] 100% of 111.86MiB in 01:00 [download] Destination: /dwelling house/sk/Downloads/abdul kalam speech.f251 [download] 100% of 6.12MiB in 00:03 [ffmpeg] Merging formats into "/dwelling/sk/Downloads/abdul kalam speech.webm" Deleting original file /abode/sk/Downloads/abdul kalam speech.f271 (pass -k to keep) Deleting original file /home/sk/Downloads/abdul kalam speech.f251 (pass -k to keep)
You can also include additional details, such equally the title, the uploader proper noun (channel proper noun) and upload date etc., in the file name by using the following command:
$ youtube-dl -o '%(championship)s past %(uploader)south on %(upload_date)s in %(playlist)southward.%(ext)s' https://www.youtube.com/watch?v=7E-cwdnsiow
two.two. Download multiple videos
Sometimes, you might want to download multiple videos from or any other site. If so, just mention the URL of the videos with space-separated like below:
$ youtube-dl <url1> <url2>
Alternatively, y'all can put them all in a text file and laissez passer it to Youtube-dl as an argument like below.
$ youtube-dl -a url.txt
This command will download all videos mentioned in the url.txt file.
2.3. Download audio-merely from a video
Youtube-dl allows us to download audio merely from a YouTube video. If you ever been in a situation to download but the audio, run:
$ youtube-dl -x https://www.youtube.com/lookout?v=7E-cwdnsiow
By default, Youtube-dl volition salvage the audio in Ogg
(opus) format.
If you adopt to download whatsoever other formats, for example mp3
, run:
$ youtube-dl -ten --sound-format mp3 https://www.youtube.com/watch?v=7E-cwdnsiow
This command will download the audio from the given video/playlist, catechumen it to an MP3 and salve it in the current directory. Please note that you should install either ffmpeg
or avconv
to convert the file to mp3 format.
2.iv. Download video with clarification, metadata, annotations, subtitles and thumbnail
To download a video along with its other details such as description, metadata, annotations, subtitles, and thumbnail etc., use the following command:
$ youtube-dl --write-description --write-info-json --write-annotations --write-sub --write-thumbnail https://www.youtube.com/watch?v=7E-cwdnsiow
2.v. List all bachelor formats of video or playlist
To listing all available formats that a video or playlist is available in, apply the following command:
$ youtube-dl --list-formats https://www.youtube.com/scout?v=7E-cwdnsiow
Or,
$ youtube-dl -F https://www.youtube.com/spotter?v=7E-cwdnsiow
Sample output:
As you lot can meet in the in a higher place screenshot, Youtube-dl lists all bachelor formats of the given video. From left to right, information technology displays the video format lawmaking, extension and resolution note of the respective video. This can be helpful when you want to download a video at a specific quality or format.
2.6. Brandish the size of Youtube videos
To recollect the file size of a video, use -F
flag.
$ youtube-dl -F https://world wide web.youtube.com/spotter?v=7E-cwdnsiow
You will meet the file size at the end of each file.
Sample output:
[youtube] 7E-cwdnsiow: Downloading webpage [info] Available formats for 7E-cwdnsiow: format code extension resolution note 249 webm sound but tiny 51k , opus @ 50k (48000Hz), 2.56MiB 250 webm audio just tiny 68k , opus @ 70k (48000Hz), 3.23MiB 140 m4a audio simply tiny 128k , m4a_dash container, [electronic mail protected] (44100Hz), 7.59MiB 251 webm sound only tiny 137k , opus @160k (48000Hz), six.12MiB 160 mp4 192x144 144p 52k , avc1.4d400c, 30fps, video simply, i.71MiB 278 webm 192x144 144p 73k , webm container, vp9, 30fps, video only, 3.73MiB 133 mp4 320x240 240p 89k , avc1.4d400d, 30fps, video only, 3.12MiB 242 webm 320x240 240p 135k , vp9, 30fps, video only, 6.06MiB 134 mp4 480x360 360p 215k , avc1.4d401e, 30fps, video only, vii.53MiB 243 webm 480x360 360p 242k , vp9, 30fps, video only, 10.39MiB 135 mp4 640x480 480p 382k , avc1.4d401e, 30fps, video only, 14.13MiB 244 webm 640x480 480p 390k , vp9, 30fps, video only, 16.44MiB 136 mp4 960x720 720p 737k , avc1.4d401f, 30fps, video only, 26.99MiB 247 webm 960x720 720p 770k , vp9, 30fps, video only, 31.12MiB 137 mp4 1440x1080 1080p 1391k , avc1.640028, 30fps, video but, 46.50MiB 248 webm 1440x1080 1080p 1421k , vp9, 30fps, video simply, 52.19MiB 271 webm 1920x1440 1440p 3462k , vp9, 30fps, video only, 111.86MiB xviii mp4 480x360 360p 360k , avc1.42001E, [email protected] 96k (44100Hz), 21.55MiB 22 mp4 960x720 720p 578k , avc1.64001F, [email protected] (44100Hz) (best)
2.seven. Download videos in certain quality and/or format
By default, Youtube-dl will download the best available quality video. Withal, information technology is as well possible to download a video or playlist at a specific quality or format.
YouTube is capable of downloading videos in the post-obit qualities:
- all-time - Select the best quality format of the given file with video and sound.
- worst - Select the worst quality format (both video and sound).
- bestvideo - Select the best quality video-but format (e.g. Dash video). Please notation that it may non be available.
- worstvideo - Select the worst quality video-just format. May not be available.
- bestaudio - Select the best quality audio just-format. May not be available.
- worstaudio - Select the worst quality audio simply-format. May not be bachelor.
For instance, if you want to download best quality format (both sound and video), merely use the following command:
$ youtube-dl -f best https://www.youtube.com/watch?v=7E-cwdnsiow
Similarly, to download sound-just with all-time quality:
$ youtube-dl -f bestaudio https://www.youtube.com/lookout man?v=7E-cwdnsiow
To download worst quality video-only format, utilise the post-obit command:
$ youtube-dl -f worstvideo https://www.youtube.com/lookout?v=7E-cwdnsiow
You can also combine different format options like beneath.
$ youtube-dl -f bestvideo+bestaudio https://www.youtube.com/watch?five=7E-cwdnsiow
The above command volition download best quality video-only and best quality audio-only formats and merge them together with ffmpeg
or avconv
. Make certain yous have installed whatsoever 1 of these tools on your organization.
If you don't desire to merge, replace +
(plus) operator with ,
(comma) like below:
$ youtube-dl -f 'bestvideo,bestaudio' https://www.youtube.com/watch?v=7E-cwdnsiow -o '%(title)due south.f%(format_id)s.%(ext)s'
This control will download best quality video and best quality audio and volition not mix them. In this instance, you lot will get 2 files, i is audio and another is video. In this instance, an output template ( -o
option) is recommended as bestvideo and bestaudio may take the aforementioned file proper name.
We can even download a video or playlist at a specific quality with specific resolution.
For example, the following command will download the best quality video in 480 pixel resolution (less than or equal to 480p).
$ youtube-dl -f "best[superlative<=480]" https://www.youtube.com/watch?v=7E-cwdnsiow
Like already said, nosotros tin group the format selectors to get a specific quality video. The following command volition download best format available(both audio and video) but no amend than 480p.
$ youtube-dl -f 'bestvideo[height<=480]+bestaudio/best[pinnacle<=480]' https://www.youtube.com/watch?v=7E-cwdnsiow
ii.eight. Download videos using format code
All videos accept format codes which nosotros tin use to download a video at specific quality.
To find the format lawmaking, but list the available formats using any ane of the following commands:
$ youtube-dl --listing-formats https://www.youtube.com/watch?v=7E-cwdnsiow
Or
$ youtube-dl -F https://www.youtube.com/watch?5=7E-cwdnsiow
As you can see in the to a higher place screenshot, all format codes of the given video are listed in the first column. The best quality format is given at the end (the format lawmaking is 22
). So, the command to download best quality format is:
$ youtube-dl -f 22 https://www.youtube.com/watch?v=7E-cwdnsiow
Some videos may not accept the same formats bachelor while you download videos from playlist. In such cases, y'all can specify multiple format codes in whatsoever preferred lodge of your choice. Take a look at the following case:
$ youtube-dl -f 22/17/18 <playlist_url>
Every bit per the above example, Youtube-dl will download the videos in format 22
if it is available.
If the format 22
is not available, it volition then download format 17
if it is available.
If both 22
and 17
formats are not bachelor, it will finally endeavor to download format eighteen
.
If none of the specified formats are available, Youtube-dl will mutter that no suitable formats are available for download.
Please note that that slash is left-associative, i.e. formats on the left hand side are preferred.
ii.9. Download videos by file extension
Download video(s) in your preferred format, say for example MP4, only run:
$ youtube-dl --format mp4 https://world wide web.youtube.com/picket?5=7E-cwdnsiow
Or,
$ youtube-dl -f mp4 https://www.youtube.com/picket?5=7E-cwdnsiow
Like I already mentioned in the previous section, some videos may not available in your preferred formats. In such cases, Youtube-dl will download any other best available formats.
For instance, the following command will download best quality MP4 format file. If MP4 format is non available, then it will download any other best available format.
$ youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/all-time' https://world wide web.youtube.com/spotter?5=7E-cwdnsiow
If you lot desire to download them with custom filename, do:
$ youtube-dl -f mp4 -o '%(championship)s.f%(format_id)due south.%(ext)southward' https://www.youtube.com/watch?five=7E-cwdnsiow
2.ten. Set size limit for videos
When you download multiple videos from a playlist, you might want to download videos within a certain size only.
For example, this control will not download any videos smaller than the given size, say 100MB:
$ youtube-dl --min-filesize 100M <playlist_url>
If you don't want to download videos larger than the given size, do:
$ youtube-dl --max-filesize 100M <playlist_url>
We tin can as well combine format choice operators to download certain size videos.
The post-obit control will download best video-just format merely non bigger than 100 MB.
$ youtube-dl -f 'best[filesize<100M]' https://www.youtube.com/watch?v=7E-cwdnsiow
2.11. Download videos by appointment-wise
Youtube-dl allows us to filter and download video or playlist past their upload date. This will be very helpful when you lot want to download videos from a playlist that contains 100s of videos.
For instance, to download videos uploaded at an exact date, for example October 01, 2018, the command would be:
$ youtube-dl --engagement 20181001 <URL>
Download videos uploaded on or before a specific date:
$ youtube-dl --datebefore 20180101 <URL>
Download videos uploaded on or after a specific date:
$ youtube-dl --dateafter 20180101 <URL>
Download but the videos uploaded in the last 6 months:
$ youtube-dl --dateafter now-6months <URL>
To download videos between a specific engagement, for example January 01, 2018 to January 01, 2019, use the following command:
$ youtube-dl --dateafter 20180101 --datebefore 20190101 <URL>
2.12. Download specific videos from playlist
This is notwithstanding another useful characteristic of Youtube-dl. It allows us to download a specific song(s) from a playlist that contains 100s of songs.
For example, to download the 10th file from a playlist, run:
$ youtube-dl --playlist-items x <playlist_url>
You can besides download and convert the file to other format at the same time. For the the following command will download the 1st file from the playlist and convert it to .mp3
format:
$ youtube-dl --playlist-items 1 -x --audio-format mp3 <playlist_url>
Similarly, to download multiple random files, just specify indices of the videos in the playlist separated past commas similar below::
$ youtube-dl --playlist-items ii,iii,vii,ten <playlist_url>
You can also specify the range of songs. To download a video playlist starting from a certain video, say 10, to finish:
$ youtube-dl --playlist-start 10 <playlist_url>
To download but the files starting from 2nd to fifth in a playlist, use:
$ youtube-dl --playlist-start 2 --playlist-end 5 <playlist_url>
2.xiii. Download just videos suitable for specific age
This is another notable feature of Youtube-dl. It allows us to download only videos suitable for the given age.
Say for example, to download all "Let'due south Play" videos that aren't marked "NSFW" or age-restricted for 7 year-olds from a playlist, run:
$ youtube-dl --friction match-title "let'southward play" --age-limit seven --reject-championship "nsfw" <playlist_url>
2.14. Set download speed limit
You tin can utilise -r option to limit the speed. For example, the following control volition limit the speed to 50K
.
$ youtube-dl -r 50K <URL>
Note that speed is specified in bytes per second.
two.fifteen. Resume downloads
Past default, youtube-dl will automatically resume the download where yous left it off. If it is doesn't resume the download for whatsoever reason, just forcefulness the resume of partially downloaded files with -c
, --continue
flag:
$ youtube-dl -c <URL>
2.sixteen. Display Youtube-dl help
Youtube-dl has a lot more options. I guess these examples are just plenty to utilize Youtube-dl to download videos from online. For more details, refer Youtube-dl help section.
$ youtube-dl --help
3. Youtube-dl Troubleshooting
Here are some common errors that you lot might come across from time to time. Most errors volition go stock-still themselves after updating the youtube-dl to its most recent version.
Even so, a few errors like below volition not get fixed even if you're using an updated youtube-dl version.
3.i. Fix "Unable to download video data: HTTP Error 403: Forbidden" Error
When downloading videos from YouTube, sometimes you volition become an mistake like below.
ERROR: unable to download video data: HTTP Fault 403: Forbidden
To ready this error, refer the following guide.
- How To Fix "Unable to download video data: HTTP Error 403: Forbidden" Error
three.2. Warning: Requested formats are incompatible for merge and will be merged into mkv
This is another common error. When you download a video, you will become an error like below:
[youtube] _XEgknKEBws: Downloading webpage Alert: Requested formats are incompatible for merge and will exist merged into mkv. ERROR: unable to open for writing: [Errno 36] File name too long: '\xe0\xae\xa8\xe0\xaf\x8b\xe0\xae\xaf\xe0\xaf\x8d \xe0\xae\x8e\xe0\xae\xa4\xe0\xae\xbf\xe0\xae\xb0\xe0\xaf\x8d\xe0\xae\xaa\xe0\xaf\x8d\xe0\xae\xaa\xe0\xaf\x81 \xe0\xae\x9a\xe0\xae\x95\xe0\xaf\x8d\xe0\xae\xa4\xe0\xae\xbf\xe0\xae\xaf\xe0\xaf\x88 \xe0\xae\x85\xe0\xae\xa4\xe0\xae\xbf\xe0\xae\x95\xe0\xae\xb0\xe0\xae\xbf\xe0\xae\x95\xe0\xaf\x8d\xe0\xae\x95\xe0\xaf\x81\xe0\xae\xae\xe0\xaf\x8d \xe0\xae\x87\xe0\xae\xaf\xe0\xae\xb1\xe0\xaf\x8d\xe0\xae\x95\xe0\xaf\x88 \xe0\xae\xaa\xe0\xae\xbe\xe0\xae\xa9\xe0\xae\x95\xe0\xae\xae\xe0\xaf\x8d - \xe0\xae\xa8\xe0\xae\xbe\xe0\xae\xae\xe0\xaf\x87 \xe0\xae\xa4\xe0\xae\xaf\xe0\xae\xbe\xe0\xae\xb0\xe0\xae\xbf\xe0\xae\xaa\xe0\xaf\x8d\xe0\xae\xaa\xe0\xae\xa4\xe0\xaf\x81 \xe0\xae\x8e\xe0\xae\xaa\xe0\xaf\x8d\xe0\xae\xaa\xe0\xae\x9f\xe0\xae\xbf- \xe0\xae\xae\xe0\xae\xb0\xe0\xaf\x81\xe0\xae\xa4\xe0\xaf\x8d\xe0\xae\xa4\xe0\xaf\x81\xe0\xae\xb5\xe0\xae\xb0\xe0\xaf\x8d \xe0\xae\xa4\xe0\xaf\x80\xe0\xae\xaa\xe0\xae\xbe \xe0\xae\xb5\xe0\xae\xbf\xe0\xae\xb3\xe0\xae\x95\xe0\xaf\x8d\xe0\xae\x95\xe0\xae\xae\xe0\xaf\x8d-_XEgknKEBws.f136.mp4.part'
This is actually not a trouble simply an expected beliefs for youtube-dl.
By default, youtube-dl will download the highest quality sound and the highest quality video streams available and and then join them into a compatible container like mkv, mp4 etc.
If these audio and video streams doesn't fit well in an mp4 container, youtube-dl will then pack them in mkv container and display the higher up warning bulletin.
In such cases, you lot can ignore the mkv warning and download the best quality video and the best quality audio but only in an mp4 container by explicitly mentioning the desired best quality audio and video formats like below:
$ youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]' https://youtu.exist/_XEgknKEBws
3.iii. ERROR: unable to open for writing: [Errno 36] File name as well long
When yous effort to download a YouTube video that has long proper name, y'all volition probably get this error:
[youtube] _XEgknKEBws: Downloading webpage Error: unable to open for writing: [Errno 36] File name too long: '\xe0\xae\xa8\xe0\xaf\x8b\xe0\xae\xaf\xe0\xaf\x8d \xe0\xae\x8e\xe0\xae\xa4\xe0\xae\xbf\xe0\xae\xb0\xe0\xaf\x8d\xe0\xae\xaa\xe0\xaf\x8d\xe0\xae\xaa\xe0\xaf\x81 \xe0\xae\x9a\xe0\xae\x95\xe0\xaf\x8d\xe0\xae\xa4\xe0\xae\xbf\xe0\xae\xaf\xe0\xaf\x88 \xe0\xae\x85\xe0\xae\xa4\xe0\xae\xbf\xe0\xae\x95\xe0\xae\xb0\xe0\xae\xbf\xe0\xae\x95\xe0\xaf\x8d\xe0\xae\x95\xe0\xaf\x81\xe0\xae\xae\xe0\xaf\x8d \xe0\xae\x87\xe0\xae\xaf\xe0\xae\xb1\xe0\xaf\x8d\xe0\xae\x95\xe0\xaf\x88 \xe0\xae\xaa\xe0\xae\xbe\xe0\xae\xa9\xe0\xae\x95\xe0\xae\xae\xe0\xaf\x8d - \xe0\xae\xa8\xe0\xae\xbe\xe0\xae\xae\xe0\xaf\x87 \xe0\xae\xa4\xe0\xae\xaf\xe0\xae\xbe\xe0\xae\xb0\xe0\xae\xbf\xe0\xae\xaa\xe0\xaf\x8d\xe0\xae\xaa\xe0\xae\xa4\xe0\xaf\x81 \xe0\xae\x8e\xe0\xae\xaa\xe0\xaf\x8d\xe0\xae\xaa\xe0\xae\x9f\xe0\xae\xbf- \xe0\xae\xae\xe0\xae\xb0\xe0\xaf\x81\xe0\xae\xa4\xe0\xaf\x8d\xe0\xae\xa4\xe0\xaf\x81\xe0\xae\xb5\xe0\xae\xb0\xe0\xaf\x8d \xe0\xae\xa4\xe0\xaf\x80\xe0\xae\xaa\xe0\xae\xbe \xe0\xae\xb5\xe0\xae\xbf\xe0\xae\xb3\xe0\xae\x95\xe0\xaf\x8d\xe0\xae\x95\xe0\xae\xae\xe0\xaf\x8d-_XEgknKEBws.f136.mp4.part
To ready this fault, simply download the video with shorter name of your selection with "-o" flag similar below:
$ youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]' -o video.mp4 https://youtu.be/_XEgknKEBws
Decision
In my opinion, Youtube-dl is undoubtedly one of the best downloader to download audio, video from online. You lot can employ Youtube-dl to download audio and video from hundreds of websites.
I will keep updating this Youtube-dl tutorial when I came across a new Youtube-dl tip. Bookmark and keep visiting information technology once in a while.
If you remember some of import tip is missing, please let me know in the comment department beneath. I will cheque and update this guide accordingly.
Resources:
- Youtube-dl website
- https://jonlabelle.com/snippets/view/shell/youtube-dl-command
DOWNLOAD HERE
Posted by: davidobed1957.blogspot.com
Post a Comment