BlankSourceCode / obs-zoom-to-mouse

An OBS lua script to zoom a display-capture source to focus on the mouse
286 stars 27 forks source link

Mac Retina Display Issue #24

Open MacPleb opened 9 months ago

MacPleb commented 9 months ago

I have tried to install this script on two different Intel MacBooks but it does not work properly on either one.

After choosing the Zoom Source and assigning a hot key, it will zoom to my cursor but only if it is around the top left of my screen. If I go to the right of my screen my cursor is no longer visible.

OBS Version: 30.0.2 (Clean install)

My Source transform settings are:

Positional Alignment : Top Left Bounding Box Type: Scale to Outer Bounds Alignment in Bounding Box: Top Left

Canvas Size: 1920X1080

Source Size: 1920x1080

Bounding Box Size: 1920x1080

The log does not appear to show anything failing. Totally unable to figure out where its going wrong.

One other user reports a similar issue in the OBS forum discussion thread (Post #29).

BlankSourceCode commented 9 months ago

@MacPleb it sounds like the mouse cursor location cannot be tracked. What version of Mac OS are you on?

MacPleb commented 9 months ago

Interestingly, it does track but the tracking is only properly aligned with the cursor if it is on the top left of the screen. If I go to the right my cursor disappears and appears to go out of the zoom frame.

Everything is set to 1920x1080 so I'm not sure where the calculations are going wrong.

I am trying on two different versions of Mac OS: Ventura and Monterey

BlankSourceCode commented 9 months ago

@MacPleb hmm, maybe the scaling got messed up. You could try resetting it by setting the Zoom Source to then clicking reset transform on your actual source in OBS, then reselecting it as the zoom source.

Do you have some custom transform values set?

Can you share the script log with debug logs enabled?

MacPleb commented 9 months ago

Tried resetting the source transform and reselecting but no luck. :(

Here is a video of what I am experiencing and a corresponding log.

BlankSourceCode commented 9 months ago

@MacPleb The video shows that your screen resolution is smaller than the canvas size (1680x1050 vs 1920x1080) which is probably causing the issue, some calculation in the script is going wrong, because it was designed for those to match. The fact that the black bars are on both the left and right suggests that your transform has Alignment in Bounding Box set to center which I'm also sure the script doesn't account for. As a test, set your canvas size in OBS to match the monitor resolution and check that zoom and tracking works correctly (you may need to reload the script after).

Can you share the contents of the script log after you press the Reload scripts button in OBS. It should show info about the source size that gets calculated.

My guess is that you could solve this by using the Set manual source position option and filling in the values manually, although I'm not sure what you'd actually need to use off the top of my head. Something like: x: 0 y: 0 width: 1920 height: 1080 scale x: 1.14 scale y: 1.02 monitor width: 1680 monitor height: 1050

Try playing with those values by positioning your mouse at the center of the screen and zooming in. You'll want to get it so that the cursor remains in the center of the screen after the zoom.

I'm not able to reproduce this on my machine even when I mess with the canvas size so I'm sure there is some other part of the setup that I'm missing.

MacPleb commented 9 months ago

Thanks for all the help, Blank. I think I'm getting closer to fixing it!

Can you share the contents of the script log after you press the Reload scripts button in OBS. It should show info about the source size that gets calculated.

So when I do this, the log says that it is "using source size 3360, 2100".

I have no idea where it is pulling this value from though.

I have set everything as follows:

In the script settings, checked the box for set manual source position.

Width: 1680 Height: 1050 Scale x: 1.0 Scale y: 1.0

Monitor Width: 1680 Monitor Height: 1050

In OBS Preferences

Canvas Size : 1680x1050

In Transform

Positional Alignment: Top left Source Size: 1680x1050 Bounding Box Type: Stretch to bounds Bounding Box Size: 1680x1050 Alignment in bounding box: Top Left

If I could figure out why the script keeps setting "3360, 2100" as the source size I think I'd be good!

BlankSourceCode commented 9 months ago

@MacPleb oh, is this an issue because you have a retina display and OBS is showing it in the UI as 1680x1050 instead of its real value 3360x2100?

That might explain why I can't repro it (as I don't have a retina display) and why the mouse is misaligned. When you move it, the Mac will report distance which is way bigger than what the script expects.

Try setting Scale X and Scale Y (in set manual source position settings) to 2 or 0.5 (I forget which way round it needs to be).

MacPleb commented 8 months ago

Hi Blank,

Yes, it indeed seems to be related to the Retina display! This is why it wasn't working well on either MacBook but it was fine on your non-retina Mac devices.

For whatever reason there are tons of inconsistencies with how the resolution is displayed throughout OBS. On top of that, every source I add (even other non-retina monitors) default to the MacBook retina resolution.

pretty annoying!

In the end, the fix that I found was to set up everything in both OBS and your script to 1920x1080 and change the x/y scaling to 2.0.

Seems to work flawlessly now!

I genuinely appreciate your work on this script and the time you wasted helping me get this sorted.

cheers!

BlankSourceCode commented 8 months ago

@MacPleb I'm glad you got it working!

I wonder if it would make sense for the script to look for the word "retina" on the OBS display name and if found, assume the size is actually twice as big as reported. I'm not 100% sure that would work though.

At least there is a way for users to make it work with the manual source settings.

MacPleb commented 8 months ago

Yes, me too!

Honestly, I don't know if it's worth your time to add it into the script. It seems like OBS itself just acts weird with MacBooks/retina displays.

Hopefully other MacBook users can find this post if they get stuck like I did though!

And for the record, the script runs much smoother for me than the python one. Even after the headache of getting that one up and running it would crash OBS constantly.

Thanks for your work on this!