occivink / mpv-scripts

Various scripts for mpv
The Unlicense
417 stars 38 forks source link

Do you think the crop script can be be easily modified for "automatic zoom"? #50

Closed fboumol closed 3 years ago

fboumol commented 3 years ago

I am interested to have some kind of "automatic zoom" inside mpv (where the input is based on selecting a region) in the way explained in https://github.com/mpv-player/mpv/issues/8794

The crop script here given comes very close to what I would like to have. The cropping of "crop.lua" provides a kind of zoom (which is useful), but unfortunately the cropping also kills the possibility to span (and move around) in the "zoomed version".

Since at present I am not familiar with lua language I am not following the details of your code, and before going deeper into it I wonder whether you consider that the approach you have implemented could be adopted for "automatic zoom" purpose. I suspect the cropping is easier than what I want, but depending on how you have designed the cropping it might the case that I can easily adapt it to my aim.

Do you think the approach of you crop script can be be easily modified for "automatic zoom"? I would like to know your opinion on this question before spending time on lua language.

Thanks.

occivink commented 3 years ago

So just to be clear, instead of cropping you would like the script to set pan-x, pan-y and zoom such that the mpv windows shows the region you selected, right? I think that sounds possible, but trickier than just setting a filter. I like the idea so I might give it a shot, but no promise regarding a timeline. I also think there will be corner cases with selecting a region whose aspect ratio does not match the video's (or is the window's?).

Btw if you're interested in zoom / pan manipulation I also have some other useful scripts over there https://github.com/occivink/mpv-image-viewer

fboumol commented 3 years ago

So just to be clear, instead of cropping you would like the script to set pan-x, pan-y and zoom such that the mpv windows shows the region you selected, right?

Exactly. The "only" thing that the code must do is to calculate the right values to set those three variables (pan-x, pan-y and zoom) assuming that when one selects the rectangle the value of these three variables is 0 (and one also needs the dimensions of the mpv window for the calculations). It does not seem worth the time trying to figure out how to do the same for all initial values of these three variables (because it is rather simple to reset those values to 0 with the usual shortcut "Alt+Backspace").

I think that sounds possible, but trickier than just setting a filter.

That is what I suspected (for cropping I guess no calculations are needed, just the info of the rectangle).

I like the idea so I might give it a shot, but no promise regarding a timeline.

It would be awesome if you find time some day (no duties).

I also think there will be corner cases with selecting a region whose aspect ratio does not match the video's (or is the window's?).

Yes, sure. I was somehow referring to this fact in my post https://github.com/mpv-player/mpv/issues/8794#issue-872171896 :

This could be done in two different ways: one destroying proportion (heighth versus vertical) of the video and one keeping it (and so in this second case there would be pixels outside of the selected region that will be showed in the mpv window).

Let me explain what would be in my opinion the preferred way:

occivink commented 3 years ago

Thinking about it, my preferred approach would be to constrain the rectangle ratio such that it must match the window ratio. I generally don't see the point of not preserving the aspect ratio, so I probably won't implement that

fboumol commented 3 years ago

Thanks a lot (you have been too fast for me). I have checked and it really works great the soft mode.