Youtube-dl
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, DMCA때문에 깃헙에서 삭제
- 유튜브 다운로더인 Youtube-dl 이 저작권을 침해 했다고 주장
- RIAA(미국 음반산업협회)가 DMCA 저작권 위반공지를 깃헙에 전달하자, 깃헙이 공식 Repo 및 Fork를 차단
- PyPi 모듈은 아직 사용 가능하며, 중국의 Git플랫폼인 Gitee 등에서는 코드 다운로드 가능
- GitLab에 백업 리포지터리 생성됨: https://gitlab.com/ytdl-org/youtube-dl
GitHub, youtube-dl 저장소 복원
- GitHub, youtube-dl 저장소 복원 | GeekNews
- Standing up for developers: youtube-dl is back - The GitHub Blog
EFF가 GitHub에 보낸 공식 서한을 통해서 youtube-dl 이 기술적으로 DMCA 및 TPM 을 위반하지 않았다는 것을 설명하고, GitHub가 이를 받아들여 저장소를 복원하고, 이번 게시중단건과 DMCA 관련된 내용을 정리.
Dependencies
FFmpeg, FFprob, index, list 등을 사용한다.
How to install
pip에 등록되어 있으므로 아래와 같이 설치할 수 있다.
Flags
-
-c
or--continue
- Force resume of partially downloaded files. By default, youtube-dl will resume downloads if possible.
-
-i
or--ignore-errors
- Continue on download errors, for example to skip unavailable vide os in a playlist.
-
-t
or--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
사용 예제 모음.
Format list
아래와 같이 포맷 목록을 확인할 수 있다.
$ 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)
이 후 사용할 퀄리티를 선택하여 아래와 같이 다운로드 받으면 된다. 참고로 위의 예제에서 Best 퀄리티인 22번 포맷을 사용할 경우 -f 22
를 플래그로 추가하면 된다.
Mixing Audio and Video
우선, 다운로드 가능한 해상도 확인:
다음과 같이 출력된다.
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
단순히 재생목록URI를 사용하면 된다.
중요한 점은 playlist
가 URL에 포함되어 있는지 확인해야 한다.
아래와 같이 사용하면 재생 목록 제목을 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
아래와 같이 MP3를 받을 수 있다.
한글 자막 다운로드
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 - 유튜브 영상을 OpenAI Whisper로 자막 생성 해주는 도구
- Yark - 유튜브 아카이빙 도구
- Pinchflat - 셀프호스트 가능한 유튜브 미디어 관리자