6

On macOS, is it possible to see a virtual Camera, such as OBS, as a CaptureDevice? I see that, for example, Google Chrome or Zoom can use this camera, but using AVCaptureDevice.DiscoverySession I am unable to see it.

Am I doing wrong?

    var deviceTypes: [AVCaptureDevice.DeviceType] = [.builtInMicrophone, .builtInWideAngleCamera]
    #if os(OSX)
    deviceTypes.append(.externalUnknown)
    #else
    deviceTypes.append(contentsOf: [.builtInDualCamera,
                                    .builtInDualWideCamera,
                                    .builtInTelephotoCamera,
                                    .builtInTripleCamera,
                                    .builtInTrueDepthCamera,
                                    .builtInUltraWideCamera])
    #endif
    let discoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: deviceTypes,
        mediaType: nil, position: .unspecified)

    result = discoverySession.devices.map { device in
        device.localizedName
    }
below
  • 929
  • 6
  • 26

2 Answers2

5

This could be related to the Hardened Runtime and library validation.

macOS does no longer load frameworks or plug-ins that are signed with 3rd party credentials when library validation is turned on. This is part of the Hardened Runtime, which is now enabled per default. Don't know about OBS, but virtual capture devices are usually implemented as CoreMediaIO plug-ins that are loaded at app launch and therefore affected by this.

For a quick test, you could try to disable the Hardened Runtime or set an entitlement that disables library validation with the HR turned on. I don't know if apps with this entitlement are accepted in the Mac App Store though.
Another approach would be to re-sign the CoreMediaIO plug-in with your signing credentials (if that's possible/allowed): https://developer.apple.com/forums/thread/126895?answerId=398061022#398061022

The developers of Camo have a good FAQ with some technical details about the library validation implications on CoreMediaIO plug-ins and there's also a comprehensive StackOverflow answer here.

Thomas Zoechling
  • 34,177
  • 3
  • 81
  • 112
  • 1
    Yes, by disabling library validation I am getting the "OBS Virtual Camera". I will check if that allows submission to the app store, or if the plugin can be re-signed! – below Jun 29 '21 at 08:58
  • Great that this worked - Thanks for confirming! I'd also be interested with which approach you went eventually and if it there were any problems during app review. – Thomas Zoechling Jun 29 '21 at 09:01
  • The Entitlement does not seem to work for Mac Catalyst Apps, I will have to ask around there … – below Jun 29 '21 at 09:05
  • And a question remains: The zoom.app, for example, can load the camera and it does not set that entitlement – below Jun 29 '21 at 09:21
0

Try setting the DiscoverSession mediaType to .video, and making sure your OBS virtual camera is working: you should be able to select it in the Camera menu in Photo Booth.app.

Rhythmic Fistman
  • 34,352
  • 5
  • 87
  • 159