OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Pytube not downloading videos in high quality

  • Thread starter Thread starter Steven Thomas
  • Start date Start date
S

Steven Thomas

Guest
So I've been trying to download YouTube videos in 720p using pytube. This is my code:

Code:
from pytube import YouTube

yt = YouTube('https://www.youtube.com/watch?v=xxxxxxx')

stream = yt.streams.get_by_resolution('720p')
stream.download('static/videos/')

Despite using

Code:
.get_by_resolution('720p')
.get_highest_resolution()
.get_by_itag(22)

The video always downloads in low quality.
When I get more info from Finder settings (using macOS), I get this:

Dimensions: 1280 × 720
Codecs: MPEG-4 AAC, H.264
Colour profile: HD (1-1-1)
Duration: 14:08

See, although it says that I'm getting the correct dimensions for the resolution, the video itself is a lot worse than viewing 720p on YouTube. It looks like 360p. I will attach 2 images to show.

YouTube:
Youtube video image1


Pytube:
Pytube video image2


I don't really understand what's going on to be honest. I've looked quite a bit online and I don't see anyone facing the same issue. Asked ChatGPT as well and it doesn't have a clue either. I also tried using yt-dlp but it resulted in the same lower quality. Any help will be appreciated.

I need a high quality video since I'm going to be doing further encoding which drastically lowers the quality. Even if re-encoded in a very high bitrate, it doesn't help much if the original video is basically 360p.
<p>So I've been trying to download YouTube videos in 720p using pytube. This is my code:</p>
<pre class="lang-py prettyprint-override"><code>from pytube import YouTube

yt = YouTube('
')

stream = yt.streams.get_by_resolution('720p')
stream.download('static/videos/')
</code></pre>
<p>Despite using</p>
<pre class="lang-py prettyprint-override"><code>.get_by_resolution('720p')
.get_highest_resolution()
.get_by_itag(22)
</code></pre>
<p>The video always downloads in low quality.<br />
When I get more info from Finder settings (using macOS), I get this:</p>
<p>Dimensions: 1280 × 720<br />
Codecs: MPEG-4 AAC, H.264<br />
Colour profile: HD (1-1-1)<br />
Duration: 14:08</p>
<p>See, although it says that I'm getting the correct dimensions for the resolution, the video itself is a lot worse than viewing 720p on YouTube. It looks like 360p. I will attach 2 images to show.</p>
<p>YouTube:
<img src="https://i.sstatic.net/pTdGD.png" alt="Youtube video image1" /></p>
<p>Pytube:
<img src="https://i.sstatic.net/kcSZs.png" alt="Pytube video image2" /></p>
<p>I don't really understand what's going on to be honest. I've looked quite a bit online and I don't see anyone facing the same issue. Asked ChatGPT as well and it doesn't have a clue either. I also tried using yt-dlp but it resulted in the same lower quality. Any help will be appreciated.</p>
<p>I need a high quality video since I'm going to be doing further encoding which drastically lowers the quality. Even if re-encoded in a very high bitrate, it doesn't help much if the original video is basically 360p.</p>
 

Latest posts

G
Replies
0
Views
1
Gamal Othman
G
Top