Reputation: 147
I am trying to implement screen recorder. I followed grafika . Simply giving Surface from encoder.getInputSurface()
to VirtualDisplay does the trick. Now my task is to encode a certain part of the screen. So, I was trying to modify the input Surface for the encoder using SurfaceTexture (I think this is right method). But I am not able to use the created surface to record screen and when I pass this Surface to VirtualDisplay I do not get any callback.
I also tried to record using TextureMovieEncoder(from grafika) but may be I do not know the correct method.
I tried to understand through following userful links. How does an output surface of a Decoder is passed to an input surface of an Encoder?
and
Android: Is it possible to create a SurfaceTexture without a SurfaceView?
And I am sure grafika is a great tutorial but I am stuck.
Please suggest solution or another workable method. I am now stuck for days.
Upvotes: 0
Views: 2266
Reputation: 1211
I think the right way is as follows:
create a SurfaceTexture with an oes texture.
connect VirtualDisplay to the surfacetexture created in step 1, so frame will go to the oes texture
Register onFrameAvailable listener on the surfacetexture, then you will get the callback continuously
Render the frame in the oes texture to the input surface of encoder.
The key process is step 4. During the process of rendering, you can crop the frame through modify the texture coordinate.
There is a crop example below: Crop video before encoding with MediaCodec for Grafika's "Continuous Capture" Activity
Upvotes: 1