Python:使用youtube-dl+ffmpeg+FQ软件下载youtube视频

时间:2023-03-08 15:45:54

声明:本文所述内容都是从http://blog.csdn.net/u011475134/article/details/71023612博文中学习而来。

背景:

一同学想通过FQ软件下载一些youtube的视频,于是我就帮忙找解决方案,发现了上述博客的文章,试了一试果然凑效,就记录下了这一收货。

环境搭建:

本机是win7 x64版本

1)python环境安装:

请参考我的博文《Python:安装mssql模块功能,并实现与sqlserver连接、查询

2)使用pip安装yutube-dl

四方建+r,打开“运行”窗口,窗口中输入cmd,回车进入cmd运行环境下,执行以下安装命令:

pip install youtube-dl
C:\Users\Administrator>pip install youtube-dl
Collecting youtube-dl
Downloading youtube_dl-2017.9.15-py2.py3-none-any.whl (1.6MB)
16% |¨€¨€¨€¨€¨€¨… | 276kB 19kB/s eta 0:01:10
19% |¨€¨€¨€¨€¨€¨€¨? | 317kB 16kB/s eta 0:01:2
20% |¨€¨€¨€¨€¨€¨€¨… | 327kB 12kB/s eta 0:01:
20% |¨€¨€¨€¨€¨€¨€¨? | 337kB 12kB/s eta 0:01:4
21% |¨€¨€¨€¨€¨€¨€¨? | 348kB 14kB/s eta 0:01:3
21% |¨€¨€¨€¨€¨€¨€¨€ | 358kB 14kB/s eta 0:01:3
22% |¨€¨€¨€¨€¨€¨€¨€¨? | 368kB 13kB/s eta 0:01
23% |¨€¨€¨€¨€¨€¨€¨€¨… | 378kB 11kB/s eta 0:0
23% |¨€¨€¨€¨€¨€¨€¨€¨? | 389kB 11kB/s eta 0:01
24% |¨€¨€¨€¨€¨€¨€¨€¨? | 399kB 14kB/s eta 0:01
25% |¨€¨€¨€¨€¨€¨€¨€¨€ | 409kB 11kB/s eta 0:01
25% |¨€¨€¨€¨€¨€¨€¨€¨€¨? | 419kB 12kB/s eta 0:
26% |¨€¨€¨€¨€¨€¨€¨€¨€¨… | 430kB 16kB/s eta 0
26% |¨€¨€¨€¨€¨€¨€¨€¨€¨? | 440kB 16kB/s eta 0:
27% |¨€¨€¨€¨€¨€¨€¨€¨€¨? | 450kB 23kB/s eta 0:
28% |¨€¨€¨€¨€¨€¨€¨€¨€¨€ | 460kB 19kB/s eta 0:
28% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 471kB 23kB/s eta
29% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨… | 481kB 24kB/s eta
30% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 491kB 18kB/s eta
30% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 501kB 20kB/s eta
31% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€ | 512kB 25kB/s eta
31% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 522kB 25kB/s et
32% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨… | 532kB 19kB/s e
33% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 542kB 19kB/s et
33% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 552kB 19kB/s et
34% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€ | 563kB 21kB/s et
35% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 573kB 19kB/s
35% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨… | 583kB 22kB/s
36% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 593kB 24kB/s
36% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 604kB 25kB/s
37% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€ | 614kB 23kB/s
38% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 624kB 21kB/
38% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨… | 634kB 28kB
39% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 645kB 19kB/
40% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 655kB 11kB/
40% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€ | 665kB 11kB/
41% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 675kB 8.9
41% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨… | 686kB 8.
42% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 696kB 8.4
43% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 706kB 6.8
43% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€ | 716kB 7.1
44% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 727kB 6
45% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨… | 737kB
45% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 747kB 6
46% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 757kB 7
46% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€ | 768kB 7
47% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 778kB
48% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨… | 788k
48% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 798kB
49% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 808kB
50% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€ | 819kB
50% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 829
51% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨… | 83
52% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 849
52% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 860
53% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€ | 870
53% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 8
54% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨… |
55% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 9
55% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? | 9
56% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€ | 9
57% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? |
57% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? |
58% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? |
58% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨? |
59% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€ |
60% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨?
60% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨?
61% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨?
62% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨?
62% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€
63% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨?
63% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨?
64% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨?
65% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨?
65% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€
66% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨?
67% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨?
67% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨?
68% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨?
68% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€
69% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨?
70% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨?
70% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨?
71% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨?
72% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€
72% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
73% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
73% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
74% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
75% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
75% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
76% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
77% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
77% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
78% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
78% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
79% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
80% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
80% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
81% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
82% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
82% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
83% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
83% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
84% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
85% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
85% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
86% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
87% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
87% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
88% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
88% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
89% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
90% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
90% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
91% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
92% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
92% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
93% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
93% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
94% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
95% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
95% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
96% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
97% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
97% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
98% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
98% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
99% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨
100% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€
¨€¨€¨€¨€¨€¨€¨€¨€¨€| 1.6MB 5.7kB/s
Installing collected packages: youtube-dl
Successfully installed youtube-dl-2017.9.15

C:\Users\Administrator>

验证是否安装成功:

C:\Users\Administrator>youtube-dl
Usage: youtube-dl [OPTIONS] URL [URL...]

youtube-dl: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.

3)下载ffmpeg组件:

备注:

如果不需要音频与视频文件合并时,是不需要安装该组件的。

官网地址:http://ffmpeg.org/

Python:使用youtube-dl+ffmpeg+FQ软件下载youtube视频

Python:使用youtube-dl+ffmpeg+FQ软件下载youtube视频

下载后,我把它解压到了D盘根目录下D:\ffmpeg-20170915-6743351-win64-static,找到目录:

Python:使用youtube-dl+ffmpeg+FQ软件下载youtube视频

将地址“D:\ffmpeg-20170915-6743351-win64-static\bin”追加到环境变量PATH后边,之后打开cmd运行窗口下运行ffmpeg -version来查看是否安装成功:

Python:使用youtube-dl+ffmpeg+FQ软件下载youtube视频

4)FQ软件下载运行:

同学给的FQ软件,下载后直接解压运行即可,IE下找到它的默认代理ip及端口号,记录下,后边有可能需要使用:

Python:使用youtube-dl+ffmpeg+FQ软件下载youtube视频

使用youtube-dl下载

1)打开“FQ”软件来启用系统代理,系统代理模式设置为全局模式,打开cmd,输入youtube-dl -F youtube视频链接,回车,会显示该视频可以下载的视频格式与分辨率。

youtube-dl -F http://www.youtube.com/watch?v=ozVRGho-cZQ
或者
youtube-dl --proxy socks5://127.0.0.1:8580 -F http://www.youtube.com/watch?v=ozVRGho-cZQ
youtube-dl -f https://www.youtube.com/watch?v=ozVRGho-cZQ
[youtube] ozVRGho-cZQ: Downloading webpage
[youtube] ozVRGho-cZQ: Downloading video info webpage
[youtube] ozVRGho-cZQ: Extracting video information
[youtube] ozVRGho-cZQ: Downloading MPD manifest
[info] Available formats for ozVRGho-cZQ:
format code  extension  resolution note
139          m4a        audio only DASH audio   48k , m4a_dash container, mp4a.40.5@ 48k (22050Hz), 1.51MiB
249          webm       audio only DASH audio   51k , opus @ 50k, 1.55MiB
250          webm       audio only DASH audio   68k , opus @ 70k, 1.98MiB
171          webm       audio only DASH audio  109k , vorbis@128k, 2.89MiB
140          m4a        audio only DASH audio  128k , m4a_dash container, mp4a.40.2@128k (44100Hz), 4.03MiB
251          webm       audio only DASH audio  143k , opus @160k, 4.32MiB
278          webm       256x144    144p  109k , webm container, vp9, 30fps, video only, 2.96MiB
160          mp4        256x144    DASH video  114k , avc1.4d400c, 30fps, video only, 3.50MiB
242          webm       426x240    240p  243k , vp9, 30fps, video only, 5.76MiB
133          mp4        426x240    DASH video  270k , avc1.4d4015, 30fps, video only, 7.80MiB
243          webm       640x360    360p  437k , vp9, 30fps, video only, 10.67MiB
134          mp4        640x360    DASH video  641k , avc1.4d401e, 30fps, video only, 13.68MiB
244          webm       854x480    480p  803k , vp9, 30fps, video only, 19.60MiB
135          mp4        854x480    DASH video 1176k , avc1.4d401f, 30fps, video only, 30.49MiB
247          webm       1280x720   720p 1707k , vp9, 30fps, video only, 42.08MiB
136          mp4        1280x720   DASH video 2349k , avc1.4d401f, 30fps, video only, 64.04MiB
248          webm       1920x1080  1080p 3149k , vp9, 30fps, video only, 79.04MiB
137          mp4        1920x1080  DASH video 4457k , avc1.640028, 30fps, video only, 127.32MiB
17           3gp        176x144    small , mp4v.20.3, mp4a.40.2@ 24k
36           3gp        320x180    small , mp4v.20.3, mp4a.40.2
43           webm       640x360    medium , vp8.0, vorbis@128k
18           mp4        640x360    medium , avc1.42001E, mp4a.40.2@ 96k
22           mp4        1280x720   hd720 , avc1.64001F, mp4a.40.2@192k (best)

其中上边是一个列表:第一列为format code(视频编码格式)、第二列为extension(视频文件扩展名)、第三列为resolution (分辨率)、第四列为note(描述信息)

绿色背景:这些都是单纯的音频(无视频);

黄色背景:这些都是单纯的视频(无声音);

蓝色背景:这些是音频&视频文件。

2)如何下载,借鉴《http://blog.csdn.net/u011475134/article/details/71023612》中的下载脚本:

文件名命名为:run_youtube-dl.bat

@echo off
:start
set /p dir=请输入保存路径:
set dir=%dir:/=\%
pushd %dir%
if /i not %dir%==%cd% goto :start
echo 保存路径:%cd%
:download
set /p input=请输入视频链接:
set input=%input:&=^^^&%
youtube-dl -F %input%
if errorlevel 1 goto :download
set /p code=请输入视频格式编号:
youtube-dl -f %code% %input%
goto :download

因此如果需要简单的下载,就可以直接选择“蓝色背景”这块的视频下载即可,但是这里的分辨率是有限的。

那么,如何实现自定义选择音频和视频本地组合呢?这个将在下边的例子中体现。

其中,如果需要单纯下载一个音频|视频文件,只需要在“请输入视频格式编号”输入“format code”对应的编号就可以。

但是,如果需要下载一个视频和一个音频文件,之后让它们两个文件合并,这就需要再在“请输入视频格式编号” 输入视频文件的“format code”+音频文件的“format code”,既可。

注意:

正是视频和音频文件合并这种情况下才会使用到ffmpeg组件,否则你可以不安装。

实际操作:运行“run_youtube-dl.bat”,之后一步一步的操作即可。

请输入保存路径:E:\湖北
保存路径:E:\湖北
请输入视频链接:https://www.youtube.com/watch?v=ozVRGho-cZQ
[youtube] ozVRGho-cZQ: Downloading webpage
[youtube] ozVRGho-cZQ: Downloading video info webpage
[youtube] ozVRGho-cZQ: Extracting video information
[youtube] ozVRGho-cZQ: Downloading MPD manifest
[info] Available formats for ozVRGho-cZQ:
format code  extension  resolution note
139          m4a        audio only DASH audio   48k , m4a_dash container, mp4a.40.5@ 48k (22050Hz), 1.51MiB
249          webm       audio only DASH audio   51k , opus @ 50k, 1.55MiB
250          webm       audio only DASH audio   68k , opus @ 70k, 1.98MiB
171          webm       audio only DASH audio  109k , vorbis@128k, 2.89MiB
140          m4a        audio only DASH audio  128k , m4a_dash container, mp4a.40.2@128k (44100Hz), 4.03MiB
251          webm       audio only DASH audio  143k , opus @160k, 4.32MiB
278          webm       256x144    144p  109k , webm container, vp9, 30fps, video only, 2.96MiB
160          mp4        256x144    DASH video  114k , avc1.4d400c, 30fps, videoonly, 3.50MiB
242          webm       426x240    240p  243k , vp9, 30fps, video only, 5.76MiB
133          mp4        426x240    DASH video  270k , avc1.4d4015, 30fps, videoonly, 7.80MiB
243          webm       640x360    360p  437k , vp9, 30fps, video only, 10.67MiB
134          mp4        640x360    DASH video  641k , avc1.4d401e, 30fps, videoonly, 13.68MiB
244          webm       854x480    480p  803k , vp9, 30fps, video only, 19.60MiB
135          mp4        854x480    DASH video 1176k , avc1.4d401f, 30fps, videoonly, 30.49MiB
247          webm       1280x720   720p 1707k , vp9, 30fps, video only, 42.08MiB
136          mp4        1280x720   DASH video 2349k , avc1.4d401f, 30fps, videoonly, 64.04MiB
248          webm       1920x1080  1080p 3149k , vp9, 30fps, video only, 79.04MiB
137          mp4        1920x1080  DASH video 4457k , avc1.640028, 30fps, videoonly, 127.32MiB
17           3gp        176x144    small , mp4v.20.3, mp4a.40.2@ 24k
36           3gp        320x180    small , mp4v.20.3, mp4a.40.2
43           webm       640x360    medium , vp8.0, vorbis@128k
18           mp4        640x360    medium , avc1.42001E, mp4a.40.2@ 96k
22           mp4        1280x720   hd720 , avc1.64001F, mp4a.40.2@192k (best)
请输入视频格式编号:160+140
[youtube] ozVRGho-cZQ: Downloading webpage
[youtube] ozVRGho-cZQ: Downloading video info webpage
[youtube] ozVRGho-cZQ: Extracting video information
[youtube] ozVRGho-cZQ: Downloading MPD manifest
[download] Destination: Jimmy and Kevin Hart Visit a Haunted House-ozVRGho-cZQ.f160.mp4
[download]  82.7% of 3.50MiB at 36.22KiB/s ETA 00:17[download] Got server HTTP error: Downloaded 3031024 bytes, expected 3667147 bytes. Retrying (attempt 1 of 10)...
[download] Resuming download at byte 3031024
[download] Destination: Jimmy and Kevin Hart Visit a Haunted House-ozVRGho-cZQ.f160.mp4
[download] 100% of 3.50MiB in 00:25
[download] Destination: Jimmy and Kevin Hart Visit a Haunted House-ozVRGho-cZQ.f140.m4a
[download]  58.2% of 4.03MiB at 30.94KiB/s ETA 00:55[download] Got server HTTP error: Downloaded 2457584 bytes, expected 4222708 bytes. Retrying (attempt 1 of 10)...
[download] Resuming download at byte 2457584
[download] Destination: Jimmy and Kevin Hart Visit a Haunted House-ozVRGho-cZQ.f140.m4a
[download] 100% of 4.03MiB in 00:07
[ffmpeg] Merging formats into "Jimmy and Kevin Hart Visit a Haunted House-ozVRGho-cZQ.mp4"
Deleting original file Jimmy and Kevin Hart Visit a Haunted House-ozVRGho-cZQ.f160.mp4 (pass -k to keep)
Deleting original file Jimmy and Kevin Hart Visit a Haunted House-ozVRGho-cZQ.f140.m4a (pass -k to keep)
请输入视频链接:

本文记录结束。