occivink / mpv-scripts

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

Proper Crop Toggle and Cycle Crops #35

Open smhmd opened 4 years ago

smhmd commented 4 years ago

toggle-crop removes crop, not toggle it.

It would be great to switch between cropped and uncropped. my use case would be cropping GUI elements of an editor in tutorials, but toggle to full video when the instructor switches the editor window.

It would also be great to cycle between crops instead of switching crop on/off. crop.lua can already define multiple crops within each other.

occivink commented 4 years ago

I wonder if this is not maybe more appropriate for another script, that would allow you to selectively enable/disable parts of the filter chain or reorder it.

smhmd commented 4 years ago

I'm not familiar with filters in general, but a general-purpose script does seem like a sensible idea. How would it work, though? Currently, you can't have two crops that intersect/are totally separate.

+-------------------------------------------------+     +-------------------------------------------------+
|                                +-------------------+ |     |                                +-------------------+ |
|   +----------------------------+              |  |     |   +---------------+       |                       |  |
|   |                           |     |               |  |     |   |                   |      |                       |  |
|   +----------------------------+              |  |     |   +---------------+       |                       |  |
|                                +-------------------+ |     |                                +-------------------+ |
+-------------------------------------------------+     +-------------------------------------------------+

A crop must be within another crop. Just a week ago, I started needing these separate/intersect crops (maybe this should go in another issue). Which raises the question: is this filter chain a stack that would only allow filters on top of filters but not two different sets of filters to be cycled through?

occivink commented 4 years ago

Yes essentially the filter chain is a stack of filter (which can be crop, rotate, flip, blur... the list is long).

And I don't think your diagram renders properly.

If you need separate crops you can use lavfi-complex but this is not going to be easy to define interactively. Maybe if you have a mostly static usecase. blur-edges.lua makes use of lavfi-complex, it essentially is two separate crops on either sides of the video

smhmd commented 4 years ago

And I don't think your diagram renders properly.

Probably different fonts. It's supposed to look like this: image


this is not going to be easy to define interactively.

How about this pattern: Press c to define-crop using [[380,230],[1500,800]] as points. pressing c again would simply zoom out to full video with the crop defined with [[380,230],[1500,800]] highlighted, leaving you with the freedom to define a separate, intersectional, or an inner crop.

Filters can be piped into something similar to this:

image

Where filters can be toggled on and off, with a keybinding to cycle between them/disable all of them on the fly.