Reputation: 115
Here's my code:
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
NSURL *videoURL =[info objectForKey:UIImagePickerControllerMediaURL];
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:videoURL]) {
[library writeVideoAtPathToSavedPhotosAlbum:videoURL completionBlock:^(NSURL *assetURL, NSError *error) {
if (error) {
NSLog(@"error");
} else {
NSLog(@"video assetUrl is %@", assetURL);
}
}];
}
else NSLog(@"videoAtPath is not compatible with photos Album.");
The videoURL is file:///private/var/mobile/Containers/Data/Application/B1F512EA-6D13-4DF1-86DB-F6166F0D533F/tmp/capture-T0x17511a30.tmp.pG4PbH/capturedvideo.MOV
I keep getting error when saving the video to the saved photo album. And this is return message:
Video /private/var/mobile/Containers/Data/Application/B1F512EA-6D13-4DF1-86DB-F6166F0D533F/tmp/capture-T0x17511a30.tmp.pG4PbH/capturedvideo.MOV cannot be saved to the saved photos album: Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." UserInfo=0x1b3e5e40 {NSErrorFailingURLStringKey=file:///private/var/mobile/Containers/Data/Application/B1F512EA-6D13-4DF1-86DB-F6166F0D533F/tmp/capture-T0x17511a30.tmp.pG4PbH/capturedvideo.MOV, NSErrorFailingURLKey=file:///private/var/mobile/Containers/Data/Application/B1F512EA-6D13-4DF1-86DB-F6166F0D533F/tmp/capture-T0x17511a30.tmp.pG4PbH/capturedvideo.MOV, NSLocalizedDescription=The requested URL was not found on this server., NSUnderlyingError=0x1b2ce310 "The operation couldn’t be completed. No such file or directory", NSURL=file:///private/var/mobile/Containers/Data/Application/B1F512EA-6D13-4DF1-86DB-F6166F0D533F/tmp/capture-T0x17511a30.tmp.pG4PbH/capturedvideo.MOV}
Upvotes: 0
Views: 2771
Reputation: 786
The error message says your file doesn't exist, so possibilities are:
File address is not correct, you can check it by look into the sandbox of your app to see whether the video file physically exists. If exist, check whether the video is valid and playable. Invalid video will be rejected to be saved to album.
Or your capture module didn't work, so you are expecting some file to be written in the directory, but it didn't happen because capture failed.
Upvotes: 1