如何获取视频的缩略图?

发布于 2024-08-01 15:08:45 字数 81 浏览 2 评论 0原文

文件格式为 wmv、asx、flv、mov、rmv、rmvb、swf、mpg、mpeg。 如何在视频上传时获取缩略图,如果:不使用 ffmpeg。

file format is wmv, asx,flv, mov, rmv, rmvb, swf, mpg, mpeg.
How to get thumbnail image while video uploading , if: not use ffmpeg.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

熟人话多 2024-08-08 15:08:46
Bitmap bm = MediaStore.Video.Thumbnails.getThumbnail(getContentResolver(), 1, 1, null);
ImageView iv = (ImageView) findViewById(R.id.ImageView01);
iv.setImageBitmap(bm);

/*
public static class 
MediaStore.Video.Thumbnails
public static Bitmap getThumbnail (ContentResolver cr, long origId, int kind, BitmapFactory.Options options) 
Since: API Level 5 This method checks if the thumbnails of the specified image (origId) has been created. It will be blocked until the thumbnails are generated.

Parameters
cr  ContentResolver used to dispatch queries to MediaProvider. 
origId  Original image id associated with thumbnail of interest. 
kind  The type of thumbnail to fetch. Should be either MINI_KIND or MICRO_KIND 
options  this is only used for MINI_KIND when decoding the Bitmap 

Returns
A Bitmap instance. It could be null if the original image associated with origId doesn't exist or memory is not enough. 
*/
Bitmap bm = MediaStore.Video.Thumbnails.getThumbnail(getContentResolver(), 1, 1, null);
ImageView iv = (ImageView) findViewById(R.id.ImageView01);
iv.setImageBitmap(bm);

/*
public static class 
MediaStore.Video.Thumbnails
public static Bitmap getThumbnail (ContentResolver cr, long origId, int kind, BitmapFactory.Options options) 
Since: API Level 5 This method checks if the thumbnails of the specified image (origId) has been created. It will be blocked until the thumbnails are generated.

Parameters
cr  ContentResolver used to dispatch queries to MediaProvider. 
origId  Original image id associated with thumbnail of interest. 
kind  The type of thumbnail to fetch. Should be either MINI_KIND or MICRO_KIND 
options  this is only used for MINI_KIND when decoding the Bitmap 

Returns
A Bitmap instance. It could be null if the original image associated with origId doesn't exist or memory is not enough. 
*/
旧梦荧光笔 2024-08-08 15:08:45

为什么你想要避免使用专门为该任务设计的东西? 无论如何,有很多商业和开源工具/库可以帮助您完成此任务,其中一些可能具有适合您使用的 API 或绑定...

ImageMagick 可以使用 convert 进行帧提取 命令:

convert movie.mpg[0]

您还可以从一系列帧创建动画 GIF

convert movie.avi[0,100,200] -background white -compose darken -flatten out.gif

或者

convert movie.avi[100-200] -background white -compose darken -flatten out.gif

Why are you ever want to avoid using something that designed especially for the task? Anyway there is a plenty of commercial and open-source tools/libraries that can help you with this, and some of them probably have API's or bindings for what you working with...

It's possible with ImageMagick using frame extraction with convert command:

convert movie.mpg[0]

You can also create animated GIF from range of frames:

convert movie.avi[0,100,200] -background white -compose darken -flatten out.gif

OR

convert movie.avi[100-200] -background white -compose darken -flatten out.gif
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文