JuanBindez/pytubefix

Incorrect audio bitrate value on itag lookup table of file 'itags.py'

Closed this issue · 1 comments

While trying to get information about a progressive 720p stream(itag 22), the library gave me a value of '192kbps' as the audio bitrate for said stream.

However, as I downloaded the stream and inspected it with ffprobe, it then said that the audio bitrate was 128kbps instead of the 192kbps stated by pytubefix.

So, I decided to investigate further and found out that the culprit of this issue is in pytubefix/itags.py (line 10), and in the lookup table the audio bitrate is set to 192kbps instead of the correct 128kbps value.

I also tried this with 10 random videos and the issue persists.


This is the script to download and get information about the aforementioned stream:

from pytubefix import YouTube

suspect = YouTube(
	'https://www.youtube.com/watch?v=E8gmARGvPlI', # Wham! - Last Christmas
	use_oauth=True,
	allow_oauth_cache=True
).streams.get_by_itag(22)

print('Audio Bitrate:', suspect.abr)

suspect.download()

This is the output of the script:

Audio Bitrate: 192kbps

This is the ffprobe script I used to get information about the video:

ffprobe -hide_banner <filename>.mp4

And this is the output of ffprobe:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '.\Wham! - Last Christmas (Official Video).mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2023-12-21T14:58:19.000000Z
  Duration: 00:04:38.36, start: 0.000000, bitrate: 968 kb/s
  Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 837 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
    Metadata:
      creation_time   : 2023-12-21T14:58:19.000000Z
      handler_name    : ISO Media file produced by Google Inc. Created on: 12/21/2023.
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default) # THIS LINE
    Metadata:
      creation_time   : 2023-12-21T14:58:19.000000Z
      handler_name    : ISO Media file produced by Google Inc. Created on: 12/21/2023.
      vendor_id       : [0][0][0][0]

After searching a bit on the internet I found out itag 22 is meant to be 192kbps, but for some reason it rarely is.
I don't know what the reason might be, but it seems like I've made a mistake.
Sorry if I caused any problems.