安装youtubedr
1 2
| brew install youtubedr brew install ffmpeg
|
查看需要下载的视频信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| [liudongkai@MBPR DIR]$ youtubedr info 'https://www.youtube.com/watch?v=aaIUjeg9MpY'
Title: 第五季 | 預告 Trailer【畫江湖之不良人 第5季 The Degenerate-Drawing Jianghu S5】 Author: 畫江湖動畫 Drawing Jianghu Duration: 1m3s
+------+-----+---------+---------+----------+-----------+---------+--------------------------------------------+ | ITAG | FPS | VIDEO | AUDIO | AUDIO | SIZE [MB] | BITRATE | MIMETYPE | | | | QUALITY | QUALITY | CHANNELS | | | | +------+-----+---------+---------+----------+-----------+---------+--------------------------------------------+ | 271 | 25 | 1080p | | 0 | 17.2 | 2298678 | video/webm; codecs="vp9" | | 400 | 25 | 1080p | | 0 | 15.5 | 2075227 | video/mp4; codecs="av01.0.08M.08" | | 137 | 25 | 1080p | | 0 | 11.5 | 1540933 | video/mp4; codecs="avc1.640028" | | 248 | 25 | 1080p | | 0 | 9.3 | 1246099 | video/webm; codecs="vp9" | | 399 | 25 | 1080p | | 0 | 7.3 | 983101 | video/mp4; codecs="av01.0.08M.08" | | 247 | 25 | 720p | | 0 | 5.3 | 710126 | video/webm; codecs="vp9" | | 136 | 25 | 720p | | 0 | 4.6 | 613055 | video/mp4; codecs="avc1.4d401f" | | 398 | 25 | 720p | | 0 | 4.2 | 562648 | video/mp4; codecs="av01.0.05M.08" | | 22 | 25 | 720p | medium | 2 | 5.6 | 742192 | video/mp4; codecs="avc1.64001F, mp4a.40.2" | | 135 | 25 | 480p | | 0 | 2.7 | 356167 | video/mp4; codecs="avc1.4d401e" | | 244 | 25 | 480p | | 0 | 2.9 | 382376 | video/webm; codecs="vp9" | | 18 | 25 | 360p | low | 2 | 3.6 | 487537 | video/mp4; codecs="avc1.42001E, mp4a.40.2" | | 397 | 25 | 480p | | 0 | 2.2 | 298541 | video/mp4; codecs="av01.0.04M.08" | | 134 | 25 | 360p | | 0 | 1.5 | 198119 | video/mp4; codecs="avc1.4d4015" | | 243 | 25 | 360p | | 0 | 1.6 | 216536 | video/webm; codecs="vp9" | | 396 | 25 | 360p | | 0 | 1.2 | 165822 | video/mp4; codecs="av01.0.01M.08" | | 133 | 25 | 240p | | 0 | 0.7 | 100255 | video/mp4; codecs="avc1.4d400d" | | 242 | 25 | 240p | | 0 | 0.8 | 103754 | video/webm; codecs="vp9" | | 251 | 0 | | medium | 2 | 0.9 | 117014 | audio/webm; codecs="opus" | | 140 | 0 | | medium | 2 | 1.0 | 129567 | audio/mp4; codecs="mp4a.40.2" | | 395 | 25 | 240p | | 0 | 0.6 | 86192 | video/mp4; codecs="av01.0.00M.08" | | 160 | 25 | 144p | | 0 | 0.4 | 47400 | video/mp4; codecs="avc1.4d400b" | | 250 | 0 | | low | 2 | 0.4 | 58873 | audio/webm; codecs="opus" | | 278 | 25 | 144p | | 0 | 0.4 | 55883 | video/webm; codecs="vp9" | | 394 | 25 | 144p | | 0 | 0.4 | 48707 | video/mp4; codecs="av01.0.00M.08" | | 249 | 0 | | low | 2 | 0.3 | 44740 | audio/webm; codecs="opus" | +------+-----+---------+---------+----------+-----------+---------+--------------------------------------------+
|
- 第三列的Video Quality,就是你想要下载的视频质量,也就是清晰度
- 最后一列的MIMETYPE告诉你视频的文件类型,一般就选mp4
下载视频
1
| youtubedr download -q 271 'https://www.youtube.com/watch?v=aaIUjeg9MpY'
|
这只是下载了视频。。还没有下载音频!!
第五列 AUDIO CHANNELS 找那些为2的行,
第四行 AUDIO QUALITY 尽量选medium的,
第三行 VIDEO QUALITY 为空的,
最后一列 MIMETYPE 为audio/mp4,
我们定位到质量最好的音频ITAG为 140。
下载音频
1
| youtubedr download -q 140 'https://www.youtube.com/watch?v=aaIUjeg9MpY'
|
现在下载了一个视频和一个音频。。。还差合并这一步,我们得合并下就大功告成了!!
合并视频与音频
1 2 3 4
| # 合并下载的音频与视频 ffmpeg -i '源视频文件.mp4' -i '源音频文件.m4a' -vcodec copy -acodec copy 输出文件.mp4
# 例:ffmpeg -i 'Peru 8K HDR 60FPS (FUHD).mp4' -i 'Peru 8K HDR 60FPS (FUHD).m4a' -vcodec copy -acodec copy output.mp4
|