비디오 다운로드은(는) 무엇을 하나요?
URL에서 yt-dlp를 직접 사용하여 비디오와 오디오를 다운로드합니다. 래퍼 스크립트가 필요 없습니다.
전제 조건
- yt-dlp:
brew install yt-dlp또는pip install yt-dlp - ffmpeg:
brew install ffmpeg또는apt install ffmpeg(비디오+오디오 스트림 병합에 필요)
사이트 변경에 대응하기 위해 yt-dlp를 정기적으로 업데이트하세요: yt-dlp -U 또는 pip install -U yt-dlp
명령어
최고 품질 다운로드
yt-dlp "URL" -o "%(title)s.%(ext)s" --merge-output-format mp4
특정 해상도 다운로드
# 720p
yt-dlp "URL" -f "bestvideo[height<=720]+bestaudio/best[height<=720]" --merge-output-format mp4
# 1080p
yt-dlp "URL" -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" --merge-output-format mp4
오디오만
yt-dlp "URL" -x --audio-format mp3 --audio-quality 0
자막 다운로드
# 영어 자막과 함께 비디오 다운로드
yt-dlp "URL" --write-subs --sub-langs en --merge-output-format mp4
# 여러 언어 자막과 함께 비디오 다운로드
yt-dlp "URL" --write-subs --sub-langs "en,es,fr" --merge-output-format mp4
# 자막만 다운로드 (비디오 제외)
yt-dlp "URL" --write-subs --sub-langs en --skip-download
메타데이터 가져오기 (다운로드 없이)
yt-dlp "URL" --dump-json --no-download
사용 가능한 포맷 목록
yt-dlp "URL" -F
출력 디렉토리 지정
yt-dlp "URL" -o "./downloads/%(title)s.%(ext)s" --merge-output-format mp4
품질 프리셋
| 품질 | 포맷 플래그 |
|---|---|
| 최고 | -f "bestvideo+bestaudio/best" (기본값) |
| 1080p | -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" |
| 720p | -f "bestvideo[height<=720]+bestaudio/best[height<=720]" |
| 480p | -f "bestvideo[height<=480]+bestaudio/best[height<=480]" |
| 최저 | -f "worstvideo+worstaudio/worst" |
출력 템플릿 변수
-o 템플릿에서 사용할 수 있는 일반 변수:
| 변수 | 설명 |
|---|---|
%(title)s | 비디오 제목 |
%(ext)s | 파일 확장자 |
%(id)s | 비디오 ID |
%(uploader)s | 채널/업로더 이름 |
%(upload_date)s | 업로드 날짜 (YYYYMMDD) |
%(duration)s | 재생 시간 (초) |
%(resolution)s | 비디오 해상도 |
팁
.webm또는.mkv파일이 생성되지 않도록 항상--merge-output-format mp4를 사용하세요.- 메타데이터만 필요한 경우
--no-download와 함께--dump-json을 사용하세요. 디스크에 파일이 기록되지 않습니다. - HTTP 오류로 다운로드가 실패하면 먼저 yt-dlp를 업데이트하세요 (
yt-dlp -U). - 전체 해상도가 필요하지 않은 경우
-f "bestvideo[height<=720]+bestaudio"를 사용하여 대역폭을 절약하세요. - yt-dlp는 자동으로 속도 제한과 재시도를 처리합니다.
--dump-json출력에는title,duration,uploader,view_count,description,formats,subtitles등이 포함됩니다.
문제 해결
- "yt-dlp: command not found": 설치(
pip install yt-dlp)하고 PATH에 pip의 bin 디렉토리가 포함되어 있는지 확인하세요. - "ffmpeg: command not found": ffmpeg를 설치하세요. 설치하지 않으면 YouTube의 HD 비디오처럼 비디오와 오디오가 별도 스트림으로 제공되는 경우 다운로드가 실패합니다.
- 다운로드 실패 또는 오류 발생:
yt-dlp -U를 실행하여 업데이트하세요. 사이트가 자주 변경되며 yt-dlp는 정기적으로 수정 사항을 제공합니다.