Getting a frame from SurfaceView

后端 未结 1 748
说谎
说谎 2020-12-17 05:15

The difficulty I am having now is to take a screenshot of the SurfaceView. Could anyone please help?

My team is doing an Android project where we use MediaCodec to d

相关标签:
1条回答
  • 2020-12-17 05:39

    You can't capture a SurfaceView, as explained in this other question.

    SurfaceViews will rarely want to override onDraw(). Generally the View part of the SurfaceView is a transparent hole.

    For the specific case of MediaCodec output, you have a couple of choices. You can direct the output to a SurfaceTexture, and then render the video frame twice using OpenGL ES. Once to the SurfaceView for display, once to an off-screen buffer from which you can capture the pixels.

    Another approach is to replace the SurfaceView with a TextureView, and then use the getBitmap() call to grab video frames.

    Various examples can be found in Grafika.

    0 讨论(0)
提交回复
热议问题