fbukevin / AccessCamera

Access FaceTime HD Camera of MacBook with AVFoundation in Swift
38 stars 3 forks source link

Snapchat Lens AVCaptureDevice #2

Open omarojo opened 6 years ago

omarojo commented 6 years ago

So Snapchat just released a Desktop app, that allows apps like OBS, Skype, Apple's PhotoBooth, Google Hangouts, or pretty much any app that uses camera, To access the SnapChat video feed when you are running it.

Your code detects the Device in the list of Devices. But for some reason, it doesnt show any feed, the window becomes glitchy, when you drag it.. like those old Windows glitches.

I find it very odd, because all other apps Detect the SnapCamera device with no problem.

Here is the SnapChat desktop app: https://snapcamera.snapchat.com/

Any idea what could be going on ?

fbukevin commented 6 years ago

In order to find the problem, I rerun again the project after installed the app. This is the output I get with AVCaptureDevice.devices():

<AVCaptureHALDevice: 0x6000000e3d80 [USB audio CODEC][AppleUSBAudioEngine:Burr-Brown from TI:USB audio CODEC:14312000:2]>
<AVCaptureHALDevice: 0x6000000e3c00 [Built-in Microphone][AppleHDAEngineInput:1F,3,0,1,0:1]>
<AVCaptureDALDevice: 0x10130e0f0 [Snap Camera][SnapCamera0]>
<AVCaptureDALDevice: 0x10130e0f0 [Snap Camera][SnapCamera0]>
<AVCaptureDALDevice: 0x101409dd0 [FaceTime HD Camera][DJH7266NKBEGJKD16]>
<AVCaptureDALDevice: 0x101409dd0 [FaceTime HD Camera][DJH7266NKBEGJKD16]>

It seems that Snap Camera is accessible. Do you have the same output?

omarojo commented 6 years ago

Yeap that's correct. I get the same. Then I assign the camera like this. But no video feed :(

        let devices = AVCaptureDevice.devices()

        // Find the FaceTime HD camera object
        for device in devices! {
        //print(device)

            // Camera object found and assign it to captureDevice
            if ((device as AnyObject).hasMediaType(AVMediaTypeVideo)) {
                print(device)
                let d = device as? AVCaptureDevice
                print("\(d?.manufacturer)")
                if(d?.manufacturer == "SnapVendor"){
                    captureDevice = device as? AVCaptureDevice
                    break;
                }

            }
        }