I am working on a project where we need to record the rendered OpenGL surface. (for example if we use GLsurfaceView, we need to record the surface along with the audio from the MIC)
Presently I am using MediaRecorder API by setting the video source as the
I am using the following sample as the base code
I wanted to know ….
- Is this the right way? . Is there any better alternate ?
- The sample test given in the link is recording the audio and video of the EGLSURFACE but it is not displayed properly.
What might be the reason?
Any help/pointers is really appreciated.
The code you reference isn’t a sample, but rather internal test code that exercises a non-public interface.
SurfaceMediaSource could change or disappear in a future release and break your code.
MediaRecorder class doesn’t take Surface input, so in your case you’d need to record the audio separately and then combine it with the new MediaMuxer class.
Android 5.0 (API 21) allows Surface input to MediaRecorder, which is often much more convenient than MediaCodec. If you neeed to use MediaCodec, there is an example showing three different ways of recording OpenGL ES output with it in Grafika’s “record GL activity”.
The MediaProjection class can also be useful for screen recording.