开发者

Gstreamer video to opengl texture

开发者 https://www.devze.com 2023-04-09 11:17 出处:网络
I\'m trying to render AV frames grabbed and converted from a MPEG4 video using Gstreamer to an Android (2.2)-opengl texture. I\'ve pretty much exhausted google and not found an answer.

I'm trying to render AV frames grabbed and converted from a MPEG4 video using Gstreamer to an Android (2.2)-opengl texture. I've pretty much exhausted google and not found an answer.

Basically, I am using Gstreamer uridecodebin to decode the frame, and then convert the frame to RGB, and then glTexSubImage2D() to create an openGL texture from it, but can't seem to get anything to work.The texture is getting colored when I get the decoded data (RGB) from Gstreamer.

I am getting the video size as 320 * 256 and my Texture size is 512 * 256 & I am using glDrawTexiOES(0,0,videowidth,videoheight), I am not getting any errors related to opengl, but the texture is blank( different color frames), though the Audio works fine.

Here is my code:Native OnDraw:

if (theGStPixelBuffer != 0) {

    glBindTexture (GL_TEXTURE_2D, s_texture);

    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

    glPixelStorei( GL_UNPACK_ALIGNMENT, 2);

    glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, theTexWidth,
        theTexHeight, GL_RGB, GL_UNSIGNED_BYTE,
        GST_BUFFER_DATA(theGStPixelBuffer));

    check_gl_error("glTexSubImage2D");

    theGStPixelBuffer = 0;

}

glDrawTexiOES(0, 0, 0, theTexWidth, theTexHeight);
ch开发者_开发百科eck_gl_error("glDrawTexiOES")


I have encounter the same problem ;you can get the bitmap and use martix class to resize the bitmap.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号