         var frameDuration = minFrameDuration
         let offsetBufferTimestamp = timestamp - self._timeOffset
         
-        if let videoConfig = self._videoConfiguration, let timeScale = videoConfig.timescale {
-            if timeScale != 1.0 {
-                let scaledDuration = CMTimeMultiplyByFloat64(duration, timeScale)
-                if self._currentClipDuration.value > 0 {
-                    self._timeOffset = self._timeOffset + (duration - scaledDuration)
-                }
-                frameDuration = scaledDuration
-            }
-        }
-        
-        if let videoInput = self._videoInput, let pixelBufferAdapter = self._pixelBufferAdapter {
-            if videoInput.isReadyForMoreMediaData {
-                
-                var bufferToProcess: CVPixelBuffer? = nil
-                if let customImageBuffer = customImageBuffer {
-                    bufferToProcess = customImageBuffer
-                } else {
-                    bufferToProcess = pixelBuffer
-                }
-                
-                if let bufferToProcess = bufferToProcess {
-                    if pixelBufferAdapter.append(bufferToProcess, withPresentationTime: offsetBufferTimestamp) {
-                        self._currentClipDuration = (offsetBufferTimestamp + frameDuration) - self._startTimestamp
-                        self._lastVideoTimestamp = timestamp
-                        self._currentClipHasVideo = true
-                        completionHandler(true)
-                        return
-                    }
-                }
-                
+        if let videoConfig = self._videoConfiguration,
+            let timeScale = videoConfig.timescale,
+            timeScale != 1.0 {
+            let scaledDuration = CMTimeMultiplyByFloat64(duration, timeScale)
+            if self._currentClipDuration.value > 0 {
+                self._timeOffset = self._timeOffset + (duration - scaledDuration)
+            }
+            frameDuration = scaledDuration
+        }
+        
+        if let videoInput = self._videoInput,
+            let pixelBufferAdapter = self._pixelBufferAdapter,
+            videoInput.isReadyForMoreMediaData {
+            
+            var bufferToProcess: CVPixelBuffer? = nil
+            if let customImageBuffer = customImageBuffer {
+                bufferToProcess = customImageBuffer
+            } else {
+                bufferToProcess = pixelBuffer
+            }
+            
+            if let bufferToProcess = bufferToProcess,
+                pixelBufferAdapter.append(bufferToProcess, withPresentationTime: offsetBufferTimestamp) {
+                self._currentClipDuration = (offsetBufferTimestamp + frameDuration) - self._startTimestamp
+                self._lastVideoTimestamp = timestamp
+                self._currentClipHasVideo = true
+                completionHandler(true)
+                return
             }
         }
         

            let lastTimestamp = presentationTimestamp + duration
            
            self._audioQueue.async {
                if let audioInput = self._audioInput {
                    if audioInput.isReadyForMoreMediaData && audioInput.append(adjustedBuffer) {
                        self._lastAudioTimestamp = lastTimestamp
                        
                        if !self.currentClipHasVideo {
                            self._currentClipDuration = lastTimestamp - self._startTimestamp
                        }
                        
                        self._currentClipHasAudio = true
                        
                        completionHandler(true)
                        return
                    }
                }
                completionHandler(false)
            }

    public var lastClipUrl: URL? {
        get {
            var lastClipUrl: URL? = nil
            if !self._clips.isEmpty,
                let lastClip: NextLevelClip = self.clips.last,
                let clipURL = lastClip.url {
                lastClipUrl = clipURL
            }
            return lastClipUrl
        }
