将 TextureView 上显示的帧记录到 mp4 [英] Record frames displayed on TextureView to mp4

查看:13
本文介绍了将 TextureView 上显示的帧记录到 mp4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法编写了一个在 TextureView 上显示 3D 模型的演示,该模型可以根据手机的传感器移动.3D引擎是用C++写的,我需要做的是把TextureView的SurfaceTexture交给3D引擎.引擎调用函数 ANativeWindow_fromSurface 来检索原生窗口并在其上绘制 3D 模型.3D引擎不是我这个问题要讲的重点.

I managed to write a demo displaying a 3D model on TextureView and the model can move according to the sensors of the phone. The 3D engine is wrote by C++ and what I need to do is giving the SurfaceTexture of TextureView to the 3D engine. The engine calls the function ANativeWindow_fromSurface to retrieve a native window and draw 3D model on it. 3D engine is not the key point I want to talk about in this question.

现在我想将移动的 3d 模型录制到视频中.一种方法是使用 GL_TEXTURE_EXTERNAL_OES 纹理,就像 grafika 一样,使 3D 引擎对 oes 纹理绘制帧,并在每次调用 updateTexImage() 后将纹理内容绘制到屏幕上.但是由于某些限制,我不允许使用这种方式.

Now I want to record the moving 3d model to a video. One way is using GL_TEXTURE_EXTERNAL_OES texture just like grafika, make 3D engine draw frames to the oes texture and draw the texture content to screen after every call of updateTexImage().But for some restrictions, I am not allowed to use this way.

我打算直接使用TextureView的SurfaceTexture.我认为 attachToGLContext() 和 detachFromGLContext() 等函数对我的工作很有用.

I plan to use the SurfaceTexture of TextureView directly. I think functions such as attachToGLContext() and detachFromGLContext() will be useful for my work.

谁能给我一些建议?

推荐答案

Grafika的记录GL应用"有三种不同的操作模式:

Grafika's "record GL app" has three different modes of operation:

  1. 将所有内容绘制两次.
  2. 渲染到屏幕外 pbuffer,然后 blit 两次.
  3. 绘制一次,然后在帧缓冲区之间复制(需要 GLES 3).

如果您可以配置渲染到的 EGL 表面,方法 2 和 3 将起作用.对于方法 #3,请记住,在调用 eglSwapBuffers() 之前,像素不会到达 Surface(即 Android Surface,而不是 EGL 表面).

If you can configure the EGL surface that is rendered to, approaches 2 and 3 will work. For approach #3, bear in mind that the pixels don't go to the Surface (that's the Android Surface, not the EGL surface) until you call eglSwapBuffers().

如果引擎代码正在管理 EGL 表面并为您调用 eglSwapBuffers(),那么事情会更烦人.SurfaceTexture 附加/分离调用将允许您使用来自不同 EGL 上下文的输出访问 GLES 纹理,但渲染线程在渲染视图 UI 时需要它.我不完全确定这将如何解决.

If the engine code is managing the EGL surface and calling eglSwapBuffers() for you, then things are a bit more annoying. The SurfaceTexture attach/detach calls will let you access the GLES texture with the output from a different EGL context, but the render thread needs that when rendering the View UI. I'm not entirely sure how that's going to work out.

这篇关于将 TextureView 上显示的帧记录到 mp4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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