3

I'm using AVCaptureSession to capture a video into a movie file. I want to get the exact timestamp of the first and last frame of the movie. How do I do this?

In AVCaptureFileOutputRecordingDelegate, the method captureOutput(_:didStartRecordingToOutputFileAtURL:fromConnections:) is called when movie recording starts, but it is too inaccurate for my purposes, as is the callback for when recording ends. I need the exact timestamp of the frame.

In AVCaptureVideoDataOutputSampleBufferDelegate, the method captureOutput:didOutputSampleBuffer:fromConnection: gets called per frame, and can be used to access explicit timestamp information for the frame, so that should be plenty accurate.

Unfortunately, it seems you cannot configure a capture session to simultaneously record to a video file and to provide raw sample data, so I cannot use this to get frame timestamps while also capturing to a file.

Or is there some way to use them both at once? Or am I missing another piece of API I could use?

algal
  • 27,584
  • 13
  • 78
  • 80

1 Answers1

0

FWIW, I raised a Developer Technical Support ticket with Apple regarding this issue, in order to get a final answer.

The Apple engineer confirmed there is no way to access both pieces of API simultaneously. So if you want exact timestamps and record a video file, then you need to conform to AVCaptureVideoDataOutputSampleBufferDelegate and build the file yourself.

algal
  • 27,584
  • 13
  • 78
  • 80