Youtube-dl · a complete and powerful command-line video downloader

in #linux7 years ago (edited)

Originally posted on my Blog:
manerosss.wordpress.com

Hi!

youtube-dl is fast, lightweight, feature-rich and command-line-only video downloader.

Don’t be scary for the lack of a GUI, it’s very easy to use even for terminal n00bs!

Here’s why I like it:

  • Extremely easy to use yet it’s a very complete software
  • Soooo many supported websites
  • It can download only the Audio or only the Video
  • it mixes automatically different Video and Audio sources
  • It can download an entire Playlist
  • Or just certain Videos from a Playlist
  • It downloads Subtitles
  • Easy to install and to keep updated
  • Free and Open Source

This is the official website and GitHub page

You can install it from your distro’s Repository (Arch in my case):
# pacman -S youtube-dl

or with this easy command (if your distro doesn’t have it):
sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

if so you’ll then need to update it manually:
youtube-dl -U


Here are some basic commands.
Show the video information:
youtube-dl -F https://youtu.be/Hs0MnhokuPM
or just:
youtube-dl -F Hs0MnhokuPM

At this point you’ll have different audio and video files, on the lest side are the format codes, I noticed that on Youtube they are always the same based on a specific format:

Video (Mp4)
133 = 240p
134 = 360p
135 = 480p
136 = 720p@30fps
137 = 1080p@30fps
298 = 720p@60fps
299 = 1080p@60fps

Audio (m4a)
140 is always the best m4a quality audio track
etc.

There may be also some Webm video and audio but mp4 and m4a should always be there.


To download a video (it will automatically download the best audio/video quality):
youtube-dl Hs0MnhokuPM

If you want a specific quality you can type:
youtube-dl -f 135+140 Hs0MnhokuPM

This will download a 480p video and the best m4a audio track. They’re then automatically mixed together as Mp4 by ffmpeg.
Webm audio and video will be mixed together as Webm, anything else will be mixed as Mkv.

You can easily download only the video or only the audio:
youtube-dl -f 140 Hs0MnhokuPM

The same option can be applied to a Playlist, first you can check some info
youtube-dl -F https://www.youtube.com/playlist?list=PLk8DskRHO_0ZREMFQJAzaMJac66AKPZp_
or just:
youtube-dl -F PLk8DskRHO_0ZREMFQJAzaMJac66AKPZp_

then download every single video with the same Audio/Video quality (if available):
youtube-dl -f 135+140 PLk8DskRHO_0ZREMFQJAzaMJac66AKPZp_

alternatively you can download just a video serie (ex. from video 2 to 5):
youtube-dl -f 135+140 --playlist-start 2 --playlist-end 5 PLk8DskRHO_0ZREMFQJAzaMJac66AKPZp_

or just some random video in a playlist (ex video 1, 3 and from 6 to 9)
youtube-dl -f 135+140 --playlist-items 1,3,6-9 PLk8DskRHO_0ZREMFQJAzaMJac66AKPZp_

Now let’s check the subtitles, to list the available subs:
youtube-dl --list-subs Hs0MnhokuPM

to download them without downloading any video or audio:
youtube-dl --all-subs --skip-download Hs0MnhokuPM

You can also rename a video:
youtube-dl Hs0MnhokuPM -o linux_gameplay


That’s it! There are many other options to suit all needs, try them out!



TA SALÜDE

Sort:  

Thanks for your post and examples. Awesome tool!

Coin Marketplace

STEEM 0.16
TRX 0.13
JST 0.027
BTC 60314.14
ETH 2890.04
USDT 1.00
SBD 2.35