 
   }
 
-  public func startWriting() {
+  public func startWriting(completionHandler: (@escaping (_ success: Bool) -> Void) = {_ in }) {
 
     if isRecording { return }
     isRecording = true

      print("AVAssetWriter Failed:", "Unknown error")
      stopDisplayLink()
      cleanUp()
      return
    }

  }

  public func finishWriting(completionHandler: (@escaping (_ url: URL) -> Void)) {

    if !isRecording { return }

    videoInput.markAsFinished()



  private func startInputPipeline() -> Bool {

    if writer.status != .unknown { return false }

    guard writer.startWriting() else { return false }

    writer.startSession(atSourceTime: kCMTimeZero)
