4

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?

souvickcse
  • 7,742
  • 5
  • 37
  • 64
devuser27
  • 81
  • 2
  • These two(`AVCaptureVideoDataOutput`, `AVCaptureMovieFileOutput`) will not work with each other. Please explain your actual requirement so that we can offer alternate work around. – souvickcse Nov 18 '19 at 07:53

2 Answers2

2

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

souvickcse
  • 7,742
  • 5
  • 37
  • 64
  • That's weird since I couldn't find any mentions of them being mutually exclusive on apple documentations. Thanks for the reference, I'll look into it – devuser27 Nov 18 '19 at 16:34
  • Yes, I didn't find any document where it is specifically mentioned – souvickcse Nov 18 '19 at 17:00
-1

You can use AVCaptureVideoDataOutput and AVAssetWriter to realize what you need. And I have a demo in https://github.com/gwh111/CoreMLRecord

hope it help.

Gao
  • 85
  • 1
  • 7