Android coding using MediaCodec and surface

I transferred the video through MediaCodec directly to the surface, which was taken from SurfaceView in my user interface. This works great.

Now I am trying to use MediaCodec as an encoder. As a test, I want to display on the Surface (as indicated above) and loopback through another instance of MediaCodec configured as an encoder.

I see the createInputSurface () method of the encoder. I think I want the encoder to create this surface, and then the MediaCodec decoder uses this as a surface for painting. First, is this possible?

Secondly, I'm not sure how to create a SurfaceView from the surface created by the encoder. I just extracted Surface from SurfaceView, and I can’t see from the docs how to do this in reverse order.

+4
source share
1 answer

Surfaces are the "producer" side of the consumer-producer side. Generally speaking, the API is centered around consumers who create both ends and then pass the producer interface (surface) back.

So, for a SurfaceView or MediaCodec encoder, you create an object and get its Surface. Then you send graphic data buffers to them with Canvas, OpenGL ES or MediaCodec decoder.

Encoder SurfaceView Surface - . SurfaceView (SurfaceFlinger), , " ". MediaCodec , .

MediaCodec SurfaceView , MediaCodec. , . , .

, Surface (BufferQueue), ( Lollipop) , API Lollipop, . , , - .

SurfaceTexture (a/k/a GLConsumer), . Surface, . MediaCodec. , , GLES SurfaceTexture. SurfaceView .

Grafika doc.

+7

Source: https://habr.com/ru/post/1606270/


All Articles