android egl显示视频,Android - OpenGL ES 2 - 在顶点上显示视频(SurfaceView)(Android - OpenGL ES 2 - Display video ...

Android - OpenGL ES 2 - 在顶点上显示视频(SurfaceView)(Android - OpenGL ES 2 - Display video on vertices (SurfaceView))

现在我使用SurfaceView通过OpenGL ES 2.0在顶点上显示图像。 我不能使用GLSurfaceView,因为我想管理自己的OpenGL上下文。 我还使用屏幕外的Surface用MediaCodec编码我的OpenGL场景的视频。

图像加载是用Java编写的,但是绘制调用是用C ++(NDK)完成的。

下一步是还在顶点上显示视频(来自文件)。 所以我想我需要加载视频的每一帧(解码),并像图像一样(将图像放在顶点上)。 但我不知道如何检索视频文件的帧,如Bitmap或GLint? 这是可能的还是可能有不同的解决方案? 先谢谢你 !

Right now I use a SurfaceView to display images on vertices via OpenGL ES 2.0. I can't use a GLSurfaceView, since I want to manage myself the OpenGL contexts. I also use an offscreen Surface to encode a video of my OpenGL scene with MediaCodec.

The loading of images is in Java, but the draw calls are done in C++ (NDK).

The next step is to also display videos (from a file) on the vertices. So I guess I need to load every frame of the video (decoding), and do the same as images (put the image on vertices). But I don't know how to retrieve the frames of the video file, as Bitmap or GLint ? Is this possible or are there different solutions possible ? Thank you in advance !

原文:https://stackoverflow.com/questions/37443498

更新时间:2019-11-30 03:32

最满意答案

您可以使用SurfaceTexture 。 SurfaceTexture的目的是将任何发送到其Surface的内容并使其作为GLES纹理使用。

您可以在Grafika的 “相机纹理”活动中找到在GLES矩形上显示实时相机Feed的示例。

您没有说明解码视频的来源是什么,但只要它可以将其输出发送到Surface,整个过程就相当有效 - 帧由句柄传递,而不是复制。 另一种方法是解码视频帧,必要时将YUV转换为RGB,并使用glTexImage2D()上传每个帧。 那会慢得多。

You can use SurfaceTexture. The purpose of SurfaceTexture is to take whatever is sent to its Surface and make it available as a GLES texture.

You can find an example of displaying a live camera feed on a GLES rect in Grafika's "texture from camera" Activity.

You don't say what the source of your decoded video is, but so long as it can send its output to a Surface the whole thing is fairly efficient -- frames are passed around by handle, not copied. The alternative is to decode the video frames, convert YUV to RGB if necessary, and upload each frame with glTexImage2D(). That will be much slower.

2016-05-25

相关问答

你想要做的就是所谓的SpriteBatching。 如果你希望你的程序在openGL es中强健,你必须检查以下内容(一个让你的程序变慢的列表): - 改变每个帧的许多opengl ES状态。 - 一次又一次启用/解散(纹理等)。 一旦你启用了一些你不需要再做的事情,它就会自动应用它的框架。 - 使用许多资产,而不是spriteSheets。 是的,这会对性能产生巨大的影响。 例如,如果您有10个图像,则必须为每个图像加载不同的纹理,即SLOW。 更好的方法是创建一个spriteSheet(你可以

...

OpenGL ES 2.0要求您提供自己用GLSL编写的着色器。 您在ES 1.0中使用的固定管道不再可用。 编写自己的着色器的唯一方法是使用更高级别的工具包为您创建着色器。 OpenGL ES 2.0 requires you to provide your own shaders written in GLSL. The fixed pipeline, which you used in ES 1.0, is not available anymore. The only way around

...

来自http://shivavg.svn.sourceforge.net/viewvc/shivavg/trunk/src/shPipeline.c?revision=14&view=markup : static void shDrawVertices(SHPath *p, GLenum mode)

{

int start = 0;

int size = 0;

/* We separate vertex arrays by contours to properly

handle the fil

...

我处于类似的状况。 以OpenGL开始的方式,首先看看基本的GLSurfaceView示例/演示。 开始,设置您的应用程序活动,并设置基本画布。 在复制岛的源代码文件:GameRenderer.java上获取一个战利品,了解如何使用适当的GL标志(2D)(sprite)渲染来设置画布。 你应该真正看一下SpriteMethodTest由同一作者的复制岛: http : //code.google.com/p/apps-for-android/source/browse/trunk/SpriteMe

...

如果你使用这个类并且调用logFrame()它会告诉你在你的logcat上的日志中的fps: import android.util.Log;

public class FPSCounter {

long startTime = System.nanoTime();

int frames = 0;

public void logFrame() {

frames++;

if(System.nanoTime() - startTime >=

...

您可以使用SurfaceTexture 。 SurfaceTexture的目的是将任何发送到其Surface的内容并使其作为GLES纹理使用。 您可以在Grafika的 “相机纹理”活动中找到在GLES矩形上显示实时相机Feed的示例。 您没有说明解码视频的来源是什么,但只要它可以将其输出发送到Surface,整个过程就相当有效 - 帧由句柄传递,而不是复制。 另一种方法是解码视频帧,必要时将YUV转换为RGB,并使用glTexImage2D()上传每个帧。 那会慢得多。 You can use

...

是的,我相信如果你用iOS的C / C ++编写游戏,将它移植到Android并不会太麻烦。 但是,如果您使用Objective-C编写游戏,那么确实会很麻烦。 Yes, I believe that if you write a game in C/C++ for iOS, to port it to Android wouldn't be too much of a hassle. However, if you write the game in Objective-C, then it c

...

你不。 思考实验时间! 首先想象你的球体直径为1厘米。 你有10厘米远的相机。 你会在框架的中心看到一个小球体。 现在假设你有一个直径1公里的球体和10公里外的相机。 您如何期待图像不同? 正确的答案是你不会期望图像会发生变化。 真正重要的是事物的相对大小。 因此,您对数字赋予的单位类型仅对程序员有意义,而对程序无效。 因此,您只需在心理上声明一个单位等于一厘米,并根据该比例创建您的对象和世界。 没有代码级别更改来实现这一点。 它只是一种惯例,用于帮助您以相对于彼此的正确尺寸构建物体。 You d

...

问题是顶点着色器中的Projection * ModelView乘数。 删除它,它的工作原理..我显然不明白这是从中衍生出来的书内容。 更新:我使用的顶点是巨大的。 以下程序有效。 我希望它可以帮助任何被困的人: #import

#include "SDL.h"

#include

#include "SDL_opengles.h"

#include "SDL_opengles2.h"

#define FALSE 0

#de

...

首先,看看有没有办法检查Android设备是否支持openGL ES 2.0? 。 另外,请查看Basemark ES 3.0 First, take a look to Is there a way to check if Android device supports openGL ES 2.0?. Also, take a look to Basemark ES 3.0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值