gorastudio-git / SCNRecorder

The best way to record your AR experience!
MIT License
201 stars 51 forks source link

How can I get timestamp from SCNRecorder when recording? #58

Open DikeyKing opened 2 years ago

DikeyKing commented 2 years ago

Hello

I want to save some data from ARFrame and associate the data to the video frame captured from SCNRecorder

How I can not read the time when recorder is recording

func append(pixelBuffer: CVPixelBuffer, withPresentationTime time: CMTime) throws {
  guard pixelBufferAdaptor.assetWriterInput.isReadyForMoreMediaData else { return }
  guard pixelBufferAdaptor.append(pixelBuffer, withPresentationTime: time) else {
    if assetWriter.status == .failed { throw assetWriter.error ?? Error.unknown }
    return
}

  let seconds = time.seconds
  duration += seconds - lastSeconds
  lastSeconds = seconds
}

Here I want to get the CMTime here to save with my ARFrame data.

Thanks a lot

v-grigoriev commented 2 years ago

I think you can implement your own AVAssetWriter and use

func capturePixelBuffers(
    handler: @escaping (CVPixelBuffer, CMTime) -> Void
  ) -> PixelBufferOutput

to supply it with pixel buffers.