2

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.

CouchDeveloper
  • 18,174
  • 3
  • 45
  • 67
HadevsCode
  • 188
  • 1
  • 12
  • The [original code](http://stackoverflow.com/questions/33990830/working-with-live-photos-in-playground) works well. So I'd say your issue comes from the video itself, not from the code. And indeed we see "Invalid video metadata" so the problem is your video. – Eric Aya May 03 '16 at 10:28
  • @EricD yea, i think so. Its can be video problem. but i trying to use about 5 movies with different formats. This error not disappearing. How i can debug it? – HadevsCode May 03 '16 at 10:29
  • For a MOV to be usable in a LivePhoto it has to be of the same specs (max size, encoding, etc) as the Apple's ones. My suggestion is take a MOV *from* an existing LivePhoto and inspect its properties then make yours similar. – Eric Aya May 03 '16 at 10:31
  • @EricD ok , i understand you. But whats properties i should to explore? You know? – HadevsCode May 03 '16 at 10:33
  • Size (and ratio) and type of encoding are the most important properties to check. There's no official specs, though, that's why I say "inspect an existing one and take it as an example". – Eric Aya May 03 '16 at 10:34
  • @EricD ok, thank you. Last question. How can i get .mov file from LivePhoto? I imported a live photo file with Photos.app and this app export file as JPEG or etc. – HadevsCode May 03 '16 at 10:37
  • @EricD oh, nevermind. i founded it. thank you again :) – HadevsCode May 03 '16 at 10:39
  • @EricD i successfully changed preview image, but Invalid Invalid video metadata not fixed. Can i somehow change source video on new and don't changed source properties? – HadevsCode May 03 '16 at 15:40
  • @HadevsCode did you ever find a solution for this? – Richmond Watkins May 12 '16 at 14:27

1 Answers1

0

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"