Apple Live Photo 文件格式

Apple Live Photo file format

Apple 将在 iOS 9/iPhone 6 秒内推出 Live Photo。文件格式记录在哪里?

这是link。否则,这里是文本:

Live Photos

Live Photos is a new feature of iOS 9 that allows users to capture and relive their favorite moments with richer context than traditional photos. When the user presses the shutter button, the Camera app captures much more content along with the regular photo, including audio and additional frames before and after the photo. When browsing through these photos, users can interact with them and play back all the captured content, making the photos come to life.

iOS 9.1 introduces APIs that allow apps to incorporate playback of Live Photos, as well as export the data for sharing. There is new support in the Photos framework to fetch a PHLivePhoto object from the PHImageManager object, which is used to represent all the data that comprises a Live Photo. You can use a PHLivePhotoView object (defined in the PhotosUI framework) to display the contents of a Live Photo. The PHLivePhotoView view takes care of displaying the image, handling all user interaction, and applying the visual treatments to play back the content.

You can also use PHAssetResource to access the data of a PHLivePhoto object for sharing purposes. You can request a PHLivePhoto object for an asset in the user’s photo library by using PHImageManager or UIImagePickerController. If you have a sharing extension, you can also get PHLivePhoto objects by using NSItemProvider. On the receiving side of a share, you can recreate a PHLivePhoto object from the set of files originally exported by the sender.

Guidelines for Displaying Live Photos

It’s important to remember that a Live Photo is still a photo. If you have to display a Live Photo in an environment that doesn’t support PHLivePhotoView, it’s recommended that you present it as a regular photo.

Don’t display the extra frames and audio of a Live Photo separately. It's important that the content of the Live Photo be presented in a consistent way that uses the same visual treatment and interaction model in all apps.

It’s recommended that you identify a photo as a Live Photo by placing the badge provided by the PHLivePhotoView class method livePhotoBadgeImageWithOptions:PHLivePhotoBadgeOptionsOverContent in the top-left corner of the photo.

Note that there is no support for providing the visual effect that users experience as they swipe through photos in the Photos app.

Guidelines for Sharing Live Photos

The data of a Live Photo is exported as a set of files in a PHAssetResource object. The set of files must be preserved as a unit when you upload them to a server. When you rebuild a PHLivePhoto with these files on the receiver side, the files are validated; loading fails if the files don’t come from the same asset.

If your app lets users apply effects or adjustments to a photo before sharing it, be sure to apply the same adjustments to all frames of the Live Photo. Alternatively, if you don’t support adjusting the entire contents of a Live Photo, share it as a regular photo and show an appropriate indication to the user.

If your app has UI for picking photos to share, you should let users play back the entire contents so they know exactly what they are sharing.When selecting photos to share in your app, users should also be able to turn a Live Photo off, so they can post it as a traditional photo.

在文档之外,Live Photos 由 2 个资源组成,一个图像和一个 mov(quicktime 电影文件)。所以每个 Live Photo 都有 2 'actual' 个文件,由 Live Photo 类型的包装器连接。

Live Photos其实是两个文件。原始 JPEG 图片和全高清视频。

一张实况照片有两个资源。它们与资产标识符(UUID 作为字符串)绑定在一起。

  1. 一张JPEG;这必须有 kCGImagePropertyMakerAppleDictionary[17 : assetIdentifier] 的元数据条目(17 是 Apple Maker Note 资产标识符密钥)。
  2. 使用 H.264 以适当的帧速率 (12-15fps) 和大小 (1080p) 编码的 Quicktime MOV。此 MOV 必须具有:
    • ["com.apple.quicktime.content.identifier" : assetIdentifier] 的顶级 Quicktime 元数据条目。如果使用 AVAsset 你可以从 asset.metadataForFormat(AVMetadataFormatQuickTimeMetadata)
    • ["com.apple.quicktime.still-image-time" : 0xFF]的定时元数据轨道;实际静止图像时间与此元数据项的呈现时间戳相匹配。有效载荷似乎只是一个 0xFF 字节(又名 -1),可以忽略。如果使用 AVAssetReader 您可以使用 CMSampleBufferGetOutputPresentationTimeStamp 来获得这个时间。

assetIdentifier 将这两个项目联系在一起,定时元数据轨道告诉系统静止图像在电影时间轴中的位置。

格式的统一类型标识符 (UTI) 为 kUTTypeLivePhoto / com.apple.live-photo

@available(OSX 10.12, *)
public let kUTTypeLivePhoto: CFString

/*
 *
 *  kUTTypeLivePhoto
 *
 *    Live Photo
 *
 *    UTI: com.apple.live-photo
 *
 *
 */

关于实时照片的一些附加信息:

  1. 同意,它有 .mov 文件扩展名
  2. 它保存在目录 /var/mobile/media/DCIM/100apple/ 旁边 带有jpg版本的照片
  3. 即使在没有 3D touch 的设备上也可以播放实时照片(我可以 通过长按照片在我的 ipad 2017 上播放)
  4. 老手机也能玩(比如iphone5)甚至iOS8 如果你安装 PhotosLive tweak