2016-06-16 3 views
1

Я сохраняю видео, полученное от AVCaptureVideoDataOutput, с AVAsset, используя writeVideoAtPathToSavedPhotosAlbum, как показано ниже.Получить информацию о видео, сохраненном в фотоальбоме по адресу

NSString* filename = [NSString stringWithFormat:@"capture%d.mp4", _currentFile]; 
    NSString* path = [NSTemporaryDirectory() stringByAppendingPathComponent:filename]; 
    NSURL* url = [NSURL fileURLWithPath:path]; 

    dispatch_async(dispatch_get_main_queue(), ^{ 
     [_encoder finishWithCompletionHandler:^{ 
      ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; 
      [library writeVideoAtPathToSavedPhotosAlbum:url completionBlock:^(NSURL *assetURL, NSError *error){ 
       NSLog(@"save completed"); 
      }]; 
     }]; 
    }); 

Однако после сохранения видео, которое я хочу, чтобы получить «сохранено видео информации» назад, как мы получаем с последующим при использовании UIImagePickerController.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 
    [picker dismissViewControllerAnimated:YES completion:NULL]; 

    NSLog(@"there"); 

    // Handle a movie capture 
    NSString *type = info[UIImagePickerControllerMediaType]; 
    NSURL *videoURL = info[UIImagePickerControllerMediaURL]; 

    //do things with that info 
} 

ответ

0

Вот код для сохранения видео и добавления этого видео в пользовательский альбом, а затем сообщите, где он был сохранен.

[library writeVideoAtPathToSavedPhotosAlbum:videoInputUrl completionBlock:^(NSURL *assetURL, NSError *error){ 
    if (error) { 

     NSLog(@"Video could not be saved"); 
    } 
    else{ 

      [library assetForURL:assetURL 
        resultBlock:^(ALAsset *asset) { 
         // assign the photo to the album 
         [groupToAddTo addAsset:asset]; 
         NSLog(@"Added Successfully %@ to %@", [[asset defaultRepresentation] filename], albumName); 
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Success" message:@"Video Saved to xyz Album." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil, nil]; 
         [alert show]; 
        } 
        failureBlock:^(NSError* error) { 
         NSLog(@"failed to retrieve image asset:\nError: %@ ", [error localizedDescription]); 
        }]; 
    } 
}]; 

Надеется, что это поможет вам ... :)

Смежные вопросы