使用AVRURLAsset从相机胶卷保存的视频 - initWithURL - iPhone

时间:2012-04-18 15:04:02

标签: iphone objective-c xcode video

我有以下代码,用于保存从相机胶卷中选择的UIImage或视频。

NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];

[self dismissModalViewControllerAnimated:YES];

if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
    introImage = [info objectForKey:UIImagePickerControllerOriginalImage];

    //Unhide our UIImage Preview and insert our chosen Video or Intro.
    selectIntroButton.hidden = YES;
    selectedIntro.hidden = NO;
    cancelIntroChoiceButton.hidden = NO;
    selectedIntro.image = introImage;
}
else if ([mediaType isEqualToString:(NSString *)kUTTypeMovie])
{

    //Create variable for video.

    AVURLAsset *asset=[[AVURLAsset alloc] initWithURL:??? options:nil];
    AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
    generator.appliesPreferredTrackTransform=TRUE;
    [asset release];
    CMTime thumbTime = CMTimeMakeWithSeconds(0,30);

我的问题是如何将所选视频输入AVURLAssset initWithURL?什么类型的对象是[info objectForKey:UIImagePickerControllerOriginalImage]返回?

谢谢。

1 个答案:

答案 0 :(得分:0)

您可以使用UIImagePickerControllerReferenceURL键获取资产的网址。

[[AVURLAsset alloc] initWithURL:[info objectForKey:UIImagePickerControllerReferenceURL]]