我有以下代码,用于保存从相机胶卷中选择的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]返回?
谢谢。
答案 0 :(得分:0)
您可以使用UIImagePickerControllerReferenceURL
键获取资产的网址。
[[AVURLAsset alloc] initWithURL:[info objectForKey:UIImagePickerControllerReferenceURL]]