Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i download thumbnails in png/jpg format? #28457

Open
3 tasks done
aviv926 opened this issue Mar 15, 2021 · 10 comments
Open
3 tasks done

How can i download thumbnails in png/jpg format? #28457

aviv926 opened this issue Mar 15, 2021 · 10 comments
Labels

Comments

@aviv926
Copy link

aviv926 commented Mar 15, 2021

Checklist

  • I'm asking a question
  • I've looked through the README and FAQ for similar questions
  • I've searched the bugtracker for similar questions including closed ones

Question

Hello, I try to download the thumbnails files in png/jpg format but they are always downloaded by default in webp format.
I'm inserting this code in cmd:

youtube-dl --write-thumbnail [URL playlist]

The files are downloaded directly to the computer in webp format

I tried to add -f:

youtube-dl -f --write-thumbnail [URL playlist]
But it still wouldn't let me choose the format I wanted.

I know there's an commend called:

--write-all-thumbnails
But I don't understand why you can't choose to download in jpg/png format
At the end of the day, it's the same quality.

For example:
https://i.ytimg.com/vi_webp/HOYDj769s6k/maxresdefault.webp

https://i.ytimg.com/vi/HOYDj769s6k/maxresdefault.jpg

It's the same picture with a different extension.

I've seen a report on it before and it's closed, but I didn't understand the solution.

Can someone explain to me where I'm wrong?

@aviv926 aviv926 changed the title hoe can i downlode thumbnails in png/jpeg format? how can i download thumbnails in png/jpg format? Mar 15, 2021
@aviv926 aviv926 changed the title how can i download thumbnails in png/jpg format? How can i download thumbnails in png/jpg format? Mar 15, 2021
@aviv926
Copy link
Author

aviv926 commented Mar 17, 2021

Anyone who can help?

@ghost
Copy link

ghost commented Mar 19, 2021

If you are talking about YouTube's thumbnails, it seems that if you specify a user-agent which doesn't handle webp, you can get maxresdefault.jpg.

$ youtube-dl HOYDj769s6k --get-thumbnail
https://i.ytimg.com/vi_webp/HOYDj769s6k/maxresdefault.webp
$ youtube-dl HOYDj769s6k --get-thumbnail --user-agent curl/7.54.0
https://i.ytimg.com/vi/HOYDj769s6k/maxresdefault.jpg

@nicolaasjan
Copy link

nicolaasjan commented Mar 21, 2021

If you are talking about YouTube's thumbnails, it seems that if you specify a user-agent which doesn't handle webp, you can get maxresdefault.jpg.

I just tried that and noticed that in that case the quality of the image is much worse...
A lot of jpeg artefacts.

@nicolaasjan
Copy link

you can always use dWebP from the Google's WebM project #1 #2, or ffmpeg (which I think is already used in ytdl anyway..), to convert the thumbnail to whatever format that works best for you.

With FFmpeg (Unix commands):

To .jpg:
for i in *.webp; do ffmpeg -i "${i}" -q:v 1 -bsf:v mjpeg2jpeg "${i%.webp}.jpg"; done

To .png:
for i in *.webp; do ffmpeg -i "${i}" "${i%.webp}.png"; done

@aviv926
Copy link
Author

aviv926 commented Sep 30, 2021

you can always use dWebP from the Google's WebM project #1 #2, or ffmpeg (which I think is already used in ytdl anyway..), to convert the thumbnail to whatever format that works best for you.

you can always use dWebP from the Google's WebM project #1 #2, or ffmpeg (which I think is already used in ytdl anyway..), to convert the thumbnail to whatever format that works best for you.

With FFmpeg (Unix commands):

To .jpg: for i in *.webp; do ffmpeg -i "${i}" -q:v 1 -bsf:v mjpeg2jpeg "${i%.webp}.jpg"; done

To .png: for i in *.webp; do ffmpeg -i "${i}" "${i%.webp}.png"; done

Thanks guys!

I'll check it out.
Suggestion I Considered an Increase:
Add an option to choose which format to download thumbnails as can be done with video
I mean it:
youtube-dl -f 'bestvideo + bestaudio / bestvideo + bestaudio' --merge-output-format mp4 [URL]

And turn it into something like this:

youtube-dl.exe --write-thumbnail [ext = jpg/png] --skip-download --output "%(title)s.%(ext)s" [URL HERE]

@nicolaasjan
Copy link

Suggestion I Considered an Increase: Add an option to choose which format to download thumbnails as can be done with video I mean it: youtube-dl -f 'bestvideo + bestaudio / bestvideo + bestaudio' --merge-output-format mp4 [URL]

And turn it into something like this:

youtube-dl.exe --write-thumbnail [ext = jpg/png] --skip-download --output "%(title)s.%(ext)s" [URL HERE]

There is already an option to do this in the yt-dlp fork of this repo. :)
(the development of the youtube-dl repo has come to a standstill since the beginning of June...
See: #29965)

--convert-thumbnails FORMAT
Convert the thumbnails to another format
(currently supported: jpg|png)

So try e.g.:

yt-dlp.exe --skip-download --write-thumbnail --convert-thumbnails jpg https://www.youtube.com/watch?v=Y2T4caGlK80

To convert to highest quality .jpg, append:
--ppa "ThumbnailsConvertor:-q:v 1"
to your command as well (this only works in yt-dlp; not nessessary for .png).

So:

yt-dlp.exe --skip-download --write-thumbnail --convert-thumbnails jpg --ppa "ThumbnailsConvertor:-q:v 1" https://www.youtube.com/watch?v=Y2T4caGlK80

Cat politely asking to get petted  Y2T4caGlK80

@aviv926
Copy link
Author

aviv926 commented Oct 1, 2021

yt-dlp.exe --skip-download --write-thumbnail --convert-thumbnails jpg

Thank you very much bro you helped me!
I did not even know that yt-dlp exists.
Thanks

@Uhter
Copy link

Uhter commented Jun 17, 2023

So:
yt-dlp.exe --skip-download --write-thumbnail --convert-thumbnails jpg --ppa "ThumbnailsConvertor:-q:v 1" https://www.youtube.com/watch?v=Y2T4caGlK80

Thank you @nicolaasjan, this command is perfect.
I made an alias with it ;)

@nicolaasjan
Copy link

So:
yt-dlp.exe --skip-download --write-thumbnail --convert-thumbnails jpg --ppa "ThumbnailsConvertor:-q:v 1" https://www.youtube.com/watch?v=Y2T4caGlK80

Thank you @nicolaasjan, this command is perfect. I made an alias with it ;)

👍️
However, later I found out that even better quality jpg can be achieved with:
--convert-thumbnails jpg --ppa "ThumbnailsConvertor:-qmin 1 -q:v 1"

See top answer at Stack Overflow:

Use -qscale:v (or the alias -q:v) as an output option.

  • Normal range for JPEG is 2-31 with 31 being the worst quality.
  • The scale is linear with double the qscale being roughly half the bitrate.
  • Recommend trying values of 2-5.
  • You can use a value of 1 but you must add the -qmin 1 output option (because the default is -qmin 2).

That gives a ~128KB image instead of a ~80KB image for the video in my example. 🙂

@Uhter
Copy link

Uhter commented Jun 17, 2023

Perfect !
Thanks again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants