Moving Video To Photo Library (Swift)

I'm trying to move a video to the photo library and I'm getting very unhelpful errors. Is there any way to get more detailed error information, or is there some place I can look them up?

I've verified that the movie exists by downloading the app data via devices/xcode and the movie plays fine on my macbook.

I have a full help request on StackOverflow with a link to the project (that it does not let me post here): https://stackoverflow.com/questions/63575539/swift-ios-save-video-to-library

I've tried:
Code Block func saveVideoToLibrary(videoURL: NSURL) {
    PHPhotoLibrary.requestAuthorization { status in
      // Return if unauthorized
      guard status == .authorized else {
        print("Error saving video: unauthorized access")
        return
      }
      PHPhotoLibrary.shared().performChanges({
        PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: videoURL as URL)
      }) { success, error in
        if !success {
          print("Error saving video: \(String(describing: error))")
        }
      }
    }
  }


with Error: Error saving video: Optional(Error Domain=PHPhotosErrorDomain Code=-1 "(null)")

and

Code Block
UISaveVideoAtPathToSavedPhotosAlbum(
            videoPath,
            self,
            #selector(self.video(_:didFinishSavingWithError:contextInfo:)),
            nil)

with Error:
Domain=ALAssetsLibraryErrorDomain Code=-1 "Unknown error" UserInfo= ...... {Error Domain=com.apple.photos.error Code=42001 "(null)"

both compile fine and are called. But end up giving me errors that do not help in the slightest.


Replies

Looks like AVFoundation is not involved here, so you'll probably want to ask this in the Photos section of the forums.
I'm using AVFoundation / AVAssetWriter to create the video and it's possible something about the video is causing the issues. I really do not know.
That is certainly possible, but you'd need to learn why ALAssetsLibrary is rejecting the video first.
  • 1

how to reslove it