Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a possibility to add cropped screenshot feature? #4842

Open
anoniniarz opened this issue Mar 4, 2024 · 6 comments
Open

Is there a possibility to add cropped screenshot feature? #4842

anoniniarz opened this issue Mar 4, 2024 · 6 comments

Comments

@anoniniarz
Copy link

What you want IINA to do:
Feature to make screenshot of only part of the video, on mpv I used crop.lua, but unfortunately can't make it work on IINA because of poor script support.
What IINA does currently:
It only can make full screenshots

Why you think this should be added:
I think it is a nice feature, you don't always want to screen whole picture. Of course you can use macos' screenshot feature, but having one built-in would be more convenient, and screenshots would be properly named.

Examples of other projects that have something similar:
https://github.com/occivink/mpv-scripts/tree/master/scripts

@low-batt
Copy link
Contributor

low-batt commented Mar 5, 2024

What is it that crop.lua provides that can't be done by selecting Custom under Crop in the Video menu?

@anoniniarz
Copy link
Author

What is it that crop.lua provides that can't be done by selecting Custom under Crop in the Video menu?

First of all you have to disable hardware encoding to use custom crop or set it to auto which consumes more memory, second it takes 9 steps to make cropped screenshot instead of two. It's just matter of convenience, and considering that crop.lua already exists it shouldn't be that hard to implement, right?

@low-batt
Copy link
Contributor

low-batt commented Mar 5, 2024

From the README for crop.lua:

Note that hardware decoding is in general not compatible with filters, and will therefore not work with this script.

From that it would seem like both the IINA crop feature and the crop Lua script have this same restriction regarding use of hardware decoding.

I just tested the crop script with mpv passing --hwdec=auto and it seemed to work. Maybe the documentation is out of date? More investigation is needed.

The crop script interface is definitely quick and easy to use.

One other alternative would be to fix some of the issues with running Lua scripts under IINA. Some work has been done on adding support for dynamic key bindings, which is one source of problems. I'm expecting mouse handling might be another area that is problematic for scripts.

IINA's long in development plugin system is very close to being released, so another choice for implementing this is to create an IINA script that does this.

I'm a junior IINA developer, so I will be deferring to the senior developers as to the best way to handle this feature request.

@krackers
Copy link
Contributor

krackers commented Mar 6, 2024

Upstream mpv recently added support for cropping at VO layer which works with hwdec (I think basically instead of adding a filter it just only copies out the relevant part of the image to the frame buffer). When iina updates to use latest mpv version, it should get this feature for free (it might depend on window screenshot support being merged)

@anoniniarz
Copy link
Author

I'm expecting mouse handling might be another area that is problematic for scripts.

I am not familiar with software engineering in any way, but if mouse handling would be an issue maybe doing it like this script would help? That is using mouse only to set coordinates, and then using keybinds to actually send them to the script.

@low-batt
Copy link
Contributor

low-batt commented Mar 8, 2024

@anoniniarz Thanks for the link to the other script. I would have to spend a good bit of time investigating the situation to comment on the situation with mouse clicks.

@krackers I see the video-crop was added in mpv 0.37.0:

--video-crop=<[W[xH]][+x+y]>, --video-crop=<x:y>
Crop the video by starting at the x, y offset for w, h pixels. The crop is applied to the source video rectangle (before anamorphic stretch) by the VO. A crop rectangle that is not within the video rectangle will be ignored. This works with hwdec, unlike the equivalent 'lavfi-crop'. When offset is omitted, the central area will be cropped. Setting the crop to empty one --video-crop=0x0+0+0 overrides container crop and disables cropping. Setting the crop to --video-crop="" disables manual cropping and restores the container crop if it's specified.

Thanks for pointing that out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants