Save Video Using AVFoundation Swift

后端 未结 6 1543
感情败类
感情败类 2021-02-05 08:57

Hi I followed a course by Jared Davidson to create a custom camera view and save pictures using AVFoundation. https://www.youtube.com/watch?v=w0O3ZGUS3pk

However I would

6条回答
  •  逝去的感伤
    2021-02-05 09:33

    you can use this code to save your videos in the photo library , You have to give the follwing parameters in which the most important is OutputURL.path which is filesystem path to the movie file you want to save to the Camera Roll album , For the rest of the parameters you can either pass there respective values or you can also assign nil that depends on your need

    func fileOutput(_ output: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from connections: [AVCaptureConnection], error: Error?) {
    
    if (error != nil) {
            print("Error recording movie: \(error!.localizedDescription)")
        } else {
    
    
            UISaveVideoAtPathToSavedPhotosAlbum(outputFileURL.path, nil, #selector(CameraController.video(_:didFinishSavingWithError:contextInfo:)), nil)
    
        }
        outputURL = nil
    
    }
    

提交回复
热议问题