po5 / thumbfast

High-performance on-the-fly thumbnailer script for mpv
Mozilla Public License 2.0
760 stars 34 forks source link

smoother thumbnail? #65

Open tmpm697 opened 1 year ago

tmpm697 commented 1 year ago

I use this config:

# Socket path (leave empty for auto)
socket=

# Thumbnail path (leave empty for auto)
thumbnail=

# Maximum thumbnail size in pixels (scaled down to fit)
# Values are scaled when hidpi is enabled
max_height=200
max_width=200

# Overlay id
overlay_id=42

# Spawn thumbnailer on file load for faster initial thumbnails
spawn_first=yes

# Enable on network playback
network=no

# Enable on audio playback
audio=no

# Enable hardware decoding
hwdec=vaapi

# Windows only: use native Windows API to write to pipe (requires LuaJIT)
direct_io=no

Basically I want thumbnails as fast as possible and real smooth when surf progress bar. I'm ok with current state of how thumbnails processed but still find it a bit not so smooth -- this is purely my experience and it's biased.

I'm thinking of if we can allow multi-threads to process thumbnails faster (threads=10) --> considering the machine's power is not limited. Other users with limited pc's hardware can turn it off.

I've tested with 60G 4k mkv file and thumbnails took a lot of time to generate frames/images.

from your video/gif in README, thumbnails look really smooth with small size / low video quality but in case of 4k or 8k video, how to have thumbfast generate thumbnails faster and smoother when surf progress bar?

  1. again, can we enable multi-threads to process thumbnails?
  2. can we give option to choose the quality of each frame/images to give faster experinece? like if you're with 4k video, and choose thumbnails frames/images with quality really low, it'll help to speed up user's experience.

Update: just confirmed that it's unusable with 4k video (tried with size of 64G and 38G video), when I surf progress bar, it always show same frame/image.

po5 commented 1 year ago

direct_io=yes will likely help if you're on Windows.

In #49 we changed vd-lavc-threads to 2, but I realize that should probably be tweakable through an option.

However if it's a hard drive speed issue there is nothing we can do.
We already optimize decoding by disabling quality options, and downscale directly to the final thumbnail resolution.

hooke007 commented 1 year ago

hwdec=vaapi

The value of this option only support yes or no You cannot use native hwdec in encoding mode. And vd-lavc-threads usually cannot limit hwdec’s decoding threads.(It only works for software-decoidng.)

tmpm697 commented 1 year ago

I changed hwdec=yes and retried, pretty much same result. No usable with 4k video, able with 4k rip, and ok with 1080p, and I believe it would only smooth with 720p mkv video.

with 4k, only one image show when you move to progress bar and then surf it. with 4k rip, images display but not keep up with mouse movment, feeling a bit slow. with 1080p, it's there but can be smoother.

I compare the smooth with any kind of online movie service that support thumbnails, and they're really fast and smooth, I don't know if streaming videos would reduce the quality that come with more light weight work for thumbnail process.

tbh, I really appreciate the work put here and hope it would keep up better.

tmpm697 commented 1 year ago

Just worked now for me -- no idea, can render even with 4k mkv native, can be limit to disk but a bit images still need somehow to keep up with mouse movement, how can we improve this?

I use this thumbnails with this, maybe there's a bottleneck?

po5 commented 1 year ago

Just worked now for me -- no idea, can render even with 4k mkv native

Then that's a disk speed issue and nothing I can help you with. Your OS caches the most common disk hits after some initial scrubbing.

christoph-heinrich commented 1 year ago

We could maybe experiment with pregenerating keyframe images with ffmpeg for local files. https://superuser.com/a/1153483 People report pretty fast generation in the comments, but the images are not guaranteed to be in the correct order and associating them to timestamps is also hacky. It would probably be best to ask in the ffmpeg irc if they know how to embed the timestamp into the filename, because I couldn't find anything from a quick search.

tmpm697 commented 1 year ago

As my comment here and a demo of lagging thumbnails:

https://user-images.githubusercontent.com/48467427/200462135-702fa69a-df76-439d-ae8b-6960887034e7.mp4

BhaturaGuy commented 1 year ago

Same issue here.

barolo commented 1 year ago

Same issue, displays only one thumbnail with 4k HDR files, on nvme drive

po5 commented 1 year ago

@barolo That is not the issue described here, please make a new issue with your OS and mpv version info.

barolo commented 1 year ago

@barolo That is not the issue described here, please make a new issue with your OS and mpv version info.

How it is different when OP states Update: just confirmed that it's unusable with 4k video (tried with size of 64G and 38G video), when I surf progress bar, it always show same frame/image. ?

tmpm697 commented 1 year ago

As my comment here and a demo of lagging thumbnails:

screencast-latest.mp4

this issue related to lagging preview images when playing large media file.

da3dsoul1 commented 7 months ago

As my comment here and a demo of lagging thumbnails:

screencast-latest.mp4

Hey, could you please tell what osc/progress bar are you using? looks slick

christoph-heinrich commented 7 months ago

We could maybe experiment with pregenerating keyframe images with ffmpeg for local files.

--vd-lavc-skipframe=nonkey --no-audio --untimed can be used to run though the keyframes of a video fairly quickly, but just like with ffmpeg I don't know how we could associate those with their timestamps :/ Maybe a script on the spawned process that observes time-pos and then renames the generated file with a timestamp? Could be worth a try.