如何在Android中从视频文件路径创建视频缩略图? [英] How to create a video thumbnail from a video file path in Android?
问题描述
我想从SD卡路径创建视频的缩略图.我该怎么办?
I want to create a thumbnail of a video from the SD card path. How can I do that?
推荐答案
您可以使用ThumbnailUtils
类获取视频文件的视频缩略图.
You can use ThumbnailUtils
class to get Video thumbnail of Video file.
createVideoThumbnail()
是从视频文件路径返回视频的位图(缩略图)的方法.
createVideoThumbnail()
is method which return Bitmap (thumbnail) of video from video file path.
来自Android文档:
From Android Docs:
公共静态位图createVideoThumbnail(字符串filePath,int类型)
为视频创建视频缩略图.如果视频是 损坏或不支持该格式.
Create a video thumbnail for a video. May return null if the video is corrupt or the format is not supported.
您可以像这样从sdcard路径创建VideoThumbnail.
You can create VideoThumbnail from sdcard path like this.
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(filePath, Thumbnails.MINI_KIND);
使用ThumbnailUtils
,您可以创建两种类型的缩略图.
Using ThumbnailUtils
, you can create thumbnail of two types.
-
MediaStore.Images.Thumbnails.MICRO_KIND
类型将生成大小为96 x 96的缩略图.
MediaStore.Images.Thumbnails.MICRO_KIND
type will generate thumbnail of size 96 x 96.
MediaStore.Images.Thumbnails.MINI_KIND
类型将生成大小为512 x 384的缩略图.
MediaStore.Images.Thumbnails.MINI_KIND
type will generate thumbnail of size 512 x 384.
希望对您有帮助!
这篇关于如何在Android中从视频文件路径创建视频缩略图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!