occivink / mpv-gallery-view

Gallery-view scripts for mpv
The Unlicense
189 stars 20 forks source link

save contact sheet to a file #29

Open akizuha opened 3 years ago

akizuha commented 3 years ago

Is it possible to save the contact sheet to a png/jpg file like some other software do? Could be a useful feature. And I am not suggesting using screenshot function that comes with mpv. If the contact sheet is longer than one screen (and usually is), screenshot is not really practical. Thanks for any comments.

occivink commented 3 years ago

That's not really possible to do in a script I'm afraid. Stitching multiple screenshots together is actually the simplest way I can think of.

akizuha commented 3 years ago

Is this because of that mpv does not have necessary api? What about using the help of external program such as ImageMagick, like this https://wiki.videolan.org/VLC_HowTo/Make_thumbnails/. I also wonder what format is used in store those thumbnail in cache folder. Maybe it is possible to manipulate that format directly.


If screenshots is the easiest way to do this. It would be better to change (lavfi-complex could do this I believe) the video output to a fixed size (portrait), make the screenshot, then restore the video size.

occivink commented 3 years ago

Yes it's very much possible to read the thumbnail files and build the contact sheet externally. The format is described here, more specifically

Currently, only bgra is defined. This format has 4 bytes per pixels, with 8 bits per component. The least significant 8 bits are blue, and the most significant 8 bits are alpha (in little endian, the components are B-G-R-A, with B as first byte).

I think it might be possible to programmatically resize the window such that the entire contact sheet fits and then take a screenshot, but that seems tricky and error-prone.