如何在Android中的视频文件路径中创建视频缩略图?

Par*_*ani 16 eclipse android android-sdcard video-thumbnails

我想从SD卡路径创建视频的缩略图.我怎样才能做到这一点?

Raj*_*esh 35

您可以使用ThumbnailUtils类来获取视频文件的视频缩略图.

createVideoThumbnail() 是从视频文件路径返回视频的Bitmap(缩略图)的方法.

来自Android文档:

public static Bitmap createVideoThumbnail(String filePath,int kind)

为视频创建视频缩略图.如果视频损坏或不支持格式,则可能返回null.

你可以像这样从sdcard路径创建VideoThumbnail.

Bitmap thumb = ThumbnailUtils.createVideoThumbnail(filePath, Thumbnails.MINI_KIND);
Run Code Online (Sandbox Code Playgroud)

使用ThumbnailUtils,您可以创建两种类型的缩略图.

  1. MediaStore.Images.Thumbnails.MICRO_KIND type将生成大小为96 x 96的缩略图.

  2. MediaStore.Images.Thumbnails.MINI_KIND type将生成大小为512 x 384的缩略图.

我希望它有所帮助!