Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
719 views
in Technique[技术] by (71.8m points)

android-mediaplayer - 我们可以使用exoplayer在opengl SurfaceTexture上渲染视频吗?(Can we use exoplayer to render a video on a opengl SurfaceTexture?)

Can we use exoplayer to render a video on a opengl SurfaceTexture like we can do with mediaPlayer?

(我们可以像使用mediaPlayer一样使用exoplayer在opengl SurfaceTexture上渲染视频吗?)

I need this because i want to draw each frame of the video on a OpenGL texture ...

(我需要这个,因为我想在OpenGL纹理上绘制视频的每一帧...)

  ask by loki translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
class SurfaceTextureWrapper extends SurfaceTexture {

    public SurfaceTextureWrapper() {
        super(genSurfaceTexture());
    }


    private static int genSurfaceTexture() {
        int[] args = new int[1];
        GLES20.glGenTextures(args.length, args, 0);
        int textureHandle = args[0];
        GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textureHandle);
        GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
        GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
        GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);


        return textureHandle;
    }

}

usage sample

(使用样本)

exoPlayer.setVideoSurface(new Surface(new SurfaceTextureWrapper());

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...