使用youtube-dl,我首先看一下可用的视频质量,然后在第二步中下载最高质量(在本例中为 -f 137+140
) . Youtube-dl会自动合并音频和视频流(DASH格式)
如何使用shell脚本自动化?选择每个视频最高的音频和视频质量?
> youtube-dl -F 'https://www.youtube.com/watch?v=VAdRBLyjLRQ&feature=youtu.be&t=8m14s'
[youtube] Downloading login page
[youtube] Logging in
[youtube] VAdRBLyjLRQ: Downloading webpage
[youtube] VAdRBLyjLRQ: Downloading video info webpage
[youtube] VAdRBLyjLRQ: Extracting video information
[youtube] VAdRBLyjLRQ: Downloading DASH manifest
[youtube] VAdRBLyjLRQ: Downloading DASH manifest
[info] Available formats for VAdRBLyjLRQ:
format code extension resolution note
249 webm audio only DASH audio , opus @ 50k
250 webm audio only DASH audio , opus @ 70k
251 webm audio only DASH audio , opus @160k
171 webm audio only DASH audio 117k , vorbis@128k (44100Hz), 7.68MiB
140 m4a audio only DASH audio 128k , m4a_dash container, aac @128k (44100Hz), 11.58MiB
160 mp4 256x144 DASH video 112k , avc1.4d400c, 15fps, video only, 9.94MiB
278 webm 256x144 DASH video 136k , webm container, VP9, 15fps, video only, 9.10MiB
133 mp4 426x240 DASH video 248k , avc1.4d4015, 30fps, video only, 22.27MiB
242 webm 426x240 DASH video 316k , vp9, 30fps, video only, 22.20MiB
243 webm 640x360 DASH video 557k , vp9, 30fps, video only, 41.05MiB
134 mp4 640x360 DASH video 609k , avc1.4d401e, 30fps, video only, 52.94MiB
244 webm 854x480 DASH video 1021k , vp9, 30fps, video only, 74.05MiB
135 mp4 854x480 DASH video 1115k , avc1.4d401f, 30fps, video only, 97.02MiB
247 webm 1280x720 DASH video 2011k , vp9, 30fps, video only, 150.61MiB
136 mp4 1280x720 DASH video 2282k , avc1.4d401f, 30fps, video only, 189.40MiB
248 webm 1920x1080 DASH video 3838k , vp9, 30fps, video only, 286.61MiB
137 mp4 1920x1080 DASH video 4209k , avc1.640028, 30fps, video only, 354.19MiB
17 3gp 176x144
36 3gp 320x240
5 flv 400x240
43 webm 640x360
18 mp4 640x360
22 mp4 1280x720 (best)
> youtube-dl -f 137+140 'https://www.youtube.com/watch?v=VAdRBLyjLRQ&feature=youtu.be&t=8m14s'
[youtube] Downloading login page
[youtube] Logging in
[youtube] VAdRBLyjLRQ: Downloading webpage
[youtube] VAdRBLyjLRQ: Downloading video info webpage
[youtube] VAdRBLyjLRQ: Extracting video information
(...)
4 回答
我发现了一些奇怪的情况,即使1080p可用,默认情况下(见#5447,#5456)
bestvideo+bestaudio/best
也会下载720p视频 . bitrate on the 720p was very slightly higher 的原因,因此它似乎更好的质量youtube-dl . 我更喜欢更高的res,也是所有其他花哨的youtube下载器应用程序下载的1080p(作为控件) .因此我建议并使用这个:
它将寻找最好的,至少1920宽视频 . 如果没有,它将采用它通常会选择的东西 . 最后/最好的部分是默认配置的一部分 .
在旁注中,我建议将
%(format_id)s
放在文件名中的某处,以便您知道该文件正在使用什么 . 如果您以后想要重新下载一堆视频而不使用存档,使用--no-overwrites
,更好/不同的质量将在旧文件旁边形成一个新文件名(因此您可以比较或其他) .只需使用
-f bestvideo+bestaudio/best
即可获得最高质量的产品 .如果您想更喜欢MP4格式容器而不是WebM,请使用:
-f bestvideo[ext!=webm]+bestaudio[ext!=webm]/best[ext!=webm]
.或者你可以使用,
这将下载最高质量的视频和音频并自动合并 . 而且我想我已经听说过你需要安装ffmpeg才能拥有这种自动行为 . 但我敢打赌,大多数系统已经拥有它 .
使用以下方法检查该特定视频的可用格式:
使用以下方式下载视频:
示例::
这是输出:
然后执行此操作以下载1280 * 720像素的视频::