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
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.