令人惊讶的是,您可以将PHImageManager.requestImageDataAndOrientation用于VIDEO资产。
Xcode 12.5
iPhone SE 2020 (iOS 14.6)
观察
let imageManager = PHImageManager.default()
imageManager.requestImageDataAndOrientation(for: videoPHAsset, options: nil) { (data, string, orientation, info) in
if let data = data, let ciImage = CIImage(data: data) {
print(ciImage.properties)
}
}
序列ciImage.properties
化为 JSON 后,我得到了以下结果。
1.视频(后置摄像头)
{"ColorModel":"RGB","PixelHeight":1920,"{Exif}":{"ColorSpace":1,"PixelXDimension":1080,"ExifVersion":[2,2,1],"FlashPixVersion":[1,0],"PixelYDimension":1920,"SceneCaptureType":0,"ComponentsConfiguration":[1,2,3,0]},"ProfileName":"HDTV","DPIHeight":72,"PixelWidth":1080,"{TIFF}":{"YResolution":72,"ResolutionUnit":2,"XResolution":72},"{JFIF}":{"DensityUnit":0,"YDensity":72,"JFIFVersion":[1,0,1],"XDensity":72},"Depth":8,"DPIWidth":72}
2.视频(前置摄像头)
{"Depth":8,"{TIFF}":{"YResolution":72,"ResolutionUnit":2,"XResolution":72},"PixelHeight":1334,"{JFIF}":{"DensityUnit":0,"YDensity":72,"JFIFVersion":[1,0,1],"XDensity":72},"ProfileName":"sRGB IEC61966-2.1","PixelWidth":750,"ColorModel":"RGB","DPIHeight":72,"DPIWidth":72,"{Exif}":{"ColorSpace":1,"PixelXDimension":750,"ExifVersion":[2,2,1],"FlashPixVersion":[1,0],"PixelYDimension":1334,"SceneCaptureType":0,"ComponentsConfiguration":[1,2,3,0]}}
3. 截图
{"ColorModel":"RGB","{Exif}":{"PixelXDimension":750,"PixelYDimension":1334,"DateTimeOriginal":"2021:01:21 14:25:56","UserComment":"Screenshot"},"{PNG}":{"InterlaceType":0},"HasAlpha":true,"Depth":16,"{TIFF}":{"Orientation":1},"PixelHeight":1334,"ProfileName":"Display P3","PixelWidth":750,"Orientation":1}
4. 照片(有大量信息和 JSON 序列化崩溃,所以我只提取了“{Exif}”部分)
{"ExifVersion":[2,3,1],"Flash":24,"LensModel":"iPhone SE (2nd generation) back camera 3.99mm f\\/1.8","OffsetTimeDigitized":"+05:30","SubsecTimeOriginal":"630","LensSpecification":[3.990000009536743,3.990000009536743,1.7999999523162842,1.7999999523162842],"ExposureMode":0,"CompositeImage":2,"LensMake":"Apple","FNumber":1.8,"OffsetTimeOriginal":"+05:30","PixelYDimension":3024,"ApertureValue":1.6959938128383605,"ExposureBiasValue":0,"MeteringMode":5,"ISOSpeedRatings":[400],"ShutterSpeedValue":4.6443251405083465,"SceneCaptureType":0,"FocalLength":3.99,"DateTimeOriginal":"2021:01:21 20:47:05","SceneType":1,"FlashPixVersion":[1,0],"ColorSpace":65535,"SubjectArea":[2013,1511,2217,1330],"PixelXDimension":4032,"FocalLenIn35mmFilm":28,"SubsecTimeDigitized":"630","OffsetTime":"+05:30","SensingMethod":2,"BrightnessValue":0.06030004492448258,"DateTimeDigitized":"2021:01:21 20:47:05","ComponentsConfiguration":[1,2,3,0],"WhiteBalance":0,"ExposureTime":0.04,"ExposureProgram":2}
视频有"ExifVersion":[2,2,1]
,照片有"ExifVersion":[2,3,1]
。_ 视频的 exif 根本不提供有关相机的任何有用信息 - 而照片的 exif 则提供。所有视频和照片都是在同一部手机上拍摄的。
在这一点上,如果这些信息甚至被编码到视频帧中,仍然一无所知。