Sam*_*ega 56 youtube youtube-dl
所以我正在尝试使用 youtube-dl 下载整个 youtube 频道。我知道如果您使用 -F 命令,它会为您提供视频质量类型的列表。我的问题是:如何下载所有视频的最佳质量,以便下载不会默认为 460p 或类似的低画质。
kar*_*rel 102
此答案不适用于旧版本的 youtube-dl。您需要将 youtube-dl 更新到最新版本。您可以在 Python 虚拟环境 ( virtualenv ) 中本地安装最新版本的 youtube-dl ,也可以下载最新版本的 youtube-dl 并使用pip( sudo apt remove youtube-dl && sudo apt install python-pip && pip install --user youtube-dl) 进行安装。youtube-dl 也是一个 snap 包。要安装它,请键入:
sudo snap install youtube-dl # 用 snap run youtube-dl 启动它
打开终端并输入:
youtube-dl -f best -ciw -o "%(title)s.%(ext)s" -v <url-of-channel>
Run Code Online (Sandbox Code Playgroud)
... where<url-of-channel>由频道的 URL 替换。
注意:如果您要下载大量视频,则应在开始下载之前将目录更改为要保存视频的目录。
-f, --format FORMAT
video format code. The special name "best" will pick the best quality.
-c, --continue
force resume of partially downloaded files
-i, --ignore-errors
continue on download errors, for example to skip unavailable videos in a channel
-w, --no-overwrites
do not overwrite files
-o, --output
Output filename template, this example functions similarly to the old --title option
-v, --verbose
print various debugging information
Run Code Online (Sandbox Code Playgroud)
smi*_*-eh 12
TL;DR使用该-f 'bestvideo[height>=720]+bestaudio/best'标志来获得更高的分辨率。我使用的完整命令是:
youtube-dl -f "bestvideo[height>=720]+bestaudio/best" -ciw -o "%(title)s.%(ext)s" -v <url-of-channel>
这就是为什么-f best可能不会为您提供最高分辨率的原因。
当您使用该-F标志列出可能的文件格式时,有时会将 360p 格式列为“最佳”,例如:
youtube-dl -F https://www.youtube.com/watch?v=FmZXCqqx6q0
[youtube] FmZXCqqx6q0: Downloading webpage
[info] Available formats for FmZXCqqx6q0:
format code extension resolution note
249 webm audio only tiny 61k , opus @ 50k (48000Hz), 12.74MiB
250 webm audio only tiny 80k , opus @ 70k (48000Hz), 16.87MiB
140 m4a audio only tiny 132k , m4a_dash container, mp4a.40.2@128k (44100Hz), 31.35MiB
251 webm audio only tiny 158k , opus @160k (48000Hz), 33.34MiB
...
244 webm 854x480 480p 271k , vp9, 30fps, video only, 35.05MiB
398 mp4 1280x720 720p 443k , av01.0.05M.08, 30fps, video only, 102.27MiB
247 webm 1280x720 720p 480k , vp9, 30fps, video only, 63.02MiB
136 mp4 1280x720 720p 489k , avc1.4d401f, 30fps, video only, 114.12MiB
18 mp4 640x360 360p 360k , avc1.42001E, 30fps, mp4a.40.2@ 96k (44100Hz), 87.29MiB (best)
Run Code Online (Sandbox Code Playgroud)
如您所见,尽管分辨率较低,但最后一个选项仍被列为最佳选项。我们有几种方法可以解决这个问题,我试图从一个以 720p 上传的频道下载,所以最简单的方法是我使用-f 'bestvideo[height>=720]+bestaudio/best'标志。
根据您的情况,您可能需要使用格式选择器表达式,可能将其从 720 增加到 1080 或选择特定的文件格式,如 mp4。
您将需要安装 ffmpeg 或从 mkv 转换。
| 归档时间: |
|
| 查看次数: |
105616 次 |
| 最近记录: |