yt-dlp <video_url>
yt-dlp --list-formats <video_url>
yt-dlp -f "398+140" <video_url>
# 优先下载 MP4,如果没有,则下载最佳画质的其它格式
# 使用默认的 -f 参数
yt-dlp -S "ext" <video_url>
# 或者
yt-dlp -f "bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4] / bv*+ba/b" <video_url>
不关心最终格式,获取「最佳视频流」和「最佳音频流」,合并为一个视频
$ yt-dlp -f "bv+ba/b" <video_url>
# 720P
$ yt-dlp -f "bv[height=720][ext=mp4]+ba[ext=m4a]/b" <video_url>
# 1080P
$ yt-dlp -f "bv[height=1080][ext=mp4]+ba[ext=m4a]/b" <video_url>
# 4K
$ yt-dlp -f "bv[height=2060][ext=mp4]+ba[ext=m4a]/b" <video_url>
yt-dlp --extract-audio --embed-thumbnail --audio-format mp3 <video_url>
yt-dlp --extract-audio --audio-format mp3 <video_url>
# 下载 Playlist 视频列表
yt-dlp --download-archive archive.txt https://www.youtube.com/playlist?list=PLSfsG
# yt-dlp 也支持包括 Bilibili 在内的很多网站
# 其中一个可行的方式是导出 Cookie,Firefox Cookies Text 插件:https://addons.mozilla.org/en-US/firefox/addon/cookies-txt/
yt-dlp --cookies cookies.txt https://www.bilibili.com/video/BV1H44y1w7AX
yt-dlp --proxy socks5://127.0.0.1:10808
# 看看该命令的选项,该命令很强大
$ yt-dlp --proxy socks://192.168.192.103:20170 --list-formats https://www.youtube.com/watch\?v\=JBdWUtBF0b4 | grep mp4
233 mp4 audio only | m3u8 | audio only unknown Default
234 mp4 audio only | m3u8 | audio only unknown Default
139-drc m4a audio only 2 | 51.40MiB 49k https | audio only mp4a.40.5 49k 22k low, DRC, m4a_dash
139 m4a audio only 2 | 51.40MiB 49k https | audio only mp4a.40.5 49k 22k low, m4a_dash
140-drc m4a audio only 2 | 136.42MiB 129k https | audio only mp4a.40.2 129k 44k medium, DRC, m4a_dash
140 m4a audio only 2 | 136.42MiB 129k https | audio only mp4a.40.2 129k 44k medium, m4a_dash
394 mp4 256x144 24 | 49.24MiB 47k https | av01.0.00M.08 47k video only 144p, mp4_dash
269 mp4 256x144 24 | ~187.05MiB 178k m3u8 | avc1.4D400C 178k video only
160 mp4 256x144 24 | 43.34MiB 41k https | avc1.4D400C 41k video only 144p, mp4_dash
603 mp4 256x144 24 | ~216.65MiB 206k m3u8 | vp09.00.11.08 206k video only
395 mp4 426x240 24 | 86.74MiB 82k https | av01.0.00M.08 82k video only 240p, mp4_dash
229 mp4 426x240 24 | ~336.14MiB 319k m3u8 | avc1.4D4015 319k video only
133 mp4 426x240 24 | 92.53MiB 88k https | avc1.4D4015 88k video only 240p, mp4_dash
604 mp4 426x240 24 | ~338.40MiB 321k m3u8 | vp09.00.20.08 321k video only
396 mp4 640x360 24 | 166.45MiB 158k https | av01.0.01M.08 158k video only 360p, mp4_dash
230 mp4 640x360 24 | ~853.99MiB 810k m3u8 | avc1.4D401E 810k video only
134 mp4 640x360 24 | 173.83MiB 165k https | avc1.4D401E 165k video only 360p, mp4_dash
18 mp4 640x360 24 2 | ≈309.70MiB 294k https | avc1.42001E mp4a.40.2 44k 360p
605 mp4 640x360 24 | ~868.45MiB 824k m3u8 | vp09.00.21.08 824k video only
397 mp4 854x480 24 | 253.86MiB 241k https | av01.0.04M.08 241k video only 480p, mp4_dash
231 mp4 854x480 24 | ~ 1.40GiB 1361k m3u8 | avc1.4D401E 1361k video only
135 mp4 854x480 24 | 277.96MiB 264k https | avc1.4D401E 264k video only 480p, mp4_dash
606 mp4 854x480 24 | ~ 1.24GiB 1207k m3u8 | vp09.00.30.08 1207k video only
398 mp4 1280x720 24 | 439.75MiB 417k https | av01.0.05M.08 417k video only 720p, mp4_dash
232 mp4 1280x720 24 | ~ 2.65GiB 2573k m3u8 | avc1.4D401F 2573k video only
136 mp4 1280x720 24 | 470.59MiB 447k https | avc1.4D401F 447k video only 720p, mp4_dash
609 mp4 1280x720 24 | ~ 2.28GiB 2212k m3u8 | vp09.00.31.08 2212k video only
399 mp4 1920x1080 24 | 682.73MiB 648k https | av01.0.08M.08 648k video only 1080p, mp4_dash MiTV4a不能播放
270 mp4 1920x1080 24 | ~ 4.85GiB 4716k m3u8 | avc1.640028 4716k video only MiTV4a能播放
137 mp4 1920x1080 24 | 1.23GiB 1198k https | avc1.640028 1198k video only 1080p, mp4_dash MiTV4a能播放
614 mp4 1920x1080 24 | ~ 4.02GiB 3911k m3u8 | vp09.00.40.08 3911k video only MiTV4a不能播放
yt-dlp --proxy socks://192.168.192.103:20170 -f "137+140" https://www.youtube.com/watch\?v\=JBdWUtBF0b4
[youtube] Extracting URL: https://www.youtube.com/watch?v=JBdWUtBF0b4
[youtube] JBdWUtBF0b4: Downloading webpage
[youtube] JBdWUtBF0b4: Downloading ios player API JSON
[youtube] JBdWUtBF0b4: Downloading mweb player API JSON
[youtube] JBdWUtBF0b4: Downloading m3u8 information
[info] JBdWUtBF0b4: Downloading 1 format(s): 137+140
[download] Destination: 佛教電影⧸ 首楞嚴演義【繁體字幕】大佛頂首楞嚴經 [JBdWUtBF0b4].f137.mp4
[download] 18.8% of 1.23GiB at 10.56MiB/s ETA 01:37[download] Got error: SocksHTTPSConnectionPool(host='rr2---sn-a5mlrnl6.googlevideo.com', port=443): Read timed out.. Retrying (1/10)...
[download] Got error: SocksHTTPSConnectionPool(host='rr2---sn-a5mlrnl6.googlevideo.com', port=443): Read timed out. (read timeout=20.0). Retrying (2/10)...
[download] Got error: SocksHTTPSConnectionPool(host='rr2---sn-a5mlrnl6.googlevideo.com', port=443): Read timed out. (read timeout=20.0). Retrying (3/10)...
[download] Destination: 佛教電影⧸ 首楞嚴演義【繁體字幕】大佛頂首楞嚴經 [JBdWUtBF0b4].f137.mp4
[download] 100% of 1.23GiB in 00:07:04 at 2.97MiB/s
[download] Destination: 佛教電影⧸ 首楞嚴演義【繁體字幕】大佛頂首楞嚴經 [JBdWUtBF0b4].f140.m4a
[download] 100% of 136.42MiB in 00:00:30 at 4.42MiB/s
[Merger] Merging formats into "佛教電影⧸ 首楞嚴演義【繁體字幕】大佛頂首楞嚴經 [JBdWUtBF0b4].mp4"
Deleting original file 佛教電影⧸ 首楞嚴演義【繁體字幕】大佛頂首楞嚴經 [JBdWUtBF0b4].f140.m4a (pass -k to keep)
Deleting original file 佛教電影⧸ 首楞嚴演義【繁體字幕】大佛頂首楞嚴經 [JBdWUtBF0b4].f137.mp4 (pass -k to keep)