Android Video Recording of OpenGL surface (GLSURFACEVIEW)

。_饼干妹妹 提交于 2019-11-28 21:41:03

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/16274569/android-video-recording-of-opengl-surface-glsurfaceview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!