youtube-dl 使用 formatid 下载视频
youtube-dl download videos with formatid
------------------------------Format Numbers----------------------------------------------------------------------
- 249 webm audio only DASH audio 52k , opus @ 50k, 629.08KiB
- 250 webm audio only DASH audio 69k , opus @ 70k, 811.98KiB
- 171 webm audio only DASH audio 110k , vorbis@128k, 1.27MiB
- 140 m4a audio only DASH audio 128k , m4a_dash container, mp4a.40.2@128k, 1.56MiB
- 251 webm audio only DASH audio 138k , opus @160k, 1.53MiB
- 278 webm 254x144 144p 82k , webm container, vp9, 13fps, video only, 772.69KiB
- 242 webm 400x226 240p 101k , vp9, 25fps, video only, 884.56KiB
- 160 mp4 254x144 144p 112k , avc1.4d400c, 13fps, video only, 1.31MiB
- 133 mp4 400x226 240p 265k , avc1.4d400d, 25fps, video only, 2.92MiB
- 17 3gp 176x144 small , mp4v.20.3, mp4a.40.2@ 24k
- 36 3gp 320x180 small , mp4v.20.3, mp4a.40.2
- 18 mp4 400x226 medium , avc1.42001E, mp4a.40.2@ 96k
- 43 webm 640x360 medium , vp8.0, vorbis@128k (best)
我想在这样的程序中使用格式数字
import youtube_dl
url = "https://www.youtube.com/watch?v=BaW_jenozKc"
ydl_opts = {
'verbose': True,
'format': 'bestaudio/best', #maybe like this 'formatid'= 22
'outtmpl': '%(title)s-%(id)s.%(ext)s',
'noplaylist': True,
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
我该怎么做
如果你真的想要格式22,那么确实,传入一个22
的format
键。如果 22 不可用,您可以使用 /best
回退到最佳视频格式:
ydl_opts = {
'format': '22/best',
...
------------------------------Format Numbers----------------------------------------------------------------------
- 249 webm audio only DASH audio 52k , opus @ 50k, 629.08KiB
- 250 webm audio only DASH audio 69k , opus @ 70k, 811.98KiB
- 171 webm audio only DASH audio 110k , vorbis@128k, 1.27MiB
- 140 m4a audio only DASH audio 128k , m4a_dash container, mp4a.40.2@128k, 1.56MiB
- 251 webm audio only DASH audio 138k , opus @160k, 1.53MiB
- 278 webm 254x144 144p 82k , webm container, vp9, 13fps, video only, 772.69KiB
- 242 webm 400x226 240p 101k , vp9, 25fps, video only, 884.56KiB
- 160 mp4 254x144 144p 112k , avc1.4d400c, 13fps, video only, 1.31MiB
- 133 mp4 400x226 240p 265k , avc1.4d400d, 25fps, video only, 2.92MiB
- 17 3gp 176x144 small , mp4v.20.3, mp4a.40.2@ 24k
- 36 3gp 320x180 small , mp4v.20.3, mp4a.40.2
- 18 mp4 400x226 medium , avc1.42001E, mp4a.40.2@ 96k
- 43 webm 640x360 medium , vp8.0, vorbis@128k (best)
我想在这样的程序中使用格式数字
import youtube_dl
url = "https://www.youtube.com/watch?v=BaW_jenozKc"
ydl_opts = {
'verbose': True,
'format': 'bestaudio/best', #maybe like this 'formatid'= 22
'outtmpl': '%(title)s-%(id)s.%(ext)s',
'noplaylist': True,
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
我该怎么做
如果你真的想要格式22,那么确实,传入一个22
的format
键。如果 22 不可用,您可以使用 /best
回退到最佳视频格式:
ydl_opts = {
'format': '22/best',
...