OpenGL的表面的Andr​​oid视频录制(GLSURFACEVIEW)表面、视频、OpenGL、Andr

2023-09-05 04:47:21 作者:你列表最软的妹.

我工作的一个项目,我们需要记录呈现的OpenGL的表面。 (例如,如果我们用GLsurfaceView,我们需要随着从MIC的音频记录表面)

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我使用MediaRecorder API通过设置视频源为 VIDEO_SOURCE_GRALLOC_BUFFER

Presently I am using MediaRecorder API by setting the video source as the VIDEO_SOURCE_GRALLOC_BUFFER.

我使用下面的样本为基数code

I am using the following sample as the base code

我想知道......

I wanted to know ....

这是正确的方式? 。有没有更好的替代? 在链路中给出的样本测试记录EGLSURFACE的音频和视频,但它是不正确显示。

可能是什么原因呢?任何帮助/指针是真的AP preciated。

What might be the reason? Any help/pointers is really appreciated.

感谢, 萨蒂什

thanks, Satish

推荐答案

在code您引用是不是一个样,而是内部测试code,它行使一个非公开的接口。 SurfaceMediaSource 可以改变或消失在未来的版本,打破你的code。

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.

更新: 的Andr​​oid 4.3(API 18)允许表面输入以媒体codeC 。该恩codeAndMuxTest 示例演示记录的OpenGL ES帧到.MP4文件。

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

MediaRecorder 类不带面输入,因此在你的情况下,你需要单独录制的声音,然后用新的 MediaMuxer 类。

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.

更新#2: 的Andr​​oid 5.0(API 21)允许表面输入以MediaRecorder ,这常常是远远超过媒体$ C $立方厘米方便。如果您neeed使用媒体codeC,还有一个例子,显示在三种不同的录音OpenGL ES的输出,它的方法Grafika的记录GL活动。

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

借助 MediaProjection 类也可以为屏幕录制有用

The MediaProjection class can also be useful for screen recording.