获取iOS视频的时间戳/位置 [英] Get Time Stamp/Location of iOS Video

查看:322
本文介绍了获取iOS视频的时间戳/位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用图像选择器获取.MOV文件,但是如何找到它的拍摄位置和拍摄时间呢?

I can get the .MOV file with the Image Picker, but how can I find the location it was taken at and the time it was taken?

我的图像选择器:
-(void)imagePickerController:(UIImagePickerController *)选择器
didFinishPickingMediaWithInfo:(NSDictionary *)info {

My image picker: - (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info {

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];
}
}


推荐答案

I不知道它的位置,但是您可以使用 文件属性键 以获得 NSFileCreationDate 使用 attributesOfItemAtPath:error: NSDictionary fileCreationDate

I don't know about the location it was taken but you can use File Attribute Keys to get the NSFileCreationDate using attributesOfItemAtPath:error:. There is a convenience method on NSDictionary fileCreationDate

NSError *error;
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:movieFile error:&error];
if (!attributes) {
    // Use the error
}
NSDate *createdDate = [attributes fileCreationDate];

如果要访问MOV文件上的元数据,可以查看< a href = https://stackoverflow.com/questions/5287603/how-to-extract-orientation-information-from-mov-videos-created-on-the-iphone-usi> EXIF 数据,我不知道是否有一个iOS库。

If you want to access the meta-data on the MOV file you can have a look at the EXIF data, I don't know if there is a iOS library for this though.

这篇关于获取iOS视频的时间戳/位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆