We have gotten reports of issues with recording slow motion videos in our application. We have tested the issue on iPhone X, iPhone 6, and iPhone SE. The 6 and the X both work fine, but the SE fails when attempting to add the recorded video to Photos.
The video file to be added to Photos:
Our code adding the video:
PHPhotoLibrary.shared().performChanges {
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: url)
}
The returned error doesn't provide much useful information, which appears to be a recurring issue when working with Photos.
Error Domain=NSCocoaErrorDomain Code=-1 "(null)"
We apply an aspect ratio to the videos using the encoder setting's clean aperture parameters. Apparently, changing the video aspect ratio affects the result (see the list at the bottom).
We have tried:
Once again - everything works fine on iPhone X and 6.
The resolution-fps-ratio combinations and their result:
1080p
720p
Have you got any clue what the issue might be?
EDIT #4
Ok this one came back to bite me again, and I probably spent another two hours trying to figure out how it regressed since the code was not touched and previously confirmed working. I initially thought it had to be device or encoding related. I ended up "fixing" it, but it makes zero sense to me. The issue was resolved after I appended .mov
to the local file that was being used to store the remote video after downloading. Why appending an arbitrary extension to the file path makes a difference is beyond me.
let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let temporaryFilename = "\(ProcessInfo().globallyUniqueString).mov"
let fileURL = documentsURL.appendingPathComponent(temporaryFilename)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With