开源下载工具

youtube-dl 是一款开源下载工具。

代码仓库:GitHub - ytdl-org/youtube-dl: Command-line program to download videos from YouTube.com and other video sitesCommand-line program to download videos from YouTube.com and other video sites - GitHub - ytdl-org/youtube-dl: Command-line program to download videos from YouTube.com and other video sitesicon-default.png?t=N7T8https://github.com/ytdl-org/youtube-dl

安装工具 youtube-dl

在 macOS/Linux下可能过 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

也可以通过 pip 安装 

sudo -H pip install --upgrade youtube-dl

 在 macOS 上也可以通过 brew 安装

brew  install youtube-dl

找到音视频URL

比如 https://www.youtube.com/watch?v=En6BECrSCxg

列出所有格式

更改URL如下,传给youtube-dl,列出所有格式

% /usr/local/bin/youtube-dl -F https://youtu.be/En6BECrSCxg

[youtube] En6BECrSCxg: Downloading webpage

[info] Available formats for En6BECrSCxg:

format code  extension  resolution note

249          webm       audio only tiny   53k , webm_dash container, opus @ 53k (48000Hz), 759.37KiB

250          webm       audio only tiny   69k , webm_dash container, opus @ 69k (48000Hz), 1000.01KiB

140          m4a        audio only tiny  129k , m4a_dash container, mp4a.40.2@129k (44100Hz), 1.81MiB

251          webm       audio only tiny  135k , webm_dash container, opus @135k (48000Hz), 1.89MiB

160          mp4        256x144    144p   64k , mp4_dash container, avc1.4d400c@  64k, 25fps, video only, 921.14KiB

278          webm       256x144    144p   92k , webm_dash container, vp9@  92k, 25fps, video only, 1.29MiB

133          mp4        426x240    240p  129k , mp4_dash container, avc1.4d4015@ 129k, 25fps, video only, 1.80MiB

242          webm       426x240    240p  133k , webm_dash container, vp9@ 133k, 25fps, video only, 1.86MiB

243          webm       640x360    360p  232k , webm_dash container, vp9@ 232k, 25fps, video only, 3.24MiB

134          mp4        640x360    360p  239k , mp4_dash container, avc1.4d401e@ 239k, 25fps, video only, 3.33MiB

244          webm       854x480    480p  335k , webm_dash container, vp9@ 335k, 25fps, video only, 4.68MiB

135          mp4        854x480    480p  352k , mp4_dash container, avc1.4d401e@ 352k, 25fps, video only, 4.91MiB

136          mp4        1280x720   720p  498k , mp4_dash container, avc1.4d401f@ 498k, 25fps, video only, 6.96MiB

247          webm       1280x720   720p  566k , webm_dash container, vp9@ 566k, 25fps, video only, 7.90MiB

248          webm       1920x1080  1080p 1776k , webm_dash container, vp9@1776k, 25fps, video only, 24.78MiB

137          mp4        1920x1080  1080p 1889k , mp4_dash container, avc1.640028@1889k, 25fps, video only, 26.35MiB

18           mp4        640x360    360p  588k , avc1.42001E, 25fps, mp4a.40.2 (44100Hz), 8.21MiB

22           mp4        1280x720   720p  630k , avc1.64001F, 25fps, mp4a.40.2 (44100Hz) (best)

下载

如上所示,仅下载 m4a 格式音频选择 140 ,然后指定要保存的文件名称,在 youtube-dl 命令行上指定参数:

% /usr/local/bin/youtube-dl -f 140 https://youtu.be/En6BECrSCxg  -o /tmp/ZhouShenWanglinmei.m4a

[youtube] En6BECrSCxg: Downloading webpage

[download] Destination: /tmp/ZhouShenWanglinmei.m4a

[download] 100% of 1.81MiB in 00:05

[ffmpeg] Correcting container in "/tmp/ZhouShenWanglinmei.m4a"

下载完成后,查看文件大小,与上面列出的大小相当。

% ls -lh /tmp/ZhouShenWanglinmei.m4a

-rw-r--r--@ 1 shugb  wheel   1.8M Mar 14 09:20 /tmp/ZhouShenWanglinmei.m4a

你可能感兴趣的:(音视频)