aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2021-10-24 18:02:00 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-10-24 18:02:00 +0530
commitf2fe69c7b0d208bdb1f6292b4ae92bc1e1a7444a (patch)
tree1e17462108b16246bcf3f28c9b14ea5462454052
parentfccf502118466bbfde7c5c6dd0279f0dfdb1311c (diff)
downloadhypervideo-pre-f2fe69c7b0d208bdb1f6292b4ae92bc1e1a7444a.tar.lz
hypervideo-pre-f2fe69c7b0d208bdb1f6292b4ae92bc1e1a7444a.tar.xz
hypervideo-pre-f2fe69c7b0d208bdb1f6292b4ae92bc1e1a7444a.zip
Approximate filesize from bitrate
Closes #1400
-rw-r--r--yt_dlp/YoutubeDL.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index 071f2e943..8c8cf7ecb 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -2330,6 +2330,10 @@ class YoutubeDL(object):
format['resolution'] = self.format_resolution(format, default=None)
if format.get('dynamic_range') is None and format.get('vcodec') != 'none':
format['dynamic_range'] = 'SDR'
+ if (info_dict.get('duration') and format.get('tbr')
+ and not format.get('filesize') and not format.get('filesize_approx')):
+ format['filesize_approx'] = info_dict['duration'] * format['tbr'] * (1024 / 8)
+
# Add HTTP headers, so that external programs can use them from the
# json output
full_format_info = info_dict.copy()