mpv-scripts icon indicating copy to clipboard operation
mpv-scripts copied to clipboard

Proper Crop Toggle and Cycle Crops

Open smhmd opened this issue 4 years ago • 4 comments

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.

smhmd avatar Jan 27 '20 02:01 smhmd

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.

occivink avatar Feb 18 '20 14:02 occivink

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?

smhmd avatar Feb 18 '20 15:02 smhmd

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

occivink avatar Feb 18 '20 16:02 occivink

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.

smhmd avatar Feb 18 '20 17:02 smhmd