提取Android中的所有视频帧 [英] extract all video frames in Android

查看:27
本文介绍了提取Android中的所有视频帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在有限的时间内录制了一个视频.现在我想获取所有视频帧.我正在使用下面的代码,并通过使用它我能够获得帧,但我没有获得所有的视频帧.重复 3 到 4 帧然后我得到了不同的帧.但众所周知,我们可以在一秒钟内获得 25-30 帧来显示流畅的视频.如何获取所有帧.

I recorded a Video for limited time. Now i want to fetch all frames of video. I am using the below code and by using it i am able to get frames but i am not getting all video frames. 3 to 4 frames are repeated then i got a different frame. But as we all know we can get 25- 30 frames in a second to display smooth video. How to get all frames.

 for (int i = 0; i < 30; i++) {

                    Bitmap bArray = mediaMetadataRetriever.getFrameAtTime(
                            1000000 * i,
                            MediaMetadataRetriever.OPTION_CLOSEST);

                    savebitmap(bArray, 33333 * i);

                }

我不想使用 NDK.我得到了这个链接,不知道argb8888"的值应该是多少.我在这里出错.任何人都可以解释如何做到这一点.在Android中从视频图像中获取帧

I don't want to use NDK. I got this link don't know what should be the value for "argb8888". I am getting error here. Can anyone explain how to do it. Getting frames from Video Image in Android

推荐答案

我之前也遇到过同样的问题,Android 的 MediaMetadataRetriever 似乎不适合这个任务,因为它没有没有很好的精度.我在 android studio 中使用了一个名为 "FFmpegMediaMetadataRetriever" 的库:

I faced the same problem before and the Android's MediaMetadataRetriever seems not appropriated for this task since it doesn't have a good precision. I used a library called "FFmpegMediaMetadataRetriever" in android studio:

  1. 在你的 build.graddle 模块 app 下添加这一行:

  1. Add this line in your build.graddle under module app:

编译'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.14'

重建您的项目.

使用 FFmpegMediaMetadataRetriever 类来抓取更高的帧精度:

Use the FFmpegMediaMetadataRetriever class to grab frames with higher precision:

FFmpegMediaMetadataRetriever med = new FFmpegMediaMetadataRetriever();

med.setDataSource("your data source");

  • 并且在您的循环中,您可以使用以下方法抓取帧:

  • and in your loop you can grab frame using:

     Bitmap bmp = med.getFrameAtTime(i*1000000, FFmpegMediaMetadataRetriever.OPTION_CLOSEST);
    

  • 这篇关于提取Android中的所有视频帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆