How to get metadata/exif from a mp4 in iOS?
I have a UIImagePickerController to pick a video with. How can I view the exif data of the video and or the metadata? This is what I have tried so far. What else can I try? Here is a sample file I've been using. https://drive.google.com/file/d/0B6zrWYe4_e7iNVM4MWRXTjRnWk0/edit?usp=sharing
-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info{
//method 1
NSLog(@"%@",info);
NSURL* assetURL=[info objectForKey:UIImagePickerControllerReferenceURL];
//This is what my asseturl looks like
//assets-library://asset/asset.MP4?id=A37A6038-DAA7-4D96-B0C6-1A5E1FC6D8F9&ext=MP4
NSString* value=NULL;
[assetURL getResourceValue:&value forKey:NSURLFileSizeKey error:nil];
NSLog(@"%@",value); //this is always nil
//method 2
AVURLAsset *videoAss = [AVURLAsset assetWithURL:assetURL];
//I get nothing back from this
NSLog(@"%@",[videoAss metadataForFormat:AVMetadataKeySpaceQuickTimeMetadata]);
//I get nothing back from this either
NSLog(@"%@",[videoAss metadataForFormat:AVMetadataKeySpaceCommon]);
//method 3
ALAssetsLibrary *assetLibrary=[[ALAssetsLibrary alloc]init];
[assetLibrary assetForURL:assetURL resultBlock:^(ALAsset *asset) {
//My asset is non nil
NSLog(@"%@",asset);
ALAssetRepresentation* rep=[asset defaultRepresentation];
//My metaData is nil.
NSDictionary* metaData=[rep metadata];
NSLog(@"%@",metaData);
} failureBlock:^(NSError *error) {
NSLog(error);
}];
}
链接地址: http://www.djcxy.com/p/66068.html