fix: Fully synchronize buffers in RecordingSession to account for late-running frames (#2206)

* fix: Fully synchronize `RecordingSession` to account for late Frames

* Restructure Code

* Update RecordingSession.swift

* Fix last audio timestamp not being used

* fix: Remove `capture/aborted` error

* Update RecordingSession.swift

* Don't log for every Frame

* Format
This commit is contained in:
Marc Rousavy
2023-11-23 18:17:15 +01:00
committed by GitHub
parent 29e649937e
commit 1767e6e881
4 changed files with 171 additions and 81 deletions

View File

@@ -273,11 +273,11 @@ class CameraSession: NSObject, AVCaptureVideoDataOutputSampleBufferDelegate, AVC
switch captureOutput {
case is AVCaptureVideoDataOutput:
// Write the Video Buffer to the .mov/.mp4 file, this is the first timestamp if nothing has been recorded yet
recordingSession.appendBuffer(sampleBuffer, type: .video)
recordingSession.appendBuffer(sampleBuffer, clock: captureSession.clock, type: .video)
case is AVCaptureAudioDataOutput:
// Synchronize the Audio Buffer with the Video Session's time because it's two separate AVCaptureSessions
audioCaptureSession.synchronizeBuffer(sampleBuffer, toSession: captureSession)
recordingSession.appendBuffer(sampleBuffer, type: .audio)
recordingSession.appendBuffer(sampleBuffer, clock: audioCaptureSession.clock, type: .audio)
default:
break
}