使用Youtube-dl+aria2+ffmpeg实现自动下载YouTube的剧集

  • A+
所属分类:随手小记

首先下载Youtube-dl、aria2、ffmpeg的Windows版本

Youtube-dl : https://rg3.github.io/youtube-dl/download.html

Aria2 : https://github.com/aria2/aria2/releases

Ffmpeg : https://www.ffmpeg.org/download.html#build-windows

我这里下载好了这些文件后放在如下位置

D:\Program Files\Windows工具\youtube-dl.exe  单文件
D:\Program Files\Windows工具\aria2c.exe      单文件
D:\Program Files\ffmpeg                     目录

配置应用文件的系统环境变量

使用Youtube-dl+aria2+ffmpeg实现自动下载YouTube的剧集

 

安装好之后来验证下

使用Youtube-dl+aria2+ffmpeg实现自动下载YouTube的剧集

下载测试

–external-downloader aria2c #调用外部下载工具aria2c
–external-downloader-args #外部下载工具指定参数
-x 16 #表示进程数,aria2最高只能16进程
-k 1M #指定块的大小

将所需下载的视频网址一行一个黏贴到test.txt文件中,保存关闭。
使用代码: youtube-dl -ci --batch-file=test.txt --external-downloader aria2c --external-downloader-args "-x 16 -k 1M" 
这样就可以实现列表批量下载

指定下载的路径
如果你已经试过前面的命令了,那就会发现:所下载的视频对应的文件都被放在执行该下载命令的路径下,要修改下载路径很简单:使用参数-o。
youtube-dl -o "绝对路径\%(title)s.%(ext)s"
其中,前半部分的绝对路径是你指定的,后半部分最好是固定的,使用原来的标题作为文件名以及使用原扩展名。

比如把之前的4K30帧的mp4视频下载到H:\youtube_videos内,那么命令就是这样:
youtube-dl -o "H:\youtube_videos\%(title)s.%(ext)s" -f 266+140 https://www.youtube.com/watch?v=1La4QzGeaaQ

137是1080p 30fps、299是1080p 60fps
并且这两个都是只有视频画面的mp4文件,它们都是不带音频的视频。
266是2160p 30fps不带音频的mp4视频
315是2160p 60fps不带音频的webm视频
138是4320p 30fps不带音频的mp4视频
140是128k 44100Hz的m4a音频
PS D:\Download-Test> youtube-dl -F https://www.youtube.com/watch?v=WcCbUbS3W7A
[youtube] WcCbUbS3W7A: Downloading webpage
[youtube] WcCbUbS3W7A: Downloading video info webpage
[info] Available formats for WcCbUbS3W7A:
format code  extension  resolution note
249          webm       audio only DASH audio   68k , opus @ 50k, 14.97MiB
250          webm       audio only DASH audio   89k , opus @ 70k, 18.73MiB
140          m4a        audio only DASH audio  130k , m4a_dash container, mp4a.40.2@128k, 41.22MiB
171          webm       audio only DASH audio  152k , vorbis@128k, 27.43MiB
251          webm       audio only DASH audio  157k , opus @160k, 33.82MiB
278          webm       256x142    144p  110k , webm container, vp9, 25fps, video only, 24.50MiB
160          mp4        256x142    144p  145k , avc1.4d400c, 25fps, video only, 13.04MiB
242          webm       426x238    240p  227k , vp9, 25fps, video only, 31.68MiB
133          mp4        426x238    240p  341k , avc1.4d4015, 25fps, video only, 31.14MiB
243          webm       640x358    360p  427k , vp9, 25fps, video only, 57.05MiB
134          mp4        640x358    360p  668k , avc1.4d401e, 25fps, video only, 62.66MiB
244          webm       854x476    480p  787k , vp9, 25fps, video only, 96.93MiB
135          mp4        854x476    480p 1164k , avc1.4d401e, 25fps, video only, 100.36MiB
247          webm       1280x714   720p 1531k , vp9, 25fps, video only, 195.56MiB
136          mp4        1280x714   720p 2255k , avc1.4d401f, 25fps, video only, 157.24MiB
248          webm       1920x1072  1080p 2680k , vp9, 25fps, video only, 344.00MiB
137          mp4        1920x1072  1080p 3471k , avc1.640028, 25fps, video only, 249.12MiB
17           3gp        176x144    small , mp4v.20.3, mp4a.40.2@ 24k, 23.02MiB
36           3gp        320x178    small , mp4v.20.3, mp4a.40.2, 66.59MiB
18           mp4        640x356    medium , avc1.42001E, mp4a.40.2@ 96k, 133.64MiB
43           webm       640x360    medium , vp8.0, vorbis@128k, 152.63MiB
22           mp4        1280x714   hd720 , avc1.64001F, mp4a.40.2@192k (best)
PS D:\Download-Test> youtube-dl --external-downloader aria2c --external-downloader-args "-x 16" -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio' 'https://www.youtube.com/watch?v=WcCbUbS3W7A'
[youtube] WcCbUbS3W7A: Downloading webpage
[youtube] WcCbUbS3W7A: Downloading video info webpage
[download] Destination: 危机四伏 10 _ 华语谍战佳作“潜伏”2.0版-WcCbUbS3W7A.f137.mp4

12/08 02:22:28 [NOTICE] Downloading 1 item(s)

12/08 02:22:29 [NOTICE] Allocating disk space. Use --file-allocation=none to disable it. See --file-allocation option in man page for more details.
 *** Download Progress Summary as of Sat Dec 08 02:23:29 2018 ***
==========================================================================================================================================
[#c08963 30MiB/249MiB(12%) CN:5 DL:222KiB ETA:16m44s]
FILE: D:/Download-Test/危机四伏 10 _ 华语谍战佳作“潜伏”2.0版-WcCbUbS3W7A.f137.mp4.part
------------------------------------------------------------------------------------------------------------------------------------------

 *** Download Progress Summary as of Sat Dec 08 02:24:30 2018 ***
==========================================================================================================================================
[#c08963 62MiB/249MiB(24%) CN:5 DL:657KiB ETA:4m51s]
FILE: D:/Download-Test/危机四伏 10 _ 华语谍战佳作“潜伏”2.0版-WcCbUbS3W7A.f137.mp4.part
------------------------------------------------------------------------------------------------------------------------------------------

[#c08963 65MiB/249MiB(26%) CN:5 DL:699KiB ETA:4m29s]
12/08 02:24:34 [NOTICE] Shutdown sequence commencing... Press Ctrl-C again for emergency shutdown.

12/08 02:24:34 [NOTICE] Download GID#c0896329e04f2d35 not complete: D:/Download-Test/危机四伏 10 _ 华语谍战佳作“潜伏”2.0版-WcCbUbS3W7A.f137.mp4.part

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
c08963|INPR|   534KiB/s|D:/Download-Test/危机四伏 10 _ 华语谍战佳作“潜伏”2.0版-WcCbUbS3W7A.f137.mp4.part

Status Legend:
(INPR):download in-progress.

aria2 will resume download if the transfer is restarted.
If there are any errors, then see the log file. See '-l' option in help/man page for details.

ERROR: Interrupted by user
PS D:\Download-Test>

使用Youtube-dl+aria2+ffmpeg实现自动下载YouTube的剧集

使用Youtube-dl+aria2+ffmpeg实现自动下载YouTube的剧集

使用Youtube-dl+aria2+ffmpeg实现自动下载YouTube的剧集

lookback

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: