我可以使用 Image Picker 获取 .MOV 文件,但我如何才能找到它的拍摄位置和拍摄时间?
我的图片选择器: - (void) imagePickerController: (UIImagePickerController *) 选择器 didFinishPickingMediaWithInfo: (NSDictionary *) 信息 {
NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
[self dismissViewControllerAnimated:NO completion:nil];
// Handle a movie capture
if (CFStringCompare ((__bridge_retained CFStringRef)mediaType, kUTTypeMovie, 0)
== kCFCompareEqualTo) {
NSString *movieFile = [[info objectForKey:
UIImagePickerControllerMediaURL] path];
NSURL *movieURL = [NSURL fileURLWithPath:movieFile];
NSLog(@"Movie File %@",movieURL);
[self dismissViewControllerAnimated:YES completion:nil];
}
}
最佳答案
我不知道它被拍摄的位置,但你可以使用 File Attribute Keys
使用 attributesOfItemAtPath:error:
获取 NSFileCreationDate
. NSDictionary
上有一个方便的方法 fileCreationDate
NSError *error;
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:movieFile error:&error];
if (!attributes) {
// Use the error
}
NSDate *createdDate = [attributes fileCreationDate];
如果您想访问 MOV 文件中的元数据,您可以查看 EXIF数据,不过我不知道是否有适用于此的 iOS 库。
关于ios - 获取 iOS 视频的时间戳/位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22337019/