I have a video player that uses MediaCodec
to render frames to a surface, just as suggested here, and it works. I need to apply some processing to the frames and change their pixels before they are rendered. But getOutputImage() returns a Read-Only image. How can I change the pixel data then?
android. media. Image getOutputImage( int index ) Returns a
read-only Image object for a dequeued output buffer index that
contains the raw video frame. After calling this method, any
ByteBuffer or Image object previously returned for the same output
index MUST no longer be used.
Here is my snippet:
Image image = codec.getOutputImage(outputBufferIndex);
if (image != null) {
applyCustomProcessing(image);
image.close();
}
SurfaceRenderer surfaceRenderer = (SurfaceRenderer) renderer;
surfaceRenderer.render(mediacodec, outputBufferIndex, presentationTime);