2

我正在开发 android 应用程序,它可以在用户执行按钮单击时从视频中抓取帧,该 android 应用程序被配置为使用 TextureView 播放视频。为了将帧捕获为位图,我正在使用:

Bitmap bit = textureView.getBitmap(width, height);

它工作正常,但“getBitmap”需要很长时间(640x480 帧大约需要 150-200 毫秒)。问题是在调用 getBitmap 时,视图上会显示灰色框架。这看起来像是有什么东西在闪烁。有没有办法解决这个问题?

谢谢

4

1 回答 1

0

您应该使用 Handler 以避免延迟时间

new Handler().post(new Runnable() {
@Override
public void run() {
    try {
        Bitmap bit = textureView.getBitmap(width, height);
        //you could save the video frames to use later
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}});
于 2015-05-26T03:52:26.220 回答