Avcapturevideodataoutput Captureoutput Not Being Called

captureOutput not being called

You made a mistake in declaration of required sample buffer delegate method:

captureOutput(_:didOutputSampleBuffer:from:).

Please check it and make sure it is:

func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, from connection: AVCaptureConnection!)

PS: Pay attention on how parameters of that method are declared. All parameters have '!' which means automatic unwrapping.

AVCaptureVideoDataOutput captureOutput not being called

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.

captureOutput not being called by AVCaptureAudioDataOutputSampleBufferDelegate

Ok, nobody got back to me but after playing around with it I worked out the correct way to declare the captureOutput method for Swift4 is as follows:

func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
//Do your stuff here
}

Unfortunately, the documentation for this online is very poor. I guess you just need to get it exactly right - there are no errors thrown if you mispell or misname the variables as it is an optional function.

captureOutput from AVCaptureVideoDataOutputSampleBufferDelegate is not being called

You are missing adding the input

if session.canAddInput(videoDeviceInput){
session.addInput(videoDeviceInput)
}

captureOutput not being called from delegate

Update: There is actually nothing wrong with the code here. The issue I was having was that the instance of the class that is described above was being garbage collected.

AVCaptureAudioDataOutput Is Not Calling AVCaptureAudioDataOutputSampleBufferDelegate.captureOutput

Did you get any devices? I tried to build your code but didn't get any devices. Anyway, you can look at this answer and also this answer. Also, one thing I can guess, not sure though. Put your capture session variable

let session  = AVCaptureSession()

outside of viewDidLoad.



Related Topics



Leave a reply



Submit