0

I imported CameraManager in a Swift project to easily capture video in my app. But I'm not sure how to export the captured video to my iOS folder following this code :

cameraManager.stopVideoRecording({ (videoURL, error) -> Void in
NSFileManager.defaultManager().copyItemAtURL(videoURL, toURL: 
self.myVideoURL, error: &error)
}) 

In Swift 4, I needed this updated code :

cameraManager.stopVideoRecording({ (videoURL, error) -> Void in
        FileManager.default.copyItem(at: videoURL, to: self.videoURL)
    })

I think I need to change this value but...

self.videoURL

If anyone could help !

Thanks a lot

Kouzkar
  • 29
  • 7

1 Answers1

0

CameraManager is not providing any out of the box API to save the video to the iOS library (as of latest version 4.3.0).

However, Once the video is taken - it gives the URL for the video file and we can save that video to the library easily by using Apple's Photos API.

PHPhotoLibrary.shared().performChanges({
    PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: self.videoURL)
}) { saved, error in
    if saved {
        // Video saved successfully
    }
}

Don't forgot to import Photos and add Privacy - Photo Library Usage Description to your info.plist

More info can be found from SO answers

Bluewings
  • 3,438
  • 3
  • 18
  • 31