Search code examples
iosios7phassetphotokitphassetcollection

PHAsset video get exifInfo (metadata)


I want to get Exif information for a video file.

Below is the code to get Exif for image but it doesn't seems to work for videos.

[[PHImageManager defaultManager] requestImageDataForAsset:photoAsset
                                              options:reqOptions
                                        resultHandler:
     ^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
         CIImage* ciImage = [CIImage imageWithData:imageData];
         DLog(@"Metadata : %@", ciImage.properties);
     }];

Is there any way to get the exif without writing the file into disk ?


Solution

  • To get metadata for video file use below API where the information is in AVAsset object.

        - (PHImageRequestID)requestAVAssetForVideo:(PHAsset *)asset options:(nullable PHVideoRequestOptions *)options 
                    resultHandler:(void (^)(AVAsset *__nullable asset, AVAudioMix *__nullable audioMix, NSDictionary *__nullable info))resultHandler;