Como converter RGB de YUV420p para codificador ffmpeg?

Eu quero fazer arquivo de vídeo .avi de imagens bitmap usando o código c + +. Eu escrevi o seguinte código:

//Get RGB array data from bmp file
uint8_t* rgb24Data = new uint8_t[3*imgWidth*imgHeight];
hBitmap = (HBITMAP) LoadImage( NULL, _T("myfile.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetDIBits(hdc, hBitmap, 0, imgHeight, rgb24Data , (BITMAPINFO*)&bmi, DIB_RGB_COLORS);

/* Allocate the encoded raw picture. */
AVPicture dst_picture;
avpicture_alloc(&dst_picture, AV_PIX_FMT_YUV420P, imgWidth, imgHeight);

/* Convert rgb24Data to YUV420p and stored into array dst_picture.data */
RGB24toYUV420P(imgWidth, imgHeight, rgb24Data, dst_picture.data); //How to implement this function?

//code for encode frame dst_picture here

Meu problema é como implementarRGB24toYUV420P() função, esta função irá converterRGB24 dados da matriz rgb24Data paraYUV420p e armazenar em arraydst_picture.data para o codificador ffmpeg?

questionAnswers(2)

yourAnswerToTheQuestion