occivink / mpv-scripts

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

Cropping with the keyboard #8

Closed rien333 closed 6 years ago

rien333 commented 6 years ago

I run mpv from a framebuffer on my raspberry pi, but this setup unfortunately does not have any mouse support. I do have gpm installed, but the mpv devs have explicitly expressed no interest in supporting it. Can your script be extended to be used with keyboard support? (might be interested in implementing it myself, just wanted to know if this can be done easily, maybe without writing a lot of extra code).

I already saw a function crop_video(x, y, w, h) in your code, which might allow for manual keyboard entry of it's parameters (thereby bypassing all the interactive stuff). The interactive part of this script is okay btw, I'm just not that sure if it fits in well with keyboard movement.

occivink commented 6 years ago

Hi,

Being able to crop without using the mouse at all is a good idea, and I would like to add support for it. I'm not sure about entering the crop values by hand: it seems error prone and not really in line with the interactiveness of the script. Another approach we could take is add bindings to {UP,DOWN,LEFT,RIGHT} to move the crop pointer, would that work for you?

If you're interested in implementing this I can give you some pointers.

For now if you absolutely want to type the values, then check out mpv-repl. Cropping with it might be a bit verbose but it can be done.

Now that I've typed this, I realize that maybe we could do something to input the coordinates while still being interactive, but I can anticipate a few tricky edge-cases with doing this.

rien333 commented 6 years ago

I was able to sort of implement this last night, but unfortunately it's kinda cumbersome to use. I'll look at some of your suggestions and maybe report back in a few days.

rien333 commented 6 years ago

My implementation didn't really use the visual pointers from your script, but rather changed some of the crop paramaters directly as sort of a proof of concept btw. (I also haven't done any mpv and not a lot of lua programming before) Adding bindings to {UP,DOWN,LEFT,RIGHT} for moving two crop pointers would probably work lots better.

occivink commented 6 years ago

I pushed some preliminary support, I'll make it configurable in the near future. For now you can use the arrow keys for coarse movement, alt+arrow for fine movement