找到你要的答案

Q:Render Android MediaCodec output on two views for VR Headset compatibility

Q:在VR耳机兼容Android mediacodec两视图渲染输出

What I know so far is that I need to use a SurfaceTexture that can be rendered on two TextureViews simultaneously. So it will be: MediaCodec -> SurfaceTexture -> 2x TextureViews

But how do I get a SurfaceTexture programmaticly to be used in the MediaCodec? As far as I know a new SurfaceTexture is created for every TextureView, so if I have two TextureViews in my activity, I will get two TextureViews!? Thats one to much... ;)

Or is there any other way to render the MediaCodec Output to a screen twice?

What I know so far is that I need to use a SurfaceTexture that can be rendered on two TextureViews simultaneously. So it will be: MediaCodec -> SurfaceTexture -> 2x TextureViews

但我如何获得表面结构的programmaticly用于在mediacodec?据我所知,一个新的表面结构是每一个textureview创建的,所以如果我有两textureviews活动,我就买两textureviews!那是一个多…;)

或是还有其他的方式使mediacodec输出到屏幕上两次?

answer1: 回答1:

Do you actually require two TextureViews, or is that just for convenience?

You could, for example, have a single SurfaceView or TextureView that covers the entire screen, and then just render on the left and right sides with GLES. With the video output in a SurfaceTexture, you can render it however you like. The "texture from camera" activity in Grafika demonstrates various ways to manipulate image from a video source.

If you really want two TextureViews, you can have them. Use a single EGL context for the SurfaceTexture and both TextureViews, and just switch between EGL surfaces with eglMakeCurrent() when it's time to render.

In any event, you should be creating your own SurfaceTexture to receive the video, not using one that comes from a TextureView -- see e.g. this bit of code.

你真的需要两textureviews,或是只是为了方便吗?

你可以,例如,有一个单一的图形或textureview覆盖整个屏幕,然后就呈现在家左右。在一个表面的视频输出,你可以把它但是你喜欢。“纹理从相机”活动在Grafika展示了以各种方式操纵图像从视频源。

如果你真的想要两textureviews,你可以让他们。使用一个单一的EGL上下文的表面和textureviews,只是切换EGL表面eglmakecurrent()当它的时间来渲染。

在任何情况下,你应该创建自己的纹理来接收视频,不使用一个来自textureview --看到这段代码。

android  mediacodec  textureview  vr