从 UIImagePickerController 抓取视频的第一帧?
我正在尝试从 UIImagePickerController
中获取所选视频的第一帧以在 UIImageView
中显示,但我不知道是否可能。如果是的话我该怎么办?
I'm trying to get the first frame from the selected video in a UIImagePickerController
to show in a UIImageView
, but I do not know if it's possible. If it is, how would I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过以下两种方式之一执行此操作。第一种方法是使用
MPMoviePlayerController
抓取缩略图:这种方法可行,但
MPMoviePlayerController
不是一个特别轻量级的对象,抓取缩略图的速度也不是特别快。首选方法是使用 AVFoundation 中新的
AVAssetImageGenerator
。这比旧方法快速、轻量且更灵活。这是一个辅助方法,它将从视频中返回自动释放的图像。异步使用
You can do this in one of two ways. The first way is to use the
MPMoviePlayerController
to grab the thumbnail:This works, but
MPMoviePlayerController
is not a particularly lightweight object and not particularly fast grabbing thumbnails.The preferred way is to use the new
AVAssetImageGenerator
in AVFoundation. This is fast, lightweight and more flexible than the old way. Here's a helper method that will return an autoreleased image from the video.Asynchronous usage