xcode 如何设置视频的缩略图?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8063853/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:22:47  来源:igfitidea点击:

how to set thumbnail image of video?

iphoneobjective-cxcode

提问by Developer

I have a custom button in my application on click of which I present a UIImagePickerControllerSourceTypeCamera to take a video.

我在我的应用程序中有一个自定义按钮,单击它我会显示一个 UIImagePickerControllerSourceTypeCamera 来拍摄视频。

Now, after capturing the video I want to set a thumbnail of it to this custom button.

现在,在捕获视频后,我想将它的缩略图设置为此自定义按钮。

How to take 1st frame of that video to set thumbnail ?

如何拍摄该视频的第一帧以设置缩略图?

回答by iOS

refer the following links. You can get some ideas regarding creating thumbnails for videos.

请参考以下链接。您可以获得一些有关为视频创建缩略图的想法。

  1. Getting a thumbnail from a video url or data in iPhone SDK

  2. stackoverflow.com/questions/1259316/iphone-sdk-3-0-video-thumbnail

  1. 从 iPhone SDK 中的视频 url 或数据获取缩略图

  2. stackoverflow.com/questions/1259316/iphone-sdk-3-0-video-thumbnail

回答by boopathi

Check This.

检查这个。

NSString *videoLink=[info objectForKey:@"UIImagePickerControllerMediaURL"];   
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:(NSURL*)videoLink];
UIImage *imageSel = [player thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];
[player stop];
[player release];