1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-09-03 00:25:08 +00:00

[core] Fix filesize_approx calculation (#9560)

Reverts 22e4dfacb6

Despite being documented as `Kbit/s`, the extractors/manifests were returning bitrates in SI units of kilobits/sec.

Authored by: seproDev, pukkandan
This commit is contained in:
sepro
2024-04-01 01:17:24 +02:00
committed by GitHub
parent e7b17fce14
commit 86e3b82261
6 changed files with 31 additions and 16 deletions

View File

@ -5415,6 +5415,17 @@ class FormatSorter:
return tuple(self._calculate_field_preference(format, field) for field in self._order)
def filesize_from_tbr(tbr, duration):
"""
@param tbr: Total bitrate in kbps (1000 bits/sec)
@param duration: Duration in seconds
@returns Filesize in bytes
"""
if tbr is None or duration is None:
return None
return int(duration * tbr * (1000 / 8))
# XXX: Temporary
class _YDLLogger:
def __init__(self, ydl=None):