0

when I'm trying to save the Video that is longer than 30 min, i got this massage after the video complete downloaded "Error Domain=NSCocoaErrorDomain Code=-1 "(null)" my app is about 3 gb right know but nothing saved in my photo library.

func downloadVideo()   
{
    let destination: DownloadRequest.DownloadFileDestination = { _, _ in
        var documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first as URL!

        let pathComponent = "\(String(describing: documentsURL))/tempFile.mp4"

        documentsURL?.appendPathComponent(pathComponent)

        return (documentsURL!, [.createIntermediateDirectories, .removePreviousFile])
    }

    Alamofire.download(self.downloadUrl, to: destination).responseData { response in
        if response.destinationURL == nil{

            self.alertMessage2(titleText: "Error", messageText: "No Video URL", style: .actionSheet, actionTitle: "OK", actionStyle: .default , handler: {(action) in self.performSegue(withIdentifier: self.home, sender: self)})
            print("no url ")
            //
        }else{

            print("succes ")
            PHPhotoLibrary.shared().performChanges({
                PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: response.destinationURL!)

            }) { saved, error in
                if saved { self.alertMessage2(titleText: "Your video was successfully saved", messageText: "", style: .alert, actionTitle: "OK", actionStyle: .default , handler: {(action) in self.performSegue(withIdentifier: self.home , sender: self)})
                }else {print("fel", error!)}}
        }
        }
        .downloadProgress { progress in
            self.progressView.progress = Float(progress.fractionCompleted)
            print("Progress: \(progress.fractionCompleted)")
    }
}
kelin
  • 11,323
  • 6
  • 67
  • 104
Adam Kadri
  • 3
  • 1
  • 3
  • Have you checked the aspect ratio of your video ? Apparently all aspect ratios with different sizes are not supported. See : https://stackoverflow.com/questions/45029084/error-domain-nscocoaerrordomain-code-1-null-when-moving-mov-to-camera-roll – Antoine Dec 13 '17 at 15:04
  • It can be same video once complete downloaded and other time not. but if that can be the issue, how can I custom video size for all video ? – Adam Kadri Dec 14 '17 at 08:39

0 Answers0