react-native-cameraroll: iOS - Large Files/Video - Can't save (to camera roll). [PHPhotosErrorDomain error -1]
Bug report
iOS - Photo’s successfully save to camera roll but videos (or large files maybe?) do not.
I’ll give as much detail as I can at the moment
Summary
I call path = await CameraRoll.save(path);
where path
is a local path to a downloaded mp4 file.
The JS hands over to the Objective C side.
The code successfully reaches here with a populated placeholder
object:
https://github.com/react-native-community/react-native-cameraroll/blob/master/ios/RNCCameraRollManager.m#L145
The code then continues but when completionHandler
is called, success is NO
https://github.com/react-native-community/react-native-cameraroll/blob/master/ios/RNCCameraRollManager.m#L152
The error returned is:
[Error: The operation couldn’t be completed. (PHPhotosErrorDomain error -1.)]
update: This seems to be a file size or maybe image dimension issue. Some videos work but others fail.
Fail: 20MB, 2160 × 4096 (portrait) Success: 18MB 4096 × 2160 (landscape)
Environment info
RN 0.62.2 React: 16.11.0 Library version: 1.7.1
- Download a large file size MP4 from remote URL to local (using
RNFetchBlob
) - Take local path for downloaded file and call:
const camerarollpath = await CameraRoll.save(localpath);
- See error as per description above.
Describe what you expected to happen:
- Video is saved to camera roll and
camerarollpath
is set
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (4 by maintainers)
I solved it like: First of all, download it via RNFS then move it to CameraRoll
@scgough more than renaming would be interesting to check similar file, e.g. big 4k portrait in .mov format if they have same issues (I don’t think renaming should make any difference honestly, I am more curious about format/codec mp4 vs mov). Since the native format that iOS shoot is .mov, wondering if it’s an issues specifically with some .mp4 format more than a file size issue. Also 20MB is not big for a video.
@scgough I see that in the JS package there is some autodetection based on the tag passed: https://github.com/react-native-community/react-native-cameraroll/blob/master/js/CameraRoll.js#L167 so probably that’s why go into the video path. I was just looking at the native code 😕