Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Video Recording of OpenGL surface (GLSURFACEVIEW)

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 VIDEO_SOURCE_GRALLOC_BUFFER.

I am using the following sample as the base code

I wanted to know ....

  1. Is this the right way? . Is there any better alternate ?
  2. 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.

thanks,
Satish

like image 418
Satish. Avatar asked Apr 29 '13 08:04

Satish.


1 Answers

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.

Update: Android 4.3 (API 18) allows Surface input to MediaCodec. The EncodeAndMuxTest sample demonstrates recording OpenGL ES frames to a .mp4 file.

The 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.

Update #2: 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.

like image 130
fadden Avatar answered Sep 17 '22 23:09

fadden