question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[youtube] `maxresdefault` doesn't exist sometimes

See original GitHub issue

Originally posted by @Zirro here


I’ve received several 404’s for maxresdefault URLs with this change, so unfortunately it doesn’t seem to be true for every video. The best approach would probably be to initially request maxresdefault and look at the response code. If it’s 404, try with hqdefault instead.

It could also be worth using a similar approach to check for the existence of a .webp-version of the thumbnail at the /vi_webp/-path before falling back to the .jpgˋ-version, though the difference in quality doesn’t seem to be very significant here.


Here’s one where there is no maxresdefault size at all: https://www.youtube.com/watch?v=pS4ca4GB-_c

https://i.ytimg.com/vi/pS4ca4GB-_c/maxresdefault.jpg (404) https://i.ytimg.com/vi_webp/pS4ca4GB-_c/maxresdefault.webp (404)

Here’s one where both JPEG and WebP-files are accessible at separate URLs: https://www.youtube.com/watch?v=goSEyGNfiPM

https://i.ytimg.com/vi/goSEyGNfiPM/maxresdefault.jpg (200) https://i.ytimg.com/vi_webp/goSEyGNfiPM/maxresdefault.webp (200)

Here’s one where only the JPEG-file is available: https://www.youtube.com/watch?v=xp-b4Ce4Mf4

https://i.ytimg.com/vi/xp-b4Ce4Mf4/maxresdefault.jpg (200) https://i.ytimg.com/vi_webp/xp-b4Ce4Mf4/maxresdefault.webp (404)

I’m not sure if there are cases where only the WebP exists, though. Besides that it’s mainly a question of whether checking for the .webp first should be done for the theoretical quality improvement, with the .jpg staying as fallback when there is no WebP available.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
pukkandancommented, May 23, 2021

the thumbnail shown in embed is normally the highest resolution one. So I opened https://www.youtube.com/embed/pS4ca4GB-_c and checked the network requests

0reactions
pukkandancommented, Oct 24, 2021

I don’t know why I didn’t think of this before. I can just put the best “known” thumbnail as thumbnail while still populating thumbnails with all possible thumbnails.

Then --get-thumbnail will give you a correct (but not the best) thumbnail without needing to check all the URLs while --write-thumbnail (due to it’s in-build fallback logic) always gives the best quality thumbnail.

If anyone wants to get the best thumbnail URL and don’t mind the slowdown, they can use --print %(thumbnails.-1.url)s --check-all-formats

Read more comments on GitHub >

github_iconTop Results From Across the Web

youtube is not generating maxresdefault.jpg - WordPress.org
Hi At lower resolutions, youtube does not generate ... hqdefault in instances where the maxresdefault doesn't exist, rather than return an image that...
Read more >
YouTube maxresdefault thumbnails - Stack Overflow
I need to use the maxresdefault.jpg, however for a bunch of my videos they simply do not exist. How can I fix this?...
Read more >
[Tips & Tricks] Here's how you can always get maxresdefault ...
Well, you will still occasionally not get the maxresdefault that way. ... After you upload videos, YouTube reencodes them to save resources.
Read more >
YouTube Image Thumbnail URLs - Brian Prom Blog
To the best of my knowledge YouTube doesn't post these image URLs all ... The same logic and image formats exist, you just...
Read more >
Jerma985 - Jerma Lore Wiki - Fandom
Jerma985 (2ndJerma on YouTube), perceived "real" name Jeremy Elbertson and true name ... to a realm of existence that is incomprehensible by the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found