1

我正在尝试示例Grafika。我对将ContinuousCapture视频记录到文件系统并同时将其绘制到屏幕上的示例感兴趣。我遇到的问题是将视频录制到文件系统似乎很慢。丢帧很多,每秒帧数只有7-10fps。

在 maindrawFrame()方法内部,

private void drawFrame() {
    //Log.d(TAG, "drawFrame");
    if (mEglCore == null) {
        Log.d(TAG, "Skipping drawFrame after shutdown");
        return;
    }

    // Latch the next frame from the camera.
    mDisplaySurface.makeCurrent();
    mCameraTexture.updateTexImage();
    mCameraTexture.getTransformMatrix(mTmpMatrix);

    // Fill the SurfaceView with it.
    SurfaceView sv = (SurfaceView) findViewById(R.id.continuousCapture_surfaceView);
    int viewWidth = sv.getWidth();
    int viewHeight = sv.getHeight();
    GLES20.glViewport(0, 0, viewWidth, viewHeight);
    mFullFrameBlit.drawFrame(mTextureId, mTmpMatrix);
    drawExtra(mFrameNum, viewWidth, viewHeight);
    mDisplaySurface.swapBuffers();

    // Send it to the video encoder.
    if (!mFileSaveInProgress) {
        mEncoderSurface.makeCurrent();
        GLES20.glViewport(0, 0, VIDEO_WIDTH, VIDEO_HEIGHT);
        Log.d(TAG, "start drawing video");
        mFullFrameBlit.drawFrame(mTextureId, mTmpMatrix);
        Log.d(TAG, "finish drawing video");
        drawExtra(mFrameNum, VIDEO_WIDTH, VIDEO_HEIGHT);
        mCircEncoder.frameAvailableSoon();
        mEncoderSurface.setPresentationTime(mCameraTexture.getTimestamp());
        mEncoderSurface.swapBuffers();
    }

    mFrameNum++;
}

主要的性能瓶颈似乎是

    Log.d(TAG, "start drawing video");
    mFullFrameBlit.drawFrame(mTextureId, mTmpMatrix);
    Log.d(TAG, "finish drawing video");

两个日志之间的时间为 130 毫秒。Android MediaRecorder 可以以 30fps 的高质量视频完成这项工作。我试图禁用显示部分,但没有任何区别

4

0 回答 0