When I take a video using UIImagePickerController and save it to SavedPhotosAlbum using
the saved file contains a name and creation date but not the GPS info. I am surprised by this since I am using the built in camera and the imagePicker. Why wouldn't Apple just include the GPS coordinates (even if I had to ask users permission to use location services).
anyway I digress
I have not found anyway to add the GPS coordinates to the video as it is being saved and I haven't been able to find anyway to add the this information in the completionBlock.
If someone knows how please let me know.
So I wrote a bit of code that is called after the video is saved [self getsavedvideo]; above which gets the saved video and I can get the movie name and creation date and it shows there is no location info.
so does anyone know how to append this with the GPS information and save it back to the video's metadata.
I have been wracking my brains out on this for a few days and haven't really found anything helpful.
Plz help
Code:
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];
}}];
the saved file contains a name and creation date but not the GPS info. I am surprised by this since I am using the built in camera and the imagePicker. Why wouldn't Apple just include the GPS coordinates (even if I had to ask users permission to use location services).
anyway I digress
I have not found anyway to add the GPS coordinates to the video as it is being saved and I haven't been able to find anyway to add the this information in the completionBlock.
If someone knows how please let me know.
So I wrote a bit of code that is called after the video is saved [self getsavedvideo]; above which gets the saved video and I can get the movie name and creation date and it shows there is no location info.
Code:
-(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");}];}
so does anyone know how to append this with the GPS information and save it back to the video's metadata.
I have been wracking my brains out on this for a few days and haven't really found anything helpful.
Plz help
Last edited: