fix: Synchronize Audio Frames with Video Frames using masterClock (#161)

* Synchronize Audio Frames with Video Frames using `masterClock`

* Update CameraView+RecordVideo.swift
This commit is contained in:
Marc Rousavy
2021-06-03 14:50:08 +02:00
committed by GitHub
parent aaad8fc94a
commit ca0c0e92e0
2 changed files with 6 additions and 4 deletions

View File

@@ -152,9 +152,12 @@ extension CameraView: AVCaptureVideoDataOutputSampleBufferDelegate, AVCaptureAud
}
switch captureOutput {
case is AVCaptureVideoDataOutput:
recordingSession.appendBuffer(sampleBuffer, type: .video)
recordingSession.appendBuffer(sampleBuffer, type: .video, timestamp: CMSampleBufferGetPresentationTimeStamp(sampleBuffer))
case is AVCaptureAudioDataOutput:
recordingSession.appendBuffer(sampleBuffer, type: .audio)
let timestamp = CMSyncConvertTime(CMSampleBufferGetPresentationTimeStamp(sampleBuffer),
from: audioCaptureSession.masterClock!,
to: captureSession.masterClock!)
recordingSession.appendBuffer(sampleBuffer, type: .audio, timestamp: timestamp)
default:
break
}