AVCaptureVideoDataOutput captureOutput not being called

后端 未结 2 912
臣服心动
臣服心动 2021-01-14 17:55

I\'m trying screen capture on a Mac with AVCaptureScreenInput, but AVCaptureVideoDataOutput delegate captureOutput is never called, and I\'m not sure why. I do get a notific

2条回答
  •  一整个雨季
    2021-01-14 18:36

    You need to define the didOutputSampleBuffer delegate callback to actually receive the captured frames:

    func captureOutput(captureOutput: AVCaptureOutput!, didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, fromConnection connection: AVCaptureConnection!) {
        print("captured \(sampleBuffer)")
    }
    

    p.s. I'm not sure about macOS, but viewWillAppear may not be a good place to do initialisation because on iOS at least it can be called multiple times.

提交回复
热议问题