如何下载youbube视频

从youtube下载vedio

  1. 首先需要一台国外VPS
  2. 主机上安装 YouTube-DL – A Command Line Video Download Tool

安装youtube-dl命令

安装完成以后的使用介绍:

下载前可以查看视频种类和视频大小,高清程度等如下命令:

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

执行完成以后为:

[youtube] r59xYe3Vyks: Downloading webpage
[youtube] r59xYe3Vyks: Downloading video info webpage
[youtube] r59xYe3Vyks: Extracting video information
[youtube] r59xYe3Vyks: Downloading DASH manifest
[youtube] r59xYe3Vyks: Downloading DASH manifest
[info] Available formats for r59xYe3Vyks:
format code  extension  resolution note
249          webm       audio only DASH audio   51k , opus @ 50k, 4.69MiB
250          webm       audio only DASH audio   71k , opus @ 70k, 6.20MiB
171          webm       audio only DASH audio  101k , vorbis@128k (44100Hz), 9.22MiB
140          m4a        audio only DASH audio  129k , m4a_dash container, mp4a.40.2@128k (44100Hz), 12.09MiB
251          webm       audio only DASH audio  154k , opus @160k, 13.26MiB
141          m4a        audio only DASH audio  256k , m4a_dash container, mp4a.40.2@256k (44100Hz), 24.02MiB
278          webm       256x144    DASH video   52k , webm container, vp9, 15fps, video only, 2.22MiB
242          webm       426x240    DASH video   58k , vp9, 30fps, video only, 2.57MiB
160          mp4        256x144    DASH video  120k , avc1.4d400c, 15fps, video only, 6.18MiB
243          webm       640x360    DASH video  132k , vp9, 30fps, video only, 4.99MiB
134          mp4        640x360    DASH video  177k , avc1.4d401e, 30fps, video only, 4.12MiB
244          webm       854x480    DASH video  236k , vp9, 30fps, video only, 7.97MiB
133          mp4        426x240    DASH video  284k , avc1.4d4015, 30fps, video only, 13.52MiB
135          mp4        854x480    DASH video  367k , avc1.4d401f, 30fps, video only, 7.60MiB
247          webm       1280x720   DASH video  556k , vp9, 30fps, video only, 16.93MiB
136          mp4        1280x720   DASH video  720k , avc1.4d401f, 30fps, video only, 15.02MiB
248          webm       1920x1080  DASH video 1248k , vp9, 30fps, video only, 37.19MiB
137          mp4        1920x1080  DASH video 1540k , avc1.640028, 30fps, video only, 30.15MiB
17           3gp        176x144    small , mp4v.20.3,  mp4a.40.2@ 24k
36           3gp        320x240    small , mp4v.20.3,  mp4a.40.2@ 32k
5            flv        400x240    small , h263, mp3  @ 64k
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)

如上可以看到对应的视频大小,高清程度,类型,如果像选择某一种类型的视频,尝试如下命令:

例如想下载

137 mp4 1920x1080 DASH video 1540k , avc1.640028, 30fps, video only, 30.15MiB

执行命令如下:

youtube-dl -f 137 https://www.youtube.com/watch?v=r59xYe3Vyks

下载完成,输出为:

[root bin]# youtube-dl -f 137 https://www.youtube.com/watch?v=r59xYe3Vyks
[youtube] r59xYe3Vyks: Downloading webpage
[youtube] r59xYe3Vyks: Downloading video info webpage
[youtube] r59xYe3Vyks: Extracting video information
[youtube] r59xYe3Vyks: Downloading DASH manifest
[youtube] r59xYe3Vyks: Downloading DASH manifest
[download] Java Tutorial For Beginners 1 - Introduction and Installing the java (JDK) Step by Step Tutorial-r59xYe3Vyks.mp4 has already been downloaded

[download] 100% of 51.74MiB

[root bin]# ls -l
total 227464
-rw-r--r-- 1 root root 161132802 Jul 27  2014 Java Programming-WPvGqX-TXP0.mp4
-rw-r--r-- 1 root root  16431677 Apr 21  2015 Java Tutorial For Beginners 1 - Introduction and Installing the java (JDK) Step by Step Tutorial-r59xYe3Vyks.flv
-rw-r--r-- 1 root root  54248266 Apr 21  2015 Java Tutorial For Beginners 1 - Introduction and Installing the java (JDK) Step by Step Tutorial-r59xYe3Vyks.mp4
-rwxr-xr-x 1 root root   1095743 Jan 27 03:06 youtube-dl

推荐阅读更多精彩内容