How to make PHLivePhoto from Mov File?

白昼怎懂夜的黑 提交于 2019-12-01 10:50:43

问题


I have a one .MOV file and one .JPG file. When I'm trying to make a Live Photo:

func makeLivePhotoFromItems(imageURL: NSURL, videoURL: NSURL, previewImage: UIImage, completion: (livePhoto: PHLivePhoto) -> Void) {
    PHLivePhoto.requestLivePhotoWithResourceFileURLs([imageURL, videoURL], placeholderImage: previewImage, targetSize: CGSizeZero, contentMode: PHImageContentMode.AspectFit) {
        (livePhoto, infoDict) -> Void in
        print("info: \(livePhoto)")

        if let lp = livePhoto {
            completion(livePhoto: lp)
        }
    }
}

And making like this:

  makeLivePhotoFromItems(url, videoURL: movURL, previewImage: UIImage(named: "preview")!) { (livePhoto) in

     }

its not working. Live photo not creating and console writes:

info: Optional(<PHLivePhoto: 0x10077f660>)
complete
info: Optional(<PHLivePhoto: 0x10143ef30>)
complete
2016-05-03 13:23:18.191 LivePhoto[2170:982987] Error: Invalid video metadata
info: nil

I am really hopes, that you can help me.


回答1:


the image and mov file must have the same identifier(NSString *assetIdentifier = [[NSUUID UUID] UUIDString]),and the key of mov in metadata must be @"com.apple.quicktime.content.identifier"



来源:https://stackoverflow.com/questions/37001612/how-to-make-phlivephoto-from-mov-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!