[Libav-user] get RGB values from ffmpeg frame

Navin nkipe at tatapowersed.com
Tue Nov 20 04:22:09 CET 2012

Hi! Glad to be part of this mailing list.
What I wanted to create, was a program which would receive a streaming 
video, and when it decodes a frame of the video into either a bitmap 
format or just pure RGB (perhaps stored in a char array), it would 
notify another program that it has received a frame, and the other 
program would take the RGB values and display it.
I've already asked this question here: 
and rogerdpack told me to post my question on the libav mailing list.
I have been through many websites, but they either use img_convert 
(which doesn't work) or sws_scale, which crashes when I try to use it 
with RGB.
Could anyone help with a complete piece of code which can give me the 
RGB values of a frame?

This is a part of the YUV conversion that I tried initially.

   while(av_read_frame(pFormatCtx, &packet) >= 0)
     // Is this a packet from the video stream?
     // Decode video frame
     avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);

     // Did we get a video frame?
         // Convert the image into YUV format that SDL uses
         sws_scale( sws_ctx, (uint8_t const * const *)pFrame->data, 
pFrame->linesize, 0, pCodecCtx->height, pict.data, pict.linesize );


More information about the Libav-user mailing list