github ytdl-org/youtube-dl, usage
How to download Youtube videos on Windows with youtube-dl and start using the command line
首先需要网络自由,推荐一枝红杏出墙来里的广告推荐码:8d50vj3e。
- 安装
pip install --upgrade youtube-dl
- 下载
youtube-dl -F https://www.youtube.com/watch?v=x0uinJvhNxI
列出所有可选择的格式 - 实际执行下载
youtube-dl -f 136 https://www.youtube.com/watch?v=x0uinJvhNxI
下载选择的对应文件到本地(执行命令的目录) - 默认支持断点续传
注意列表中的格式,有些是只有视频没有音频的文件。
youtube-dl -f bestvideo+bestaudio https://www.youtube.com/watch?v=x0uinJvhNxI
报错:
You have requested multiple formats but ffmpeg or avconv are not installed. The formats won't be merged.
这个命令需要本地安装有ffmpeg或avconv(用来自动将音视频合成),可以从这里下载ffmpeg的zip包,解压后将bin目录添加到环境变量。
# check list
# youtube-dl -F https://www.youtube.com/watch?v=x0uinJvhNxI
[youtube] x0uinJvhNxI: Downloading webpage
[info] Available formats for x0uinJvhNxI:
format code extension resolution note
249 webm audio only tiny 63k , opus @ 50k (48000Hz), 123.69MiB
250 webm audio only tiny 75k , opus @ 70k (48000Hz), 154.79MiB
251 webm audio only tiny 130k , opus @160k (48000Hz), 275.97MiB
140 m4a audio only tiny 150k , m4a_dash container, mp4a.40.2@128k (44100Hz), 319.05MiB
160 mp4 256x144 144p 118k , avc1.4d400c, 30fps, video only, 30.87MiB
278 webm 256x144 144p 205k , webm container, vp9, 30fps, video only, 68.27MiB
242 webm 426x240 240p 262k , vp9, 30fps, video only, 92.25MiB
133 mp4 426x240 240p 271k , avc1.4d4015, 30fps, video only, 52.00MiB
243 webm 640x360 360p 432k , vp9, 30fps, video only, 172.66MiB
134 mp4 640x360 360p 680k , avc1.4d401e, 30fps, video only, 106.63MiB
244 webm 854x480 480p 736k , vp9, 30fps, video only, 267.36MiB
135 mp4 854x480 480p 1241k , avc1.4d401f, 30fps, video only, 176.36MiB
247 webm 1280x720 720p 1284k , vp9, 30fps, video only, 497.02MiB
136 mp4 1280x720 720p 1871k , avc1.4d401f, 30fps, video only, 290.41MiB
248 webm 1920x1080 1080p 2332k , vp9, 30fps, video only, 872.66MiB
137 mp4 1920x1080 1080p 3200k , avc1.640028, 30fps, video only, 453.62MiB
22 mp4 1280x720 720p 246k , avc1.64001F, 30fps, mp4a.40.2@192k (44100Hz)
18 mp4 640x360 360p 262k , avc1.42001E, 30fps, mp4a.40.2@ 96k (44100Hz), 647.47MiB (best)
# actual downlaod
youtube-dl -f bestvideo+bestaudio https://www.youtube.com/watch?v=x0uinJvhNxI
[youtube] x0uinJvhNxI: Downloading webpage
[download] Resuming download at byte 337521534
[download] Destination: Flutter Crash Course for Beginners 2020 - Build a Flutter App with Google's Flutter & Dart-x0uinJvhNxI.f137.mp4
[download] 100% of 453.62MiB in 02:08
[download] Destination: Flutter Crash Course for Beginners 2020 - Build a Flutter App with Google's Flutter & Dart-x0uinJvhNxI.f140.m4a
[download] 100% of 319.05MiB in 05:08
[ffmpeg] Merging formats into "Flutter Crash Course for Beginners 2020 - Build a Flutter App with Google's Flutter & Dart-x0uinJvhNxI.mp4"
Deleting original file Flutter Crash Course for Beginners 2020 - Build a Flutter App with Google's Flutter & Dart-x0uinJvhNxI.f137.mp4 (pass -k to keep)
Deleting original file Flutter Crash Course for Beginners 2020 - Build a Flutter App with Google's Flutter & Dart-x0uinJvhNxI.f140.m4a (pass -k to keep)