Best method to play hi-res frame animation in android

时间:2015-04-24 21:33:16

标签: android animation

I want to play 6 sec hi-res video animation in the background of my activity views. On my device thats 1080x1080. The video has to have a transparent background. I did some research on AnimationDrawable and people say its a pain in the a... (OutOfMemory Exceptions,...)

I want to be able to loop the video and change the speed. The framerate should be at least 20fps.

How would you do it?

1 个答案:

答案 0 :(得分:2)

我将视频编码为.mp4(AVC),并使用MediaCodec将其解码为SurfaceTexture,然后使用OpenGL ES渲染纹理。你渲染的内容取决于你的应用程序正在做什么; SurfaceViewTextureView

你说视频是在后台,但它必须有一个透明的背景,这表明它有点在前景。不太确定你想要实现的目标。该视频不具备Alpha通道,但您可以使用片段着色器设置Alpha(全局或根据视频像素值)。

您可以在Grafika中找到视频播放的示例(使用循环和速度控制)。来自相机的#34;纹理"活动可能也是相关的,因为它说明了通过SurfaceTexture进行渲染(尽管它使用来自摄像机的实时视频而不是录制的文件)。相机过滤器演示显示了一些simple fragment shaders