video-download
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesevideo-download
视频下载
Download video and audio from URLs using yt-dlp directly. No wrapper scripts needed.
直接使用yt-dlp从URL下载视频和音频,无需包装脚本。
Prerequisites
前置要求
- yt-dlp: or
brew install yt-dlppip install yt-dlp - ffmpeg: or
brew install ffmpeg(required for merging video+audio streams)apt install ffmpeg
Update yt-dlp periodically to keep up with site changes: or .
yt-dlp -Upip install -U yt-dlp- yt-dlp:或
brew install yt-dlppip install yt-dlp - ffmpeg:或
brew install ffmpeg(合并视频+音频流时必需)apt install ffmpeg
定期更新yt-dlp以适配平台变化: 或 。
yt-dlp -Upip install -U yt-dlpCommands
命令说明
Download best quality
下载最佳画质视频
bash
yt-dlp "URL" -o "%(title)s.%(ext)s" --merge-output-format mp4bash
yt-dlp "URL" -o "%(title)s.%(ext)s" --merge-output-format mp4Download specific resolution
下载指定分辨率视频
bash
undefinedbash
undefined720p
720p
yt-dlp "URL" -f "bestvideo[height<=720]+bestaudio/best[height<=720]" --merge-output-format mp4
yt-dlp "URL" -f "bestvideo[height<=720]+bestaudio/best[height<=720]" --merge-output-format mp4
1080p
1080p
yt-dlp "URL" -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" --merge-output-format mp4
undefinedyt-dlp "URL" -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" --merge-output-format mp4
undefinedAudio only
仅下载音频
bash
yt-dlp "URL" -x --audio-format mp3 --audio-quality 0bash
yt-dlp "URL" -x --audio-format mp3 --audio-quality 0Download subtitles
下载字幕
bash
undefinedbash
undefinedDownload video with English subtitles
下载带英文字幕的视频
yt-dlp "URL" --write-subs --sub-langs en --merge-output-format mp4
yt-dlp "URL" --write-subs --sub-langs en --merge-output-format mp4
Download video with multiple subtitle languages
下载带多语言字幕的视频
yt-dlp "URL" --write-subs --sub-langs "en,es,fr" --merge-output-format mp4
yt-dlp "URL" --write-subs --sub-langs "en,es,fr" --merge-output-format mp4
Download only subtitles (no video)
仅下载字幕(不下载视频)
yt-dlp "URL" --write-subs --sub-langs en --skip-download
undefinedyt-dlp "URL" --write-subs --sub-langs en --skip-download
undefinedGet metadata (no download)
获取元数据(无需下载)
bash
yt-dlp "URL" --dump-json --no-downloadbash
yt-dlp "URL" --dump-json --no-downloadList available formats
列出可用格式
bash
yt-dlp "URL" -Fbash
yt-dlp "URL" -FSpecify output directory
指定输出目录
bash
yt-dlp "URL" -o "./downloads/%(title)s.%(ext)s" --merge-output-format mp4bash
yt-dlp "URL" -o "./downloads/%(title)s.%(ext)s" --merge-output-format mp4Quality Presets
画质预设
| Quality | Format flag |
|---|---|
| Best | |
| 1080p | |
| 720p | |
| 480p | |
| Worst | |
| 画质 | 格式参数 |
|---|---|
| 最佳 | |
| 1080p | |
| 720p | |
| 480p | |
| 最差 | |
Output Template Variables
输出模板变量
Common variables for templates:
-o| Variable | Description |
|---|---|
| Video title |
| File extension |
| Video ID |
| Channel/uploader name |
| Upload date (YYYYMMDD) |
| Duration in seconds |
| Video resolution |
用于模板的常用变量:
-o| 变量 | 说明 |
|---|---|
| 视频标题 |
| 文件扩展名 |
| 视频ID |
| 频道/上传者名称 |
| 上传日期(YYYYMMDD) |
| 时长(秒) |
| 视频分辨率 |
Tips
小贴士
- Always use to avoid ending up with
--merge-output-format mp4or.webmfiles..mkv - Use with
--no-downloadfor metadata-only queries -- no files written to disk.--dump-json - If a download fails with HTTP errors, update yt-dlp first ().
yt-dlp -U - Use to save bandwidth when full resolution is not needed.
-f "bestvideo[height<=720]+bestaudio" - yt-dlp automatically handles rate limiting and retries.
- The output includes
--dump-json,title,duration,uploader,view_count,description,formats, and much more.subtitles
- 始终使用参数,避免生成
--merge-output-format mp4或.webm格式文件。.mkv - 搭配和
--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
Troubleshooting
故障排查
- "yt-dlp: command not found": Install it () and ensure your PATH includes pip's bin directory.
pip install yt-dlp - "ffmpeg: command not found": Install ffmpeg. Without it, downloads fail when video and audio are separate streams (common on YouTube for HD).
- Downloads fail or return errors: Run to update. Sites change frequently and yt-dlp ships fixes regularly.
yt-dlp -U
- "yt-dlp: command not found":安装yt-dlp()并确保你的PATH包含pip的bin目录。
pip install yt-dlp - "ffmpeg: command not found":安装ffmpeg。如果没有它,当视频和音频流分离时(YouTube高清视频常见情况),下载会失败。
- 下载失败或返回错误:运行更新工具。平台会频繁变化,yt-dlp会定期发布修复补丁。
yt-dlp -U