Tell us which versions you are using:
Tell us to which platform this issue is related
Return video
Return error
Open picker
Select video
Return error
code:E_CANNOT_PROCESS_VIDEO
message:Cannot process video data
domain:RCTErrorDomain
userInfo:null
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
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 Optimize Photos on until now
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
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 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:
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-17507), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x2801f2280 {Error Domain=NSOSStatusErrorDomain Code=-17507 "(null)"}}
@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? https://github.com/ivpusic/react-native-image-crop-picker/issues/1415#issuecomment-732551876
@vladpanov Yes. Didn't work.
Not working for me as well, any help so far?
Most helpful comment
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