letmaik / pyvirtualcam

🎥 Send frames to a virtual camera from Python
GNU General Public License v2.0
452 stars 49 forks source link

macOS 11: test captures in CI are darker than in 10.15 #82

Closed letmaik closed 1 year ago

letmaik commented 2 years ago

As far as I see, the only relevant change was GitHub Action's upgrade to macOS 11.

Old:

Current:

In both old and current, the OBS version used in CI was the same: 26.1.2.

Log excerpt showing the diff for current:

FAILED ../test/test_capture.py::test_capture[diff-RGB-obs] - assert 24.0 <= 2
FAILED ../test/test_capture.py::test_capture[diff-BGR-obs] - assert 24.0 <= 2
FAILED ../test/test_capture.py::test_capture[diff-I420-obs] - assert 33.0 <= 2
FAILED ../test/test_capture.py::test_capture[diff-NV12-obs] - assert 33.0 <= 2
FAILED ../test/test_capture.py::test_capture[diff-YUYV-obs] - assert 33.0 <= 2
FAILED ../test/test_capture.py::test_capture[diff-UYVY-obs] - assert 33.0 <= 2

Comparison

This is for UYVY which is the native pixel format of this camera, so theoretically it should be closest to the reference.

Reference

test_UYVY_in

Old

test_UYVY_out_diff_Darwin_obs_py37

Current

test_UYVY_out_diff_Darwin_obs_py37

I'm not sure where the issue is coming from. It would be good to get independent user verification from someone running macOS 11.

I should note that the test capture mechanism used here relies on OpenCV's VideoCapture, but the OpenCV Python package version is pinned to 4.5.1.48 (see dev-requirements.txt for why), both in old and current.

Things to try:

  1. Bumping the OBS version in CI to the latest is worth a try, maybe some fixes were needed for macOS 11, though it's unlikely. EDIT: Tried that but didn't help: https://github.com/letmaik/pyvirtualcam/runs/5300762692

  2. Run the CI workflow to use macOS 10.15 which is still available. Currently it uses macos-latest which switched to macos 11 recently. EDIT: This avoids the issue! https://github.com/letmaik/pyvirtualcam/actions/runs/1886403645

Status: To keep CI green, I switched back to 10.15 in the meantime. EDIT: CI is now using macOS 11 because 10.15 is EOL. The capture tests have been relaxed to accept a larger diff for macOS. See #96.

Call for help: If someone has macOS 11, try the following experiment and report back:

  1. Output a fixed test image on the virtual camera in OBS (the app, not using Python).
  2. Start some video app like Zoom and take a screenshot of the virtual cam image.
  3. Check if they are identical or not.
  4. If the screenshot is darker, then the issue can be reported to OBS and is not related to pyvirtualcam.
janmonterrubio commented 1 year ago

Took samples of pictures of the reference provided and what it looks like on zoom / teams: Screen Shot 2022-08-29 at 9 22 52 AM Screen Shot 2022-08-29 at 9 22 17 AM

Using macOS 12.5 Monterey.

Seems that the image is brighter on zoom and darker on teams.

letmaik commented 1 year ago

I used the color picker to check your images. Zoom and Teams are actually identical. Note that the image is flipped horizontally in Zoom for preview. Both images differ from the reference image but I'm not sure what the difference is exactly - the greens are brighter in Zoom/Teams, but the orange and red are slightly darker. I'm not sure if this is an actual issue or maybe coming from some settings of the graphics driver which sometimes tune images to look "better". After all, this is a camera device and goes through a few layers of the operating system.

letmaik commented 1 year ago

Just did some tests on macOS 11.7 with OBS 28.0.2 and pyvirtualcam 0.10.0.

When using pyvirtualcam to send the test image, then there is a perfect match between the input image and what's shown in webcamtests.com in Firefox, so that's good.

When using OBS to send the test image, then the image in Firefox is slightly different. This is a bit surprising.

When using pyvirtualcam to send the test image and capturing it in Python via OpenCV, then the captured image is slightly different. This is the behavior described in this issue.

I'm going to close this issue as it doesn't seem to be an issue with pyvirtualcam itself. It's a bit unfortunate but a proper investigation on what's going on in macOS would take too much time.