最近使用idm下载视频受限

youtube-dl官网

安装

去上面官网下载exe执行,或者使用pip install youtube-dl

查看油管视频的所有格式

'youtube-dl -F 油管链接'

λ youtube-dl -F  https://www.youtube.com/watch?v=JzMgbimJfrc
[youtube] JzMgbimJfrc: Downloading webpage
[youtube] JzMgbimJfrc: Downloading video info webpage
[info] Available formats for JzMgbimJfrc:
format code  extension  resolution note
249          webm       audio only DASH audio   62k , opus @ 50k, 5.89MiB
250          webm       audio only DASH audio   80k , opus @ 70k, 7.57MiB
140          m4a        audio only DASH audio  131k , m4a_dash container, mp4a.40.2@128k, 14.44MiB
251          webm       audio only DASH audio  151k , opus @160k, 14.61MiB
160          mp4        256x138    144p  112k , avc1.4d400c, 24fps, video only, 6.35MiB
278          webm       256x138    144p  145k , webm container, vp9, 24fps, video only, 9.97MiB
242          webm       426x230    240p  215k , vp9, 24fps, video only, 13.89MiB
133          mp4        426x230    240p  241k , avc1.4d4015, 24fps, video only, 10.17MiB
243          webm       640x346    360p  390k , vp9, 24fps, video only, 22.73MiB
134          mp4        640x346    360p  462k , avc1.4d401e, 24fps, video only, 18.60MiB
244          webm       854x460    480p  715k , vp9, 24fps, video only, 33.68MiB
135          mp4        854x460    480p  743k , avc1.4d401e, 24fps, video only, 28.25MiB
136          mp4        1280x690   720p 1161k , avc1.4d401f, 24fps, video only, 44.11MiB
247          webm       1280x690   720p 1443k , vp9, 24fps, video only, 58.74MiB
248          webm       1920x1036  1080p 2557k , vp9, 24fps, video only, 161.87MiB
137          mp4        1920x1036  1080p 4345k , avc1.640028, 24fps, video only, 154.62MiB
43           webm       640x360    medium , vp8.0, vorbis@128k, 75.02MiB
18           mp4        640x344    medium  456k , avc1.42001E, mp4a.40.2@ 96k (44100Hz), 50.94MiB
22           mp4        1280x690   hd720  524k , avc1.64001F, mp4a.40.2@192k (44100Hz) (best)

下载

youtube-dl -f format-code 油管链接

youtube-dl -f 137+251  https://www.youtube.com/watch?v=JzMgbimJfrc

137+251分别为视频和音频的format-code,对比看看上面-F命令。使用通常以视频format-code/137开头

不查看解析度,直接下载最高解析度视频,命令:

youtube-dl -f bestvideo+bestaudio https://www.youtube.com/watch?v=JzMgbimJfrc

选择的视频的解析度超过720p,比如:format code为'160-247',如果系统没有安装ffmpeg/convert,下载的视频不会合并,是音频和视频分离的。

下载hd720格式

使用-F命令可以看到hd720解析度是最后一个,下载命令:

youtube-dl -f best https://www.youtube.com/watch?v=JzMgbimJfrc
//
youtube-dl -f 22 https://www.youtube.com/watch?v=JzMgbimJfrc

当然,也可以在youtube-dl后直接加上油管链接

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

合并音视频

已经下载成功的音视频应该怎么合并呢?
ffmpeg -i 视频 -i 音频 -c:v copy -c:a aac -strict experimental 合并后视频名

D:\ffmpeg\bin\ffmpeg.exe -i 百元之恋.mp4 -i 百元之恋.webm -c:v copy -c:a aac -strict experimental 百元之恋牛叔解说.mp4 && rm 百元之恋.*

字幕

–write-sub:加入字幕文件 –all-subs:如果有字幕存在则全部下载