-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed on select Video - IOS 14 #1415
Comments
Same here, iOS 14 is causing a lot of trouble |
Also experiencing the same issue with iOS 14 and iOS 14.2 beta. |
It's related to downloading images from iCloud. iOS devices can choose to store a compressed version of the video/images locally but have a full version in the iCloud. When you choose to upload a video, it first gets the full version from iCloud and then tries the upload it. When I try to upload a video that was recently viewed on my phone (which means the full version is already downloaded), there’s no problem. The problem occurs when it needs to download from iCloud |
We are also experiencing this as of iOS 14. |
It does seem related to iCloud. I didn't realize I had |
Also experiencing this issue on iOS14, but only on a physical device. On simulator iOS14, there are no issues. However, I am guessing that this is because on the simulator, the files are not stored in iCloud. |
Anyone find a solution for this yet? Also having this issue but for me it doesn't work on the simulator but does work on physical device |
Doesn't seem so. They released another version, but it does not include a fix. @ivpusic do you guys have an update on this, it is fairly critical that we are able to select an older video which may be stored on iCloud. |
I tried with a video that was sent to me by whatsapp and I passed it to diaspositive and it doesn't work so I don't think it's a problem of iCloud |
I tried with a fresh captured video and it has been selected without issues, the problem is related to iCloud videos only, I am sure now |
The following code is work, for your reference: - (void)requestVideoOutputPathWithAsset:(PHAsset *)asset presetName:(NSString *)presetName success:(void (^)(NSString *outputPath))success failure:(void (^)(NSString *errorMessage, NSError *error))failure {
if (!presetName) {
presetName = AVAssetExportPresetMediumQuality;
}
[[PHImageManager defaultManager] requestExportSessionForVideo:asset options:[self getVideoRequestOptions] exportPreset:presetName resultHandler:^(AVAssetExportSession *_Nullable exportSession, NSDictionary *_Nullable info) {
NSString *outputPath = [self getVideoOutputPath];
exportSession.outputURL = [NSURL fileURLWithPath:outputPath];
exportSession.shouldOptimizeForNetworkUse = NO;
exportSession.outputFileType = AVFileTypeMPEG4;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
[self handleVideoExportResult:exportSession outputPath:outputPath success:success failure:failure];
}];
}];
}
- (void)handleVideoExportResult:(AVAssetExportSession *)session outputPath:(NSString *)outputPath success:(void (^)(NSString *outputPath))success failure:(void (^)(NSString *errorMessage, NSError *error))failure {
dispatch_async(dispatch_get_main_queue(), ^{
switch (session.status) {
case AVAssetExportSessionStatusCompleted: {
if (success) {
success(outputPath);
}
} break;
case AVAssetExportSessionStatusFailed: {
if (failure) {
failure(@"AVAssetExportSessionStatusFailed", session.error);
}
} break;
case AVAssetExportSessionStatusCancelled: {
if (failure) {
failure(@"AVAssetExportSessionStatusCancelled", nil);
}
} break;
default: break;
}
});
}
- (PHVideoRequestOptions *)getVideoRequestOptions {
PHVideoRequestOptions* options = [[PHVideoRequestOptions alloc] init];
options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
options.networkAccessAllowed = YES;
return options;
}
- (NSString *)getVideoOutputPath {
NSDateFormatter *formater = [[NSDateFormatter alloc] init];
[formater setDateFormat:@"yyyy-MM-dd-HH:mm:ss-SSS"];
NSString *outputPath = [NSHomeDirectory() stringByAppendingFormat:@"/tmp/video-%@-%d.mp4", [formater stringFromDate:[NSDate date]], arc4random_uniform(10000000)];
return outputPath;
} |
@banchichen Can you make a PR? |
@banchichen Tried your code. Doesn't work either. I managed to find the error on the native side:
|
@luco It’s a bit strange, that piece of code works in TZImagePickerController:https://github.com/banchichen/TZImagePickerController/blob/master/TZImagePickerController/TZImagePickerController/TZImageManager.m |
Has anyone been successful in trying @banchichen code suggestion? #1415 (comment) |
@vladpanov Yes. Didn't work. |
Not working for me as well, any help so far? |
Same here, any ideas? |
I found the solution. Add this line to the getVideoAsset function |
@superandrew213 I'll give it a shot and let you know. |
@superandrew213 It works! @anhkieet Thanks a lot! I've opened a PR #1515. @ivpusic Can you merge? |
I found the solution : |
Awesome! When can we expect this to hit npm? |
Still issue for iCloud video. I use iOS 14.4 and version 0.35.3 |
How come this was solved for video and not photo? I have the same issue with iCloud photos -- anyone else? I tried adding a similar fix as suggested above but I still have the same error:
|
Still issue for iCloud video. I use iOS 14.3 and version 0.36.0 |
macOS : You can make this |
Still same issues for iCloud photos with version 0.36.0. |
@tufanlodos your suggestion creates a duplicate entry and adds the wrong deliveryMode in the video section (I ran the command once). Even after I fixed the duplicate part, the same issue happens with iCloud photos. The library freezes then crashes the app |
@guy-shahine you need to run this |
@tufanlodos save an original copy of the file. run your command once, then use a file diff to view the changes, you'll notice that the deliveryMode=... will be added twice for getVideoAsset and for the imagePickerController because options.networkAccessAllowed = YES; is found at line 467 and line 530 |
@guy-shahine try remove |
@tufanlodos I've tried many approaches. imageData is always nil for iCloud images and I see an error in the console |
Still have issue with apple m1. react native latest version.
|
react-native version 0.63.4, image-crop-picker version 0.36.3 |
I resolved this issue for videos with the following solution: Hope this helps someone. @russelRajitha You can change |
Version
Tell us which versions you are using:
Platform
Tell us to which platform this issue is related
Expected behaviour
Return video
Actual behaviour
Return error
Steps to reproduce
Open picker
Select video
Return error
Attachments
When I'm trying to debug in xcode, exportSession always return status = 4 (AVAssetExportSessionStatusFailed), and the error look like this.
Video Export Failed: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSUnderlyingError=0x2826f6730 {Error Domain=NSOSStatusErrorDomain Code=-16979 "(null)"}, NSLocalizedFailureReason=An unknown error occurred (-16979), NSURL=file:///var/mobile/Media/PhotoData/Metadata/DCIM/102APPLE/IMG_2272.medium.MP4, NSLocalizedDescription=The operation could not be completed}
[Update]
I'm trying to select few files:
Video with .MOV extension return success, but video with .MP4 return error.
Any idea why this issue exist and how to solve??
Love react-native-image-crop-picker? Please consider supporting our collective:
👉 https://opencollective.com/react-native-image-crop-picker/donate
The text was updated successfully, but these errors were encountered: