Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVCaptureSession - add multiple outputs in parallel

I'm trying to record captured frames as video while performing image processing tasks on the frames at the same time in parallel.

I have a single AVCaptureSession which I have added two separate outputs to -

  1. AVCaptureVideoDataOutput
  2. AVCaptureMovieFileOutput

I confirmed to both AVCaptureVideoDataOutputSampleBufferDelegate and AVCaptureFileOutputRecordingDelegate

I am using captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) for frame capture and analyze and func fileOutput(_ output: AVCaptureFileOutput, didStartRecordingTo fileURL: URL, from connections: [AVCaptureConnection]) for video recording

For some reason, each method works separately, but when I'm adding both outputs, only the video recording works and the "captureOutput" function is not being called at all.

Any thoughts why this is happening, what am I doing wrong? or what should I make sure while setting up and configuring the session?

like image 322
devuser27 Avatar asked Dec 03 '25 18:12

devuser27


1 Answers

These two(AVCaptureVideoDataOutput, AVCaptureMovieFileOutput) will not work with each other. You can use captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) for getting the frame to analyse as well as recording. You can find sample code here

like image 110
souvickcse Avatar answered Dec 06 '25 08:12

souvickcse