youtube-dl --proxy "socks5://127.0.0.1/" https://www.youtube.com/watch\?v\=tniqRDvQ4bs
youtube-dl --no-check-certificate --proxy 127.0.0.1:1086 https://www.youtube.com/watch\?v\=JSLpG_spOBM
youtube-dl -x --audio-format mp3 https://www.youtube.com/watch\?v\=tniqRDvQ4bs
查看视频所有类型,只看不下载
youtube-dl -F [url]
youtube-dl -F http://www.youtube.com/watch?v=BlXaGWbFVKY
它的输出类似于:
Setting language
BlXaGWbFVKY: Downloading video webpage
BlXaGWbFVKY: Downloading video info webpage
BlXaGWbFVKY: Extracting video information<
Available formats:
37 : mp4 [1080×1920]
46 : webm [1080×1920]
22 : mp4 [720×1280]
45 : webm [720×1280]
35 : flv [480×854]
44 : webm [480×854]
34 : flv [360×640]
18 : mp4 [360×640]
43 : webm [360×640]
5 : flv [240×400]
17 : mp4 [144×176]
在可用的视频格式中,选择你需要的一种。例如,如果你想下载 MP4 格式的,你可以:
youtube-dl -f 17 http://www.youtube.com/watch?v=BlXaGWbFVKY
或者
youtube-dl --list-formats [url]
这是一个列清单参数,执行后并不会下载视频,但能知道这个目标视频都有哪些格式存在,这样就可以有选择的下载啦!
下载指定质量的视频和音频并自动合并
youtube-dl -f [format code] [url]
通过上一步获取到了所有视频格式的清单,最左边一列就是编号对应着不同的格式.
由于YouTube的1080p及以上的分辨率都是音视频分离的,所以我们需要分别下载视频和音频,可以使用137+140这样的组合.
如果系统中安装了ffmpeg的话, youtube-dl 会自动合并下下好的视频和音频, 然后自动删除单独的音视频文件