Unexpected color values when capturing OBS virtual vamera

I am performing a basic test:

  1. Set up a fully red (255, 0, 0) scene in OBS
  2. Start the OBS virtual camera
  3. Capture this virtual camera and show the image

The issue I see is: Pixel colors are approximately (230, 0, 0), also in the preview window. This seems far off from the expected value.

The virtual camera color output is NV12 so there is color conversion going on. The color is correct if I open the virtual camera in VLC.

Code is just like this:

import cv2 as cv

vid = cv.VideoCapture(0)

while True:
    ret, frame = vid.read()
    cv.imshow('frame', frame)
    if cv.waitKey(1) == ord('q'):
        break

vid.release()
cv.destroyAllWindows()

What could cause the color to be this far off from the original?

we don’t link to that SEO spam site (geeksforgeeks). the code snippet you refer to on that page is awful in particular. I’ve copied it over and fixed it up a little.


what you experience is probably the difference between full range (0-255) and “limited range” (16-235).

I was considering that, but the other channels are 0-3…

you can play with the backends. try both CAP_DSHOW and CAP_MSMF. if either one works fine, and the other one shows the issue, that’s worth filing an issue.