1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-12-22 16:06:49 +00:00

[youtube] Extract abr and vbr (closes #28100)

This commit is contained in:
Sergey M․ 2021-02-07 01:54:46 +07:00
parent 1641b13232
commit 0156ce95c5
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -500,6 +500,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'uploader': 'AfrojackVEVO', 'uploader': 'AfrojackVEVO',
'uploader_id': 'AfrojackVEVO', 'uploader_id': 'AfrojackVEVO',
'upload_date': '20131011', 'upload_date': '20131011',
'abr': 129.495,
}, },
'params': { 'params': {
'youtube_include_dash_manifest': True, 'youtube_include_dash_manifest': True,
@ -1518,6 +1519,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
if itag: if itag:
itags.append(itag) itags.append(itag)
tbr = float_or_none(
fmt.get('averageBitrate') or fmt.get('bitrate'), 1000)
dct = { dct = {
'asr': int_or_none(fmt.get('audioSampleRate')), 'asr': int_or_none(fmt.get('audioSampleRate')),
'filesize': int_or_none(fmt.get('contentLength')), 'filesize': int_or_none(fmt.get('contentLength')),
@ -1526,8 +1529,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'fps': int_or_none(fmt.get('fps')), 'fps': int_or_none(fmt.get('fps')),
'height': int_or_none(fmt.get('height')), 'height': int_or_none(fmt.get('height')),
'quality': q(quality), 'quality': q(quality),
'tbr': float_or_none(fmt.get( 'tbr': tbr,
'averageBitrate') or fmt.get('bitrate'), 1000),
'url': fmt_url, 'url': fmt_url,
'width': fmt.get('width'), 'width': fmt.get('width'),
} }
@ -1538,7 +1540,13 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
if mobj: if mobj:
dct['ext'] = mimetype2ext(mobj.group(1)) dct['ext'] = mimetype2ext(mobj.group(1))
dct.update(parse_codecs(mobj.group(2))) dct.update(parse_codecs(mobj.group(2)))
if dct.get('acodec') == 'none' or dct.get('vcodec') == 'none': no_audio = dct.get('acodec') == 'none'
no_video = dct.get('vcodec') == 'none'
if no_audio:
dct['vbr'] = tbr
if no_video:
dct['abr'] = tbr
if no_audio or no_video:
dct['downloader_options'] = { dct['downloader_options'] = {
# Youtube throttles chunks >~10M # Youtube throttles chunks >~10M
'http_chunk_size': 10485760, 'http_chunk_size': 10485760,