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:
		@@ -507,7 +507,7 @@ PODS:
 | 
			
		||||
    - libwebp (~> 1.0)
 | 
			
		||||
    - SDWebImage/Core (~> 5.10)
 | 
			
		||||
  - SocketRocket (0.6.1)
 | 
			
		||||
  - VisionCamera (3.6.9):
 | 
			
		||||
  - VisionCamera (3.6.11):
 | 
			
		||||
    - React
 | 
			
		||||
    - React-callinvoker
 | 
			
		||||
    - React-Core
 | 
			
		||||
@@ -747,9 +747,9 @@ SPEC CHECKSUMS:
 | 
			
		||||
  SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d
 | 
			
		||||
  SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
 | 
			
		||||
  SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
 | 
			
		||||
  VisionCamera: aa2ce576c146a5e9afcbfe30e5464a311e275b8a
 | 
			
		||||
  VisionCamera: b35fc51a521ce0a9b9da41d8b13127e3d414d195
 | 
			
		||||
  Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce
 | 
			
		||||
 | 
			
		||||
PODFILE CHECKSUM: 27f53791141a3303d814e09b55770336416ff4eb
 | 
			
		||||
 | 
			
		||||
COCOAPODS: 1.14.2
 | 
			
		||||
COCOAPODS: 1.14.3
 | 
			
		||||
 
 | 
			
		||||
@@ -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