2016-06-16 17 views
1

AVCaptureVideoDataOutputから取得したビデオをAVAssetと保存する場合は、以下のようにwriteVideoAtPathToSavedPhotosAlbumを使用しています。写真アルバムに保存されたビデオの情報をURLで取得します。

私たちは UIImagePickerControllerを使用する際には、以下に取得するように戻って「保存された動画情報を」取得したい動画を保存した後しかし
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"); 
      }]; 
     }]; 
    }); 

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

・ホープ、このヘルプあなた... :)

関連する問題