python读取视频分辨率_在将它用作python模块时,如何在youtube-dl中列出视频分辨率?...

好吧,我可以在终端中直接使用它来获取视频格式-

$youtube-dl -F "some youtube url"

输出:

[youtube] Setting language

[youtube] P9pzm5b6FFY: Downloading webpage

[youtube] P9pzm5b6FFY: Downloading video info webpage

[youtube] P9pzm5b6FFY: Extracting video information

[info] Available formats for P9pzm5b6FFY:

format code extension resolution note

140 m4a audio only DASH audio , [email protected] (worst)

160 mp4 144p DASH video , video only

133 mp4 240p DASH video , video only

134 mp4 360p DASH video , video only

135 mp4 480p DASH video , video only

136 mp4 720p DASH video , video only

17 3gp 176x144

36 3gp 320x240

5 flv 400x240

43 webm 640x360

18 mp4 640x360

22 mp4 1280x720 (best)

但我想在将youtube-dl用作python中的模块时使用相同的选项.

现在,我不得不猜测并指定下载选项为:

import youtube_dl

options = {

'format': 'bestaudio/best', # choice of quality

'extractaudio' : True, # only keep the audio

'audioformat' : "mp3", # convert to mp3

'outtmpl': '%(id)s', # name the file the ID of the video

'noplaylist' : True, # only download single song, not playlist

}

with youtube_dl.YoutubeDL(options) as ydl:

ydl.download(url)

我不知道哪种格式可用.

但是如果我可以列出可用的格式,那么我可以相应地设置这些选项.

有什么办法可以在python内部使用“ -F”开关吗?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值