flip opengl frame buffer before sending to nvenc

If I send OpenGL frame buffer directly to NVENC, the encoded image is vertically flipped.
I guess that might due to OpenGL origin is bottom-left, NVEnC when is assuming image origin is top-left.

Are there anyway to flip the frame buffer efficiently? Or NVENC has an option to handle image with origin in bottom left?


NVENCODEAPI doesn’t have any capability to change orientation of the frame. It encodes the frame fed to it as-is.

However, you need to explore if you have a way of making the right orientation of the OGL frame right before feeding it to the encoder.

You can also explore the option of using OGL<->Cuda interop, then flip the Cuda surface using a Cuda kernel and feed that to NVENCODEAPI using the Cuda interface of NVENCODEAPI.

Ryan Park

Hi guo.tang,

I am trying to replicate what you’ve done, send the OpenGL FBO to NVENC directly. Would you be able to post some sample code that I can use to refer?

You can follow the example here: