Installing youtube-dl
- Download and install
- Updating
Downloading videos
- Where videos are downloaded
- Basic video download
- Downloading specific qualities
- Downloading qualities by criteria
- Downloading a video's audio only
- Downloading a video and all of its metadata
- Downloading livestreams
- Downloading premium and user-locked videos
- Downloading subscriptions
- Cancelling downloads
- Resuming downloads
Output filename structure
- Typical files
- Unfinished files
Video formats and containers
- Difference between a format, a container, and a file extension
- Web-friendly containers
- Don't be afraid of MKV
Media players
- Recommended media players
- Media players you shouldn't use
C:\Program Files\youtube-dl
, and put the exe there.
cmd
(Command Prompt) or PowerShell, as an administrator and run the following:
setx /M path "%PATH%;C:\Program Files\youtube-dl"Replace the italic text with the folder you put youtube-dl.exe in.
PATH
system property and simplifies updating.
cmd
(the command prompt), or PowerShell, as an administrator.
Once you have it open, run the following command, and accept the license when it prompts you to do so:
choco install youtube-dlAfter that, it should be ready to use.
/usr/local/bin/
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-dlalternatively, you can use
wget
instead of curl
if you don't have it installed:
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
/usr/local/bin/
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-dlalternatively, you can use
wget
instead of curl
if you don't have it installed:
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
sudo apt install youtube-dlUsing Pacman on ArchLinux/Manjaro:
sudo pacman -S youtube-dlIf you don't use any of these distributions, check for a package named
youtube-dl
on your package manager's repositories.
cmd
(Command Prompt) or PowerShell, as an administrator, and run the following command:
choco upgrade youtube-dl
youtube-dl -U
and the program will update itself.
sudo
or some other command to elevate your permissions if that didn't work.
/usr/local/bin/
sudo youtube-dl -U
and the program will update itself.
cd <new location>This will change your folder to the provided location, and until you close that commandline/terminal or change the location again, videos will be downloaded there.
youtube-dl "<URL>"This command will download the video provided at the highest quality possible. This works on both singular videos, OR playlists, entire channels, and more.
youtube-dl -F "<URL>"This will produce something similar to the following:
[info] Available formats for B9RbCdSNoQg: format code extension resolution note 249 webm audio only tiny 64k , opus @ 50k (48000Hz), 11.22MiB 250 webm audio only tiny 81k , opus @ 70k (48000Hz), 15.23MiB 140 m4a audio only tiny 132k , m4a_dash container, mp4a.40.2@128k (44100Hz), 27.84MiB 251 webm audio only tiny 152k , opus @160k (48000Hz), 29.42MiB 394 mp4 256x144 144p 91k , av01.0.00M.08, 30fps, video only, 13.16MiB 278 webm 256x144 144p 97k , webm container, vp9, 30fps, video only, 14.80MiB 160 mp4 256x144 144p 191k , avc1.4d400c, 30fps, video only, 10.52MiB 395 mp4 426x240 240p 218k , av01.0.00M.08, 30fps, video only, 18.97MiB 242 webm 426x240 240p 224k , vp9, 30fps, video only, 20.16MiB 133 mp4 426x240 240p 328k , avc1.4d4015, 30fps, video only, 19.31MiB 396 mp4 640x360 360p 401k , av01.0.01M.08, 30fps, video only, 32.84MiB 243 webm 640x360 360p 411k , vp9, 30fps, video only, 33.20MiB 134 mp4 640x360 360p 603k , avc1.4d401e, 30fps, video only, 34.05MiB 397 mp4 854x480 480p 735k , av01.0.04M.08, 30fps, video only, 55.80MiB 244 webm 854x480 480p 756k , vp9, 30fps, video only, 50.42MiB 135 mp4 854x480 480p 1025k , avc1.4d401f, 30fps, video only, 49.43MiB 398 mp4 1280x720 720p 1497k , av01.0.05M.08, 30fps, video only, 114.65MiB 247 webm 1280x720 720p 1515k , vp9, 30fps, video only, 88.29MiB 136 mp4 1280x720 720p 2238k , avc1.4d401f, 30fps, video only, 85.67MiB 399 mp4 1920x1080 1080p 2630k , av01.0.08M.08, 30fps, video only, 205.52MiB 248 webm 1920x1080 1080p 2664k , vp9, 30fps, video only, 231.49MiB 137 mp4 1920x1080 1080p 6149k , avc1.640028, 30fps, video only, 287.57MiB 18 mp4 640x360 360p 456k , avc1.42001E, 30fps, mp4a.40.2@ 96k (44100Hz), 98.10MiB 22 mp4 1280x720 720p 527k , avc1.64001F, 30fps, mp4a.40.2@192k (44100Hz) (best)It's important to explain the columns in the table the command just spit out.
format code
is the key for this format. When specifying which to download, that's what will be used to select.
extension
defines the container (not format) the quality is stored in.
resolution
is fairly self-explanatory, it defines the video resolution, or is audio only
if the file isn't video.
note
is more ambiguous, but contains some of the most important information.
tiny
if it's audio only.
<audio format> @ <bitrate>k (<full bitrate>Hz), <file size>MiB/KiBIts format for video only is:
<video format>, <frame rate>fps, video only, <file size>MiB/KiBAnd its format for video + audio is:
<video format>, <frame rate>fps, <audio format> @ <bitrate>k (<full bitrate>Hz), <file size>MiB/KiBKeep in mind that not all qualities listed contain both video and audio, and to get the best quality, youtube-dl often has to merge multiple formats together. To the best of my knowledge, the quality that youtube-dl lists as
(best)
here is the best bitrate and resolution file that has both audio and video, but is not the best combination of video-only and audio-only files.
format code
, and run the following:
youtube-dl -f <format code> "<URL>"This will download the specified quality. If you want to download a video with a specific video and audio quality, you can use the
+
operator to combine them.
For example, the following will download specific video and audio qualities, and merge them into one file:
youtube-dl -f "<video format code>+<audio format code>" "<URL>"If the video and audio formats aren't compatible, they will be merged into a single MKV file.
format codes
with either best
(to get the best audio + best video, cannot be combined with another criteria), bestvideo
(best video), or bestaudio
(best audio).
You can also add further qualifications on these terms, such as extension, resolution, etc.
youtube-dl -f "bestaudio" <URL>This will download the best quality, but the result may not be in a typical audio container. If you want to download the audio with a specific extension, you can specify it like so:
youtube-dl -f "bestaudio[ext=m4a]/bestaudio" <URL>This will try to download the best audio with the extension
m4a
.
The /bestaudio
in the example tells youtube-dl to go for the best quality if no quality with the extension m4a
exists.
Without this, it would simply fail if it couldn't find the preferred extension.
youtube-dl --write-annotations --write-description --write-info-json --write-all-thumbnails --write-sub --add-metadata --embed-subs -i <URL>The resulting files will be in the same format as normal files, except their extensions will be different from the video. For example, the metadata will have the extension
json
.
all domains
.
Save the cookies.txt
file where you want to use youtube-dl.
cookies.txt
file, you can specify it along with the URL of the video you want to download:
youtube-dl --cookies cookies.txt <URL>The video should be able to download.
CTRL+C
on the terminal/commandline where youtube-dl is currently running. It will cancel the download.
Partially downloaded files will still be present unless you delete them.
Stories From Our Disturbing World _ Episode 1-B9RbCdSNoQg.mkvThis example was a video named
Stories From Our Disturbing World | Episode 1
, and the filename reflects that, except for the character |
being changed into _
.
This change is because some characters cannot exist in filenames, so youtube-dl is smart enough to replace them with something that is valid.
It's worth mentioning that it doesn't do this with unicode characters like Chinese characters or accented letters, because those types of characters can still exist in filenames.
-
) and then what appears to be a random string of characters. This is the video ID.
Everything after the dash in youtube-dl is the video's ID. This will be different depending on the site, but in this example, this was a video downloaded from YouTube.
Stories From Our Disturbing World _ Episode 1-B9RbCdSNoQg.f137.mp4.partLike the example in the previous sub-section, the video title is present and bad characters are replaced with
_
, and the ID is present.
However, after the ID, there is a period (.
) and another string of seemingly random numbers starting with an f
.
These numbers are actually the format code
of the file being downloaded.
The last notable part of the filename is that it ends with .part
. This signifies that the file has not finished downloading yet.
mkv
is associated with the Matroska container.
.mp4
.
.m4a
.
.webm
.
Artifact - A visual anomaly in videos or images, often caused in video by encoding or decoding issues
Format - A specific way of encoding a piece of media
Container/Container Format - A file format that contains multiple encoded media formats, such as video and audio, or even subtitles
File extension - The simple text following a dot (.
) at the end of a file (for example: .mp4
). In the context of media, this corresponds to media containers and sometimes formats.
Lossless - A type of media that has not lost any quality after being encoded, often at the cost of a larger size
Lossy - A type of media that has lost some quality after being encoded, often being smaller than the original
Compress - To make a piece of media smaller, either by making storage more efficient (in the case of lossless compression), or by losing some quality (in the case of lossy compression)
Encode - To process a piece of media into a format that a computer can understand, often associated with compression