diff --git a/ios/CameraView+RecordVideo.swift b/ios/CameraView+RecordVideo.swift index b4c1aeb..8a958d2 100644 --- a/ios/CameraView+RecordVideo.swift +++ b/ios/CameraView+RecordVideo.swift @@ -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 } diff --git a/ios/RecordingSession.swift b/ios/RecordingSession.swift index ffc95a0..68735c5 100644 --- a/ios/RecordingSession.swift +++ b/ios/RecordingSession.swift @@ -106,7 +106,7 @@ class RecordingSession { ReactLogger.log(level: .info, message: "Started RecordingSession at \(initialTimestamp!.seconds) seconds.") } - func appendBuffer(_ buffer: CMSampleBuffer, type bufferType: BufferType) { + func appendBuffer(_ buffer: CMSampleBuffer, type bufferType: BufferType, timestamp: CMTime) { if !CMSampleBufferDataIsReady(buffer) { return } @@ -117,7 +117,6 @@ class RecordingSession { return } - let timestamp = CMSampleBufferGetPresentationTimeStamp(buffer) latestTimestamp = timestamp switch bufferType {