OpenGL表面的Android视频录制(GLSURFACEVIEW) [英] Android Video Recording of OpenGL surface (GLSURFACEVIEW)

查看:89
本文介绍了OpenGL表面的Android视频录制(GLSURFACEVIEW)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个项目,我们需要记录渲染的 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)

目前我通过将视频源设置为 VIDEO_SOURCE_GRALLOC_BUFFER 来使用 MediaRecorder API.

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

我想知道....

  1. 这是正确的方法吗?.有没有更好的替代品?
  2. 链接中给出的示例测试是录制 EGLSURFACE 的音频和视频,但无法正常显示.

可能是什么原因?
非常感谢任何帮助/指针.

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

谢谢,
萨蒂什

推荐答案

您引用的代码不是示例,而是执行非公共接口的内部测试代码.SurfaceMediaSource 可能会在未来的版本中更改或消失,从而破坏您的代码.

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.

更新:Android 4.3 (API 18) 允许 Surface 输入MediaCodec.EncodeAndMuxTest 示例演示了将 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 类不接受 Surface 输入,因此在您的情况下,您需要单独录制音频,然后将其与新的 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:Android 5.0 (API 21) 允许 Surface input 到 MediaRecorder,这通常比 MediaCodec 方便得多.如果您需要使用 MediaCodec,Grafika's 记录总账活动".

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.

这篇关于OpenGL表面的Android视频录制(GLSURFACEVIEW)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆