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

fix: respect preview.max_width for video thumbnails #2560

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ze0987
Copy link
Contributor

@ze0987 ze0987 commented Mar 31, 2025

Currently, Yazi only scales thumbnails to preview.max_height, which means that thumbnails of videos in landscape orientation are unnecessarily large.

Example:

max_width       = 600
max_height      = 900
image_quality   = 75

Before

File size: 131 kB
Image size: 1600x900
On the left is a preview in Yazi, and on the right is a generated thumbnail.
before

After

File size: 28 kB
Image size: 600x338
after

@sxyazi
Copy link
Owner

sxyazi commented Apr 1, 2025

Thanks for the PR!

Could you provide some benchmarks to see how this change affects performance — separately when the video size is under max_width/max_height and when it reaches them?

@ze0987
Copy link
Contributor Author

ze0987 commented Apr 1, 2025

Sure.

max_width       = 600
max_height      = 900
image_quality   = 75

Video resolution 320x180, software

Before

  Time (mean ± σ):     253.2 ms ±   1.7 ms    [User: 194.5 ms, System: 53.8 ms]
  Range (min … max):   250.8 ms … 255.5 ms    10 runs

After

  Time (mean ± σ):     254.1 ms ±   1.6 ms    [User: 194.9 ms, System: 54.5 ms]
  Range (min … max):   251.3 ms … 256.3 ms    10 runs

Video resolution 320x180, vaapi

Before

  Time (mean ± σ):     272.6 ms ±   2.4 ms    [User: 198.1 ms, System: 68.9 ms]
  Range (min … max):   269.8 ms … 277.5 ms    10 runs

After

  Time (mean ± σ):     278.0 ms ±   2.7 ms    [User: 202.2 ms, System: 70.4 ms]
  Range (min … max):   273.3 ms … 282.8 ms    10 runs

Video resolution 1920x1080, software

Before

  Time (mean ± σ):     884.0 ms ±   2.7 ms    [User: 778.3 ms, System: 95.8 ms]
  Range (min … max):   879.6 ms … 888.7 ms    10 runs

After

  Time (mean ± σ):     843.4 ms ±   2.9 ms    [User: 744.5 ms, System: 89.7 ms]
  Range (min … max):   838.7 ms … 846.9 ms    10 runs

Video resolution 1920x1080, vaapi

Before

  Time (mean ± σ):     448.4 ms ±   3.7 ms    [User: 314.1 ms, System: 126.7 ms]
  Range (min … max):   442.9 ms … 453.8 ms    10 runs

After

  Time (mean ± σ):     388.1 ms ±   2.9 ms    [User: 268.0 ms, System: 113.2 ms]
  Range (min … max):   383.8 ms … 392.5 ms    10 runs

With this PR, thumbnails of videos smaller than preview.max_width x preview.max_height will be upscaled to preview.max_width x preview.max_height, which may or may not be a good thing.

@sxyazi sxyazi force-pushed the main branch 2 times, most recently from 75fad25 to 9565c1b Compare April 4, 2025 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants