Skip to content

A feature-rich command-line audio/video downloader

Approximate filesize from bitrate Closes #1400

pukkandanf2fe69c7b0d2
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index 071f2e9438..8c8cf7ecb6 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()