我已经看到这个问题弹出了几次,但作者认为对错误答案感到满意,所以我会再问一遍。
当从用户的图库中挑选一部电影时,我在tmp目录中获得了MOV,但我现在没有在3.1+ sdk中获得该电影的缩略图。在sdk 3.0中,您在tmp文件夹中获得了一个jpg,但此行为已停止。
除了ffmpeg之外,还有答案可以获得拇指吗?什么东西支持sdk?
他们直接拍摄视频时会得到一个拇指。
这个答案错了:iphone sdk > 3.0 . Video Thumbnail?
答案 0 :(得分:2)
找到答案,但我不得不等到iOS4(该功能在3.2中出现)
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType compare:(NSString*)kUTTypeMovie] == NSOrderedSame) {
// deal with the movie
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
NSURL *mediaUrl = [info objectForKey:UIImagePickerControllerMediaURL];
NSLog(@"media Url = %@, path %@", mediaUrl, [mediaUrl path]);
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:mediaUrl];
UIImage *thumbnail = [[moviePlayer thumbnailImageAtTime:0.0 timeOption:MPMovieTimeOptionNearestKeyFrame] retain];
[moviePlayer release];
NSLog(@"thumbnail = %@", thumbnail);
[thumbnail release];
}
}