I'm measuring times from tens of seconds to minutes depending on the size of the video. Shouldn't this change request be fast (local flash disk copy/meta data/checksums) as it adds a local video to the photolibrary/camera roll? This issue appears to occur when iCloud backups are turned on. I haven't been able to find much helpful information through web search or the apple dev docs.
Sample code:
func exportAssetToPhotoLibrary(videoURL: NSURL, _ exportedAsset: (localIdentifier: String) -> Void) {
var localIdentifier = ""
var startTime = NSDate.timeIntervalSinceReferenceDate()
PHPhotoLibrary.sharedPhotoLibrary().performChanges({
let assetRequest = PHAssetChangeRequest.creationRequestForAssetFromVideoAtFileURL(videoURL)
let assetPlaceholder = assetRequest.placeholderForCreatedAsset
localIdentifier = assetPlaceholder.localIdentifier
},
completionHandler: { success, error in
var elapsedTime: NSTimeInterval = NSDate.timeIntervalSinceReferenceDate() - startTime
NSLog("exported cameo video to photo library \(elapsedTime)")
exportedAsset(localIdentifier: localIdentifier)
})
}