I need to convert RGBA to NV12 using OpenGL shader as encoder input.
Already have render two different fragment shaders, both textures are from one camera . Using v4l2 to get the camera image(YUV). Then, convert YUV to RGB let OpenGL render. The next step, I need to convert RGB to NV12 as encoder input because the encoder only accept NV12 format.
Use a compute shader to convert RGB to planar YUV, then downsample the UV plane by a factor of two.
Here's the compute shader:
There's lots of different YUV conventions, and I don't know which one is expected by your encoder. So replace
rgb_to_yuv
above with the inverse of your YUV -> RGB convertion.Then proceed as follows:
DISCLAIMER: