如何通过ImagePickerViewController为录制的视频资产网址?

时间:2014-05-29 07:16:55

标签: ios iphone xcode video uiimagepickercontroller

实际上我想在纵向或横向模式下在设备上捕获视频时修复视频方向问题。为了解决这个问题,我有这个链接

How to fix video orientation issue in iOS

我也有谷歌解决方向问题,每种方法都需要一个资产网址。所以请告诉我如何从相机拍摄视频时获取参考网址。

目前我在

中获得UIImagePickerControllerMediaURL
 - (void) imagePickerController: (UIImagePickerController *) picker
     didFinishPickingMediaWithInfo: (NSDictionary *) info
 { 
    NSUrl * url =[info objectForKey:UIImagePickerControllerMediaURL];
    NSlog("Url is ::::%@",url);
 }

但我希望获得UIImagePickerControllerReferenceURL最近录制的视频。请指导我。

1 个答案:

答案 0 :(得分:1)

您好,您可以试试这个。它将提供视频的引用网址。

// For responding to the user accepting a newly-captured picture or movie
- (void)video:(NSString*)videoPath didFinishSavingWithError:(NSError*)error contextInfo:(void*)contextInfo
{

        NSString *str=@"file://localhost";
        NSString *appendPath=[str stringByAppendingString:videoPath];

        NSURL *urlVideo = [NSURL URLWithString:[appendPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];


            AVURLAsset *asset = [AVURLAsset assetWithURL: urlVideo];
            Float64 duration = CMTimeGetSeconds(asset.duration);

            NSString *strTime = [[NSString alloc] initWithString:[NSString stringWithFormat:@"%f",duration]];

            DLog(@"strTime ==%@",strTime);
}

由于