Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

macOS: Accessing a virtual Cameras (OBS) as AVFoundation CaptureDevice

Tags:

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
    }
like image 812
below Avatar asked Jun 28 '21 09:06

below


1 Answers

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.

like image 82
Thomas Zoechling Avatar answered Sep 30 '22 17:09

Thomas Zoechling