How to save live photo?

1.3k views Asked by At
PHPhotoLibrary.shared().performChanges({ () -> Void in

let request = PHAssetCreationRequest.forAsset()
request.addResource(with: .pairedVideo, fileURL: videoURL, options: nil)

request.addResource(with: .photo, fileURL: imageURL, options: nil)}, completionHandler: { (result : Bool, error : Error?) -> Void in
    if result {
        NSLog("save to camera roll as live photo")
    } else {
        if error != nil {
            print("something wrong when saving : %@", error!)
        }
    }
})

but, Error Domain=NSCocoaErrorDomain Code=-1 "(null)".How to fix it?

1

There are 1 answers

3
j.thome On BEST ANSWER

fixed.The jpg and mov must add metadata.

1.jpg,must add metadata: 17:UUID().uuidString

2.mov,must add metadata :com.apple.quicktime.content.identifier:UUID().uuidString