Ideally I'd like to accomplish two goals:
- Pass the
Camera
preview data to aMediaCodec
encoder via aSurface
. I can create theSurface
usingMediaCodec.createInputSurface()
but theCamera.setPreviewDisplay()
takes aSurfaceHolder
, not aSurface
. - In addition to passing the
Camera
preview data to the encoder, I'd also like to display the preview on-screen (so the user can actually see what they are encoding). If the encoder wasn't involved then I'd use aSurfaceView
, but that doesn't appear to work in this scenario sinceSurfaceView
creates its ownSurface
and I think I need to use the one created byMediaCodec
.
I've searched online quite a bit for a solution and haven't found one. Some examples on bigflake.com seem like a step in the right direction but they take an approach that adds a bunch of EGL/SurfaceTexture overhead that I'd like to avoid. I'm hoping there is a simpler example or solution where I can get the Camera
and MediaCodec
talking more directly without involving EGL or textures.