Youtube-dl
lastmod 2025-02-05created 2015-05-1222 edits
youtube-dl is a small command-line program to download videos from YouTube.com and a few more sites. It requires the Python interpreter (2.6, 2.7, or 3.2+), and it is not platform specific. We also provide a Windows executable that includes Python. youtube-dl should work in your Unix box, in Windows or in Mac OS X. It is released to the public domain, which means you can modify it, redistribute it or use it however you like.
The YouTube-DL Takedown
- The YouTube-DL Takedown - Youtube-dl removed from GitHub due to the DMCA
- Claim that the YouTube downloader Youtube-dl infringes copyright
- After the RIAA (Recording Industry Association of America) sent a DMCA copyright violation notice to GitHub, GitHub blocked the official repo and its forks
- The PyPi module is still available, and the code can be downloaded from places such as Gitee, a Chinese Git platform
- Backup repository created on GitLab: https://gitlab.com/ytdl-org/youtube-dl
GitHub restores the youtube-dl repository
- GitHub restores the youtube-dl repository | GeekNews
- Standing up for developers: youtube-dl is back - The GitHub Blog
In an official letter sent to GitHub, the EFF explained that youtube-dl does not technically violate the DMCA or TPM. GitHub accepted this, restored the repository, and summarized this takedown case and DMCA-related matters.
Dependencies
Uses FFmpeg, FFprob, index, list, and so on.
How to install
It is registered on pip, so it can be installed as follows.
Flags
-
-cor--continue - Force resume of partially downloaded files. By default, youtube-dl will resume downloads if possible.
-
-ior--ignore-errors - Continue on download errors, for example to skip unavailable vide os in a playlist.
-
-tor--title - [deprecated] Use title in file name (default)
-
--playlist-start NUMBER - Playlist video to start at (default is 1)
-
--playlist-end NUMBER - Playlist video to end at (default is last)
Example
A collection of usage examples.
Format list
You can check the list of formats as follows.
$ youtube-dl -F http://www.youtube.com/watch?v=P9pzm5b6FFY
[youtube] Setting language
[youtube] P9pzm5b6FFY: Downloading webpage
[youtube] P9pzm5b6FFY: Downloading video info webpage
[youtube] P9pzm5b6FFY: Extracting video information
[info] Available formats for P9pzm5b6FFY:
format code extension resolution note
140 m4a audio only DASH audio , audio@128k (worst)
160 mp4 144p DASH video , video only
133 mp4 240p DASH video , video only
134 mp4 360p DASH video , video only
135 mp4 480p DASH video , video only
136 mp4 720p DASH video , video only
17 3gp 176x144
36 3gp 320x240
5 flv 400x240
43 webm 640x360
18 mp4 640x360
22 mp4 1280x720 (best)
Then choose the quality you want and download it as shown below. For reference, to use format 22, the Best quality in the example above, add -f 22 as a flag.
Mixing Audio and Video
First, check the available resolutions:
The output looks like this.
format code extension resolution note
249 webm audio only tiny 46k , webm_dash container, opus @ 46k (48000Hz), 673.08KiB
250 webm audio only tiny 60k , webm_dash container, opus @ 60k (48000Hz), 877.56KiB
251 webm audio only tiny 120k , webm_dash container, opus @120k (48000Hz), 1.70MiB
140 m4a audio only tiny 129k , m4a_dash container, mp4a.40.2@129k (44100Hz), 1.83MiB
278 webm 80x144 144p 31k , webm_dash container, vp9@ 31k, 30fps, video only, 458.78KiB
160 mp4 80x144 144p 35k , mp4_dash container, avc1.4d400a@ 35k, 30fps, video only, 514.78KiB
242 webm 134x240 144p 70k , webm_dash container, vp9@ 70k, 30fps, video only, 1022.05KiB
133 mp4 134x240 144p 77k , mp4_dash container, avc1.4d400c@ 77k, 30fps, video only, 1.10MiB
243 webm 202x360 240p 129k , webm_dash container, vp9@ 129k, 30fps, video only, 1.83MiB
134 mp4 202x360 240p 191k , mp4_dash container, avc1.4d400d@ 191k, 30fps, video only, 2.71MiB
244 webm 270x480 240p 238k , webm_dash container, vp9@ 238k, 30fps, video only, 3.37MiB
135 mp4 270x480 240p 332k , mp4_dash container, avc1.4d4015@ 332k, 30fps, video only, 4.70MiB
247 webm 404x720 360p 475k , webm_dash container, vp9@ 475k, 30fps, video only, 6.73MiB
136 mp4 404x720 360p 718k , mp4_dash container, avc1.4d401e@ 718k, 30fps, video only, 10.17MiB
302 webm 404x720 360p60 836k , webm_dash container, vp9@ 836k, 60fps, video only, 11.83MiB
298 mp4 404x720 360p60 1088k , mp4_dash container, avc1.4d401f@1088k, 60fps, video only, 15.40MiB
303 webm 608x1080 480p60 1425k , webm_dash container, vp9@1425k, 60fps, video only, 20.17MiB
299 mp4 608x1080 480p60 1823k , mp4_dash container, avc1.640020@1823k, 60fps, video only, 25.81MiB
308 webm 810x1440 720p60 4196k , webm_dash container, vp9@4196k, 60fps, video only, 59.39MiB
315 webm 1072x1906 1080p60 6785k , webm_dash container, vp9@6785k, 60fps, video only, 96.04MiB
18 mp4 202x360 240p 552k , avc1.42001E, 30fps, mp4a.40.2 (44100Hz), 7.82MiB (best)
youtube-dl -f 315 -o video <url>
youtube-dl -f 251 -o audio <url>
ffmpeg -i video -i audio -c:v h264 -c:a aac -map 0:v:0 -map 1:a:0 result.mp4
Playlist download
Simply use the playlist URI.
The important point is to check that playlist is included in the URL.
Use it as follows to use the playlist title as a prefix.
$ youtube-dl -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' -f 22 "https://www.youtube.com/playlist?list=PLlMkM4tgfjnLSOjrEJN31gZATbcj_MpUm"
MP3 Download
You can download MP3 as follows.
Korean subtitle download
Best quality
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]' "https://www.youtube.com/watch?v=C_kooU5i52Q&list=PLv8NImkCqMMU1oziR9nOGMqnV2wVE2EK4"
See also
- YouTube
- FFmpeg
- yt-dlp - A youtube-dl fork with additional features and fixes
- yt-whisper - A tool that generates subtitles for YouTube videos with OpenAI Whisper
- Yark - YouTube archiving tool
- Pinchflat - Self-hostable YouTube media manager
Favorite site
-
youtube-dl web site - GitLab backup repository
- using youtube-dl and ffmpeg/ffplay/ffprobe
- Stackoverflow: How to select video quality from youtube-dl?
- how to download playlist from youtube-dl?
- AVideo
- BriskLimbs
- ClipBucket
- CumulusClips
- DTube
- Emby
- FFmpeg:CLI
- FHV Stream
- Homehost
- Immich
- Jellyfin
- Klopix
- Kodi
- LBRY
- Live Streaming
- Media Streaming
- MediaCMS
- MediaDrop
- MediaGoblin
- MyTube
- Netflix
- OSMC
- Peer2PeerTube
- PeerTube
- Plex
- Plumi
- Podify
- PuMuKIT
- Python:Libraries
- Rutube
- Shareavideo
- Streama
- Tube Archivist
- Tunarr
- VideoHub
- Vidx-video-sharing
- We-TeVe
- Yark
- YouTube
- Yt-dlp
- Yt-fts
- Yt-whisper