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

cannot customize video.screen.size configuration #76

Open
LiYing2010 opened this issue Jul 6, 2022 · 1 comment
Open

cannot customize video.screen.size configuration #76

LiYing2010 opened this issue Jul 6, 2022 · 1 comment

Comments

@LiYing2010
Copy link
Contributor

LiYing2010 commented Jul 6, 2022

I am trying to customize video.screen.size configuration, but it does not work, and VideoRecorder always get System Screen Dimension

my code (in Kotlin) is something like:

System.getProperties().apply {
    setProperty("video.screen.size", "1366x768")
}

and when I debug into method com.automation.remarks.video.recorder.ffmpeg.FFmpegWrapper#getScreenSize:

private String getScreenSize() {
    Dimension dimension = conf().screenSize();
    return dimension.width + "x" + dimension.height;
}

the dimension value get from conf().screenSize() is always System Screen Dimension,
instead of my customized setting 1366x768

since conf() returns a proxy which created by org.aeonbits.owner.ConfigFactory
so I also debugged into these proxy code,
and found something in org.aeonbits.owner.PropertiesInvocationHandler#invoke:

public Object invoke(Object proxy, Method invokedMethod, Object... args) throws Throwable {
    propertiesManager.syncReloadCheck();

    if (isDefault(invokedMethod))
        return invokeDefaultMethod(proxy, invokedMethod, args);

    DelegateMethodHandle delegate = getDelegateMethod(invokedMethod);
    if (delegate != null)
        return delegate.invoke(args);

    return resolveProperty(invokedMethod, args);
}

looks like com.automation.remarks.video.recorder.VideoConfiguration#screenSize is a default method of interface,

@Key("video.screen.size")
default Dimension screenSize() {
  return SystemUtils.getSystemScreenDimension();
}

so PropertiesInvocationHandler always invokes this default method, instead of resolve property value,
that's why customized video.screen.size is never be used.

I guess this issue was introduced in this commit:
0550699#diff-203944a2497bdc096cac64c8e238e158746026fe559d3f4bcf0ed24db5dcc523R47-R50

I like to ask, is my investigation result correct?
if so, I like to send a PR to fix this issue

LiYing2010 added a commit to LiYing2010/video-recorder-java that referenced this issue Jul 6, 2022
@LiYing2010
Copy link
Contributor Author

I made PR #77 to fix this
please review when you get time

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

No branches or pull requests

1 participant