I found that VLC.app save video to album quickly. But my code will cost long time. Or it crash. How can I optimazed it. (compare with same large video)
Here is my code.
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
assetId = [PHAssetCreationRequest creationRequestForAssetFromVideoAtFileURL:fileUrl].placeholderForCreatedAsset.localIdentifier;
} completionHandler:^(BOOL success, NSError * _Nullable error) {
if (!success) {
if(onError)onError(error);
return ;
}
PHAssetCollection *collection = [self getAlbumCollection:collectionStr];
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetCollectionChangeRequest *request = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:collection];
PHAsset *asset = [PHAsset fetchAssetsWithLocalIdentifiers:@[assetId] options:nil].firstObject;
[request addAssets:@[asset]];
} completionHandler:^(BOOL success, NSError * _Nullable error) {
if (!success) {
if(onError)onError(error);
return;
}
if(onComplete)onComplete(fileUrl);
}];
}];