Converting NV12 decoded AVFrame from FFMPEG in GPU memory to RGB

Hi, I am using FFMPEG’s h264_cuvid decoder to decode a video frame and I am able to get a decoded frame out. However it is in NV12 format. I want to convert this to RGB planar or packed format. What is the fastest way to do that (without transferring it to system memory). I want to keep all the data in GPU memory.

I tried to use “scale_cuda” and “scale_npp” FFMPEG filters but they don’t seem to support output in PIX_FMT_RGB24. Can I do the color conversion (and possibly scaling) using libavfilter?

Or should I use the NPP library to do it (or perhaps manually by writing a CUDA kernel)?

Scale_cuda supports rgb avfilter/scale_cuda: add support for rgb32/bgr32 conversions · FFmpeg/FFmpeg@3c07c24 · GitHub