如何在iOS中从mp4获取元数据/ exif?
我有一个UIImagePickerController来选择一个视频。 我如何查看视频和/或元数据的exif数据? 这是我到目前为止所尝试的。 我还能尝试什么? 这是我一直使用的示例文件。 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/66067.html