【发布时间】:2017-03-10 20:37:21
【问题描述】:
当我使用 UIImagePickerController 拍摄视频并将其保存到 SavedPhotosAlbum 时使用
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeVideoAtPathToSavedPhotosAlbum:(NSURL *)movieURL
completionBlock:^(NSURL *assetURL, NSError *error){
if (error) {
NSLog(@"Save video fail:%@",error);
} else {
NSLog(@"Save video succeed.");
[self getsavedvideo];
}}];
保存的文件包含名称和创建日期,但不包含 GPS 信息。我对此感到惊讶,因为我使用的是内置相机和 imagePicker。为什么 Apple 不只包含 GPS 坐标(即使我必须征得用户使用定位服务的权限)。
反正我离题了
我还没有找到将 GPS 坐标添加到视频的方法,因为它正在保存,我也无法找到在 completionBlock 中添加此信息。
如果有人知道怎么做,请告诉我。
所以我写了一段在视频保存后调用的代码 [self getsavedvideo];上面获取保存的视频,我可以获取电影名称和创建日期,它显示没有位置信息。
-(void) getsavedvideo;{
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
// Enumerate just the photos and videos group by using ALAssetsGroupSavedPhotos.
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
// Within the group enumeration block, filter to enumerate just photos.
[group setAssetsFilter:[ALAssetsFilter allVideos]];
// Chooses the photo at the last index
[group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *alAsset, NSUInteger index, BOOL *innerStop) {
// The end of the enumeration is signaled by asset == nil.
if (alAsset) {
ALAssetRepresentation *representation = [alAsset defaultRepresentation];
// Stop the enumerations
*stop = YES; *innerStop = YES;
// Do something interesting with the AV asset.
NSString *fileName = [representation filename];
NSDate *myDate = [alAsset valueForProperty:ALAssetPropertyDate];
CLLocation *location = [alAsset valueForProperty:ALAssetPropertyLocation];
NSLog(@"fileName!!!!,%@",fileName);
NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:mad:"dd-MM-yyyy 'at' HH:mm"];
NSLog( @"date for this file is %@ %@", [[[alAsset defaultRepresentation] url] absoluteString], [dateFormatter stringFromDate: myDate] );
NSLog (@"locate!!!!%@",location);
} }];
} failureBlock: ^(NSError *error) {
NSLog(@"No groups");}];}
所以有谁知道如何将其附加到 GPS 信息中并将其保存回视频的元数据。 这几天我一直在绞尽脑汁,并没有真正找到任何有用的东西。
请帮忙
【问题讨论】:
标签: ios xcode metadata uiimagepickercontroller alassetslibrary