Extracting Bitmaps from Video WITHOUT Resorting to FFMpeg

做~自己de王妃 提交于 2019-12-10 20:21:26

问题


First, thanks to this forum for having provided me (as a long time lurker) with so much help on my first app (SwatchMatic). I'm trying something harder now for my second, and, for the first time, I'm posing a question.

As has pointed out elsewhere on this forum, MediaDataRetriever cannot be counted on to retrieve bitmaps from video at fine-grained steps, even if microseconds are used and even if OPTION CLOSET is used (to get all frames, not just key/sync frames).

So, something like this, will return many duplicate frames -- one as opposed to the ~30 you'd expect for a second of video (on my Samsung test device anyway -- and Samsung distros do seem to be poorer at delivering all frames than those of other manufacturers from what I've read in other forums).

for (int i = 0; i < 1000000 ; i = i + (1000000/30)){
    Bitmap myBitmap = retriever.getFrameAtTime(i, android.media.MediaMetadataRetriever.OPTION_CLOSEST);
    ...
    }

The typical answer is to use ffmpeg, but this is such a bloated solution to get at the very limited functionality I need (a few bitmaps sequences of 30-60 from mpeg-4 encoded vido), and it opens me up to having to distribute LGPL code with my app, etc.

I've also read on this forum, that there's no easy way to get the frames out of VideoView (which is a chid of SurfaceView). Some Google employees actually replied to this effect here.

But what about ThumbnailUtils's createVideoThumbnail method? I could live with the MINI_KIND resolution it can deliver, but it seems it only delivers the middle frame (time wise) of a clip. Can it be overrided/extended somehow to create frames at specific times?

来源:https://stackoverflow.com/questions/17483764/extracting-bitmaps-from-video-without-resorting-to-ffmpeg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!