title: How can I convert an FFmpeg AVFrame with pixel format AV_PIX_FMT_CUDA to a new AVFrame with pixel format AV_PIX_FMT_RGB
body: <p>I have a simple C++ application that uses FFmpeg 3.2 to receive an H264 RTP stream. In order to save CPU, I'm doing the decoding part with the codec h264_cuvid. My FFmpeg 3.2 is compiled with hw acceleration enabled. In fact, if I do the command:</p>
  
  <pre><code>ffmpeg -hwaccels
  </code></pre>
  
  <p>I get</p>
  
  <pre><code>cuvid
  </code></pre>
  
  <p>This means that my FFmpeg setup has everything OK to "speak" with my NVIDIA card.
  The frames that the function <code>avcodec_decode_video2</code> provides me have the pixel format <code>AV_PIX_FMT_CUDA</code>. I need to convert those frames to new ones with <code>AV_PIX_FMT_RGB</code>. Unfortunately, I can't do the conversion using the well knwon functions <code>sws_getContext</code> and <code>sws_scale</code> because the pixel format <code>AV_PIX_FMT_CUDA</code> is not supported. If I try with swscale I get the error:</p>
  
  <p>"cuda is not supported as input pixel format"</p>
  
  <p>Do you know how to convert an FFmpeg <code>AVFrame</code> from <code>AV_PIX_FMT_CUDA</code> to <code>AV_PIX_FMT_RGB</code> ?
  (pieces of code would be very appreciated)</p>