                             }
                             
                         } else {
-                            writer.endSession(atSourceTime: (self.sessionCurrentClipDuration + self.startTimestamp))
+                            writer.endSession(atSourceTime: (self._currentClipDuration + self._startTimestamp))
                             writer.finishWriting(completionHandler: {
                                 // TODO support info dictionaries
                                 self.appendClip(withClipURL: writer.outputURL, infoDict: nil, error: writer.error, completionHandler: completionHandler)

    internal func destroyWriter() {
        self._writer = nil
        self._clipStarted = false
        self.timeOffset = kCMTimeZero
        self.startTimestamp = kCMTimeInvalid
        self.sessionCurrentClipDuration = kCMTimeZero
        self.sessionCurrentClipHasVideo = false
        self.sessionCurrentClipHasAudio = false
    }
}


            if self.clips.count > 0 {
                if let clipToRemove = self.clips.last {
                    self.remove(clip: clipToRemove)
                    self._duration = self._duration - clipToRemove.duration
                }
            }
        }
