使用 youtube-dl 下载 1080p 高清视频

请先安装 ffmpeg 以提供必要支持,详情

安装 youtube-dl:

在 UNIX 系统上安装 (Linux, OS X, 等.):

使用 curl 安装:

sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

使用 wget 安装:

sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

使用 pip 安装:

sudo pip install --upgrade youtube_dl

使用 Homebrew 安装:

brew install youtube-dl

输入下面的命令确认签名:

sudo wget https://yt-dl.org/downloads/latest/youtube-dl.sig -O youtube-dl.sig
gpg --verify youtube-dl.sig /usr/local/bin/youtube-dl
rm youtube-dl.sig

获得更多内容请访问项目主页

我们以某个 MV 为例,YouTube 页面,首先看看这个视频有多少格式:

sudo youtube-dl -F https://www.youtube.com/watch?v=ECIU3SQyUU4

输出如下:

 ECIU3SQyUU4: Downloading webpage
 ECIU3SQyUU4: Extracting video information
 ECIU3SQyUU4: Downloading js player do
 ECIU3SQyUU4: Downloading DASH manifest
[info] Available formats for ECIU3SQyUU4:
format code extension resolution  note
171         webm      audio only  DASH audio , audio@128k (worst)
140         m4a       audio only  DASH audio , audio@128k
139         m4a       audio only  DASH audio   49k , audio@ 48k (22050Hz), 1.19MiB
140         m4a       audio only  DASH audio  129k , audio@128k (44100Hz), 3.16MiB
171         webm      audio only  DASH audio  132k , audio@128k (44100Hz), 3.08MiB
172         webm      audio only  DASH audio  191k , audio@256k (44100Hz), 4.33MiB
141         m4a       audio only  DASH audio  255k , audio@256k (44100Hz), 6.27MiB
160         mp4       144p        DASH video , video only
278         webm      256x144     DASH video   96k , webm container, VP9, 1fps, video only, 2.14MiB
160         mp4       256x144     DASH video  111k , 13fps, video only, 2.70MiB
242         webm      240p        DASH video , video only
133         mp4       240p        DASH video , video only
242         webm      426x240     DASH video  223k , 1fps, video only, 4.62MiB
133         mp4       426x240     DASH video  253k , 25fps, video only, 6.00MiB
243         webm      360p        DASH video , video only
134         mp4       360p        DASH video , video only
243         webm      640x360     DASH video  397k , 1fps, video only, 8.30MiB
134         mp4       640x360     DASH video  620k , 25fps, video only, 13.78MiB
244         webm      480p        DASH video , video only
135         mp4       480p        DASH video , video only
244         webm      854x480     DASH video  798k , 1fps, video only, 16.47MiB
135         mp4       854x480     DASH video 1117k , 25fps, video only, 25.52MiB
247         webm      720p        DASH video , video only
136         mp4       720p        DASH video , video only
247         webm      1280x720    DASH video 1476k , 1fps, video only, 30.38MiB
136         mp4       1280x720    DASH video 2246k , 25fps, video only, 49.86MiB
248         webm      1080p       DASH video , video only
137         mp4       1080p       DASH video , video only
248         webm      1920x1080   DASH video 2427k , 1fps, video only, 50.28MiB
137         mp4       1920x1080   DASH video 4176k , 25fps, video only, 96.17MiB
17          3gp       176x144
36          3gp       320x240
5           flv       400x240
43          webm      640x360
18          mp4       640x360
22          mp4       1280x720    (best)

因为这是个音乐 MV,所以音质也可以选最好的,我们想下载 1080p 的 mp4 格式,注意 video 的 ID 是 137,audio 的 ID 是 141

下载的话就运行这个命令:

sudo youtube-dl -f 137+141 https://www.youtube.com/watch?v=ECIU3SQyUU4

一切正常的话,就会输出如下:

 ECIU3SQyUU4: Downloading webpage
 ECIU3SQyUU4: Extracting video information
 ECIU3SQyUU4: Downloading DASH manifest
[download] Destination: Alex Mica - Dalinda (Official Video)-ECIU3SQyUU4.f137.mp4
[download] 100% of 96.17MiB in 00:02
[download] Destination: Alex Mica - Dalinda (Official Video)-ECIU3SQyUU4.f141.m4a
[download] 100% of 6.27MiB in 00:07
[ffmpeg] Merging formats into "Alex Mica - Dalinda (Official Video)-ECIU3SQyUU4.mp4"

然后再用迅雷 10 个线程拖回本地,速度会比你直接本地下载快多了去了,此方法只是用来学习和研究相关工具的使用,请勿下载带版权/版权争议的内容。

参考:通天塔

1