使用的OpenGL ES渲染视频SurfaceView,但关注更多的开销 [英] Use opengl es to render video to SurfaceView but concerned about more overhead

查看:806
本文介绍了使用的OpenGL ES渲染视频SurfaceView,但关注更多的开销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个视频播放认为,这是一个MediaPlayer的实例SurfaceView。我重视的媒体播放器到表面支架时表面形成然后开始播放。

I wrote a video play view, it is a SurfaceView with a MediaPlayer instance. I attached the mediaplayer to the surface holder when surface created then start the play.

这是容易的,每个人都知道的细节。但我想画一个位图这是视频的surfaceview.Canvas的第一帧是不是一个选择,绘制位图,因为它会禁止媒体播放器连接。

This is easy and everyone knows the details. But I want to draw a bitmap which is the first frame of the video to the surfaceview.Canvas is not a choice to draw the bitmap, because it will disable the mediaplayer to connect.

由于API级别14,我们可以用新的一个表面纹理表面。因此,我们可以使用的OpenGL ES绘制视频帧和位图。但我担心的播放视频更为复杂,它会造成更多的开销performance.This方式吗?谁可以给我一些建议?

Since api level 14, we can new a surface with surfacetexture. So we can use opengl es to draw video frame and bitmap. But I am concerned about the performance.This way of playing video is more complicated and will it cause more overhead? Who can give me some advices?

推荐答案

您有几种选择:


  1. 使用的FrameLayout穿上SurfaceView的顶部自定义视图(或者只是一个ImageView的)。画出你的内容在那里。当视频开始播放,隐藏查看。

  1. Use a FrameLayout to put a custom View (or maybe just an ImageView) on top of the SurfaceView. Draw your content there. When video playback starts, hide the View.

连接GLES,绘制第一帧,断开GLES,连接的MediaPlayer,播放影片。实际上,这就是Grafika的<一个href=\"https://github.com/google/grafika/blob/master/src/com/android/grafika/PlayMovieSurfaceActivity.java#L243\"相对=nofollow> PlayMovieSurfaceActivity 不播放影片之前清除屏幕为黑色(见 clearSurface())。

Connect GLES, draw the first frame, disconnect GLES, connect the MediaPlayer, play the movie. This is essentially what Grafika's PlayMovieSurfaceActivity does to clear the screen to black (see clearSurface()) before playing a movie.

正如你提到的问题,可以发送视频到表面纹理,然后选择渲染你的内容或纹理图像渲染到SurfaceView。

As noted in your question, you can send the video to a SurfaceTexture, and then choose to render your content or render the image from the texture onto the SurfaceView.

#1是最容易的。 #3增加了复杂性,并且更昂贵。

#1 is the easiest. #3 adds complexity and is more expensive.

这篇关于使用的OpenGL ES渲染视频SurfaceView,但关注更多的开销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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