yt-dlp: -F does not give FILESIZE of ID 22

Checklist

Region

No response

Example URLs

https://www.youtube.com/watch?v=BaW_jenozKc

Description

Requesting yt-dlp to also be able to extract file size of -f 22


[debug] Command-line config: ['-v', 'BaW_jenozKc', '-F']
[debug] Encodings: locale cp1252, fs utf-8, out cp1252 (No ANSI), err cp1252 (No ANSI), pref cp1252[debug] yt-dlp version 2021.10.22 (win_exe)
[debug] Optional libraries: Cryptodome, mutagen, sqlite, websockets
[debug] Proxy map: {}
[debug] [youtube] Extracting URL: BaW_jenozKc
[youtube] BaW_jenozKc: Downloading webpage
[youtube] BaW_jenozKc: Downloading android player API JSON
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, codec:vp9.2, lang
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), acodec, lang, filesize, fs_approx, tbr, vbr, abr, asr, proto, vext, aext, hasaud, id
[info] Available formats for BaW_jenozKc:
ID  EXT  RESOLUTION FPS |  FILESIZE    TBR PROTO | VCODEC        VBR ACODEC     ABR  ASR    MORE INFO
--- ---- ---------- --- - ---------- ----- ----- - ----------- ----- --------- ---- ------- -----------------
139 m4a  audio only     |  58.59KiB    48k https |                   mp4a.40.5  48k 22050Hz low, m4a_dash
249 webm audio only     |  58.17KiB    48k https |                   opus       48k 48000Hz low, webm_dash
250 webm audio only     |  76.07KiB    63k https |                   opus       63k 48000Hz low, webm_dash
140 m4a  audio only     |  154.06KiB  127k https |                   mp4a.40.2 127k 44100Hz medium, m4a_dash
251 webm audio only     |  138.96KiB  115k https |                   opus      115k 48000Hz medium, webm_dash
17  3gp  176x144    12  |  55.79KiB    44k https | mp4v.20.3     44k mp4a.40.2   0k 22050Hz 144p
160 mp4  256x144    15  |  135.08KiB  112k https | avc1.4d400c  112k                        144p, mp4_dash
278 webm 256x144    30  |  52.22KiB    43k https | vp9           43k                        144p, webm_dash
133 mp4  426x240    30  |  294.27KiB  245k https | avc1.4d4015  245k                        240p, mp4_dash
242 webm 426x240    30  |  33.27KiB    27k https | vp9           27k                        240p, webm_dash
134 mp4  640x360    30  |  349.59KiB  292k https | avc1.4d401e  292k                        360p, mp4_dash
18  mp4  640x360    30  |  354.29KiB  293k https | avc1.42001E  293k mp4a.40.2   0k 44100Hz 360p
243 webm 640x360    30  |  75.55KiB    62k https | vp9           62k                        360p, webm_dash
135 mp4  854x480    30  |  849.41KiB  710k https | avc1.4d401f  710k                        480p, mp4_dash
244 webm 854x480    30  |  165.49KiB  137k https | vp9          137k                        480p, webm_dash
136 mp4  1280x720   30  |  1.60MiB   1365k https | avc1.4d401f 1365k                        720p, mp4_dash
22  mp4  1280x720   30  |            1493k https | avc1.64001F 1493k mp4a.40.2   0k 44100Hz 720p
247 webm 1280x720   30  |  504.68KiB  420k https | vp9          420k                        720p, webm_dash
137 mp4  1920x1080  30  |  2.11MiB   1803k https | avc1.640028 1803k                        1080p, mp4_dash
248 webm 1920x1080  30  |  965.31KiB  804k https | vp9          804k                        1080p, webm_dash

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 15 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Both issues fixed in a25a424323267e3f6f9f63c0b62df499bd7b8d46 86e3b82261e8ebc6c6707c09544c9dfb8907c0fd

The difference is a bug in tbr calculation:

diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
index d72423272..385232929 100644
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -3834,7 +3834,7 @@ def build_fragments(f):
                             video_id=video_id, only_once=True)
                     throttled = True

-            tbr = float_or_none(fmt.get('averageBitrate') or fmt.get('bitrate'), 1000)
+            tbr = float_or_none(fmt.get('averageBitrate') or fmt.get('bitrate'), 1024)
             language_preference = (
                 10 if audio_track.get('audioIsDefault') and 10
                 else -10 if 'descriptive' in (audio_track.get('displayName') or '').lower() and -10

The bug has gone unnoticed for a long time 140a13f5de1ff8e6bf7ba0d27b38063a2b20fa33

We can derive a very close approximation of the contentLength(the filesize) for itag=22 from this.

This is a good idea. I should be able to do this in general, and not just for youtube