fix: Fix first Frame not being written in Video (#2228)
* fix: Fix first Frame not being written in Video * Update Podfile.lock
This commit is contained in:
@@ -194,11 +194,7 @@ class RecordingSession {
|
||||
- Use bufferType to specify if this is a video or audio frame.
|
||||
*/
|
||||
func appendBuffer(_ buffer: CMSampleBuffer, clock _: CMClock, type bufferType: BufferType) {
|
||||
// 1. Check if the data is even ready
|
||||
guard let startTimestamp = startTimestamp else {
|
||||
// Session not yet started
|
||||
return
|
||||
}
|
||||
// 1. Prepare the data
|
||||
guard !isFinishing else {
|
||||
// Session is already finishing, can't write anything more
|
||||
return
|
||||
@@ -212,15 +208,8 @@ class RecordingSession {
|
||||
return
|
||||
}
|
||||
|
||||
// 2. Check the timing of the buffer and make sure it's within our session start and stop times
|
||||
// 2. Check the timing of the buffer and make sure it's not after we requested a session stop
|
||||
let timestamp = CMSampleBufferGetPresentationTimeStamp(buffer)
|
||||
if timestamp < startTimestamp {
|
||||
// Don't write this Frame, it was captured before we even started recording.
|
||||
// The reason this can happen is because the capture pipeline can have a delay, e.g. because of stabilization.
|
||||
let delay = CMTimeSubtract(startTimestamp, timestamp)
|
||||
ReactLogger.log(level: .info, message: "Capture Pipeline has a delay of \(delay.seconds) seconds. Skipping this late Frame...")
|
||||
return
|
||||
}
|
||||
if let stopTimestamp = stopTimestamp,
|
||||
timestamp >= stopTimestamp {
|
||||
// This Frame is exactly at, or after the point in time when RecordingSession.stop() has been called.
|
||||
@@ -231,13 +220,13 @@ class RecordingSession {
|
||||
// already wrote last Video Frame before, so skip this one.
|
||||
return
|
||||
}
|
||||
hasWrittenLastVideoFrame = true // flip to true, then write it
|
||||
hasWrittenLastVideoFrame = true // flip to true, then fallthrough & write it
|
||||
case .audio:
|
||||
if hasWrittenLastAudioFrame {
|
||||
// already wrote last Audio Frame before, so skip this one.
|
||||
return
|
||||
}
|
||||
hasWrittenLastAudioFrame = true // flip to true, then write it
|
||||
hasWrittenLastAudioFrame = true // flip to true, then fallthrough & write it
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user