【问题标题】:How to asset url for a recorded video by ImagePickerViewController?如何通过 ImagePickerViewController 为录制的视频资产 url?
【发布时间】:2014-05-29 07:16:55
【问题描述】:

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

How to fix video orientation issue in iOS

而且我也有 google 来解决方向问题,每种方法都需要一个资产 url。所以请告诉我如何在从相机捕获视频时获取参考 url。

目前我收到UIImagePickerControllerMediaURL

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

但我想为最近录制的视频获取UIImagePickerControllerReferenceURL。请指导我。

【问题讨论】:

    标签: ios iphone xcode video uiimagepickercontroller


    【解决方案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);
    }
    

    谢谢

    【讨论】:

    • didFinishSavingWithError ,当这个方法被调用时,我想,它会在一些错误来时被调用。请解释一下
    • 否 视频保存完成后调用,如果有错误则返回错误。
    • 感谢回复。但我需要的资产 url 看起来像 UIImagePickerControllerReferenceURL = "assets-library://asset/asset.MOV?id=C40988C3-B7D3-42BA-8556-AD72A8BE6055&ext=MOV"
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-28
    • 1970-01-01
    • 2021-02-03
    • 1970-01-01
    • 1970-01-01
    • 2016-04-06
    相关资源
    最近更新 更多