-[AVAssetWriterInput markAsFinished] Can’t name technique when standing is 0′ digital camera file Swift iOS

[ad_1]

I am utilizing AVAssetWriterInput to file video however after I wish to cease recording I am getting this error solely 1/10 instances.

-[AVAssetWriterInput markAsFinished] Can't name technique when standing is 0'

Right here is the cease technique :

func stopRecording(completion: ((String?)-> Void)? = nil) {
        sessionQueue.async { [self] in
            guard let captureSession = self.session, captureSession.isRunning else {
                print(CameraControllerError.captureSessionIsMissing)
                completion?(nil)
                return
            }
            
            if(!isRecording) {
                completion?(nil)
                return
            }
            
            isRecording = false
     
            do {
                if (assetWriter?.standing == .writing) {
                    videoWriterInput?.markAsFinished()
                    audioWriterInput?.markAsFinished()
                    videoWriterInputPixelBufferAdaptor!.assetWriterInput.markAsFinished()
                    print("video completed")
                    print("audio completed")
                } else{
                    print("not writing")
                }
                
                
                self.assetWriter?.finishWriting() {
                    print("completed writing")
                }
                
            }
            catch {
                if let e=self.assetWriter?.error{
                    print("cease file error:", e)
                }
            }
            
            if(self.audioCaptureSession!.isRunning) {
            let inputs = self.audioCaptureSession!.inputs
            for oldInput:AVCaptureInput in inputs {
                self.audioCaptureSession!.removeInput(oldInput)
            }
            let outputs = self.audioCaptureSession!.outputs
            for oldOutput:AVCaptureOutput in outputs {
                self.audioCaptureSession!.removeOutput(oldOutput)
            }
            self.audioCaptureSession!.stopRunning()
            }
            
            self.audioCaptureSession = nil
            
            let path = assetWriter?.outputURL.path
            self.videoRecordCompletionBlock?(path)
            videoWriterInputPixelBufferAdaptor = nil
        }
    }

What does imply this error and why this it taking place ?

Perhaps the issue is inside one other a part of my digital camera config which is massive and complicated, however higher perceive the explanation of this error, which I did not discovered, will assist me lots to repair the scenario so thanks for any assist or explanations

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *