ios - 获取 iOS 视频的时间戳/位置

标签 ios objective-c cocoa-touch

我可以使用 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/

相关文章:

ios - iPhone 的 UIPopoverController 通过实现类别

ios - 如何在 UICollectionView 中添加 Load more cell?

ios - 如何从 iOS 中其他 View Controller 的 TextView 中获取 NSDictionary 中的值

objective-c - 识别哪个关键用户在文本字段中输入

ios - iOS-AWS Mobile Hub使用开发人员身份验证提供程序登录

objective-c - UIView subview 中的 setNeedsLayout

ios - PhoneGap IOS 键盘完成按键事件

objective-c - MKStoreKit 自动更新订阅

iphone - 从 NSKeyedArchiver 加载单例状态

objective-c - 如何访问成员对象