cosmic-files
cosmic-files copied to clipboard
feature request: image and video tumbnails that just work
A thing about most graphical file managers that annoys me to no end on Linux is that they don't support thumbnails well enough, most of the time images are fine, but videos I have never been able to get working in a single graphical file manager. And in some extreme cases images aren't even present. It's so bad that I can get more graphical features in my terminal file manager and it mostly just works, see image below for a example of a video thumbnail
video thumbnails may want to rely on a separate library/crate, I'm not sure of any current rust libraries for handling them, but you need to first check the container for an embedded thumbnail, and if one doesn't exist, generate one yourself. much like the ffmpegthumbs library or ffmpeg thumbnailer
image thumbnails are easier to generate using image-rs for the majority of them (though it does lack support for jxl and likely wont get support for a while). I wonder what cosmic's plans are for this, if they plan on spinning their own solution or just interfacing with something else.
We could call ffmpeg commands in the background to generate video thumbnails.
ffmpeg -ss 90 -i input.mp4 -vf "select=gt(scene\,0.4),scale=320:-1" -frames:v 1 -vsync vfr output.jpg
Which skips the first 90 seconds of the video and looks for the first scene with a 40% difference.
That seems like it might be slow and maybe hacky, but with caching, and running it asynchronously it wouldn't be terrible. I am pretty sure that's what most terminal file managers do anyway, hope it goes well because video thumbnails seem like a thing most file managers fail at but of course this should be a consideration for later likely
It takes about a half second or two to generate a frame, and you could alternatively use the thumbnail=n=1000
video filter to limit the search within 1000 frames to make it even faster. The ss
argument above seeks through first 90 seconds of frames without decoding, so it is relatively instantaneous.
We already use tokio for spawning processes asynchronously on a tokio runtime running in the background, so spawning a couple ffmpeg processes and asynchronously updating the UI is easy. Spawning commands would also be the more Unix philosophy way of software development.
External thumbnailing is now supported using entries in /usr/share/thumbnailers
Maybe dumb question, but does this work in file picker too? I assume you write a script? How exactly does that work? Maybe PopOS should ship ones for video