Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9123309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:18:29+00:00 2026-06-17T06:18:29+00:00

I am working on processing video using OpenGL ES 2.0 on Android. The picture

  • 0

I am working on processing video using OpenGL ES 2.0 on Android. The picture data is being pulled as YUV420P and I need to process them in RGBA in my OpenGL fragment shader somehow.

How do I convert the YUV420P data into RGBA? (Performance is key given it’s video)

UPDATE: Got further thanks to Brad Larsson’s answer but it doesn’t look right.

UPDATE2: Duh, I was still using my RGBA fragment shader. Of course it looked wrong. Now I have another issue though. Let me dig further.

UPDATE3: OK, something is not going right here.

enter image description here

I am using this for the textures. Is this correct?

glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, luminanceBuffer);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width / 2, height / 2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, chrominanceBuffer);

UPDATE4: Using GL_LUMINANCE_ALPHA sorted the interlacing problem but the picture is still corrupted BUT… I just learned that the problem lies in my byte buffer so marking this one as answered.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:18:30+00:00Added an answer on June 17, 2026 at 6:18 am

    Apple has a couple of examples for iOS where they convert from YUV420 planar data to RGBA in an OpenGL ES 2.0 shader. While not specifically for Android, you should still be able to use this GLSL shader code to accomplish what you want.

    This is what I use in a conversion fragment shader based on their example:

     varying highp vec2 textureCoordinate;
    
     uniform sampler2D luminanceTexture;
     uniform sampler2D chrominanceTexture;
    
     void main()
     {
         mediump vec3 yuv;
         lowp vec3 rgb;
    
         yuv.x = texture2D(luminanceTexture, textureCoordinate).r;
         yuv.yz = texture2D(chrominanceTexture, textureCoordinate).rg - vec2(0.5, 0.5);
    
         // BT.601, which is the standard for SDTV is provided as a reference
         /*
          rgb = mat3(      1,       1,       1,
          0, -.39465, 2.03211,
          1.13983, -.58060,       0) * yuv;
          */
    
         // Using BT.709 which is the standard for HDTV
         rgb = mat3(      1,       1,       1,
                    0, -.21482, 2.12798,
                    1.28033, -.38059,       0) * yuv;
    
         gl_FragColor = vec4(rgb, 1);
     }
    

    luminanceTexture is the Y plane of your image as a texture, and chrominanceTexture is the UV plane.

    I believe the above is tuned for video range YUV, so you may need to adjust these values for full range YUV. This shader runs in a fraction of a millisecond for 1080p video frames on an iPhone 4S.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are working on a video processing application using EmguCV and recently had to
I am processing raw IP data to process a video signal (ATSC-MH). However, I
I am working on a video processing project using Qt and Opencv with Qt
I am working on a video processing library in C# and would like to
I'm working with data processing and want to generate PowerPoint or OpenOffice Impress presentation
I'm working on a program processing streaming data based on MS-RTSP protocol and it's
I am working on a real time video processing project(c/c++) which needs some amount
I'm working on a Matlab code that takes video frames, puts them inside a
I'm using OpenCV to do some processing on an AVI file. Everything is working
I am currently working on batch processing application using MSMQ in C#. In the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.