[FFmpeg-devel] How to substitute part of an AVFrame with an RGB24 image buffer

Thomas Seilund tps
Thu Feb 4 11:53:47 CET 2010

Dear all,

I have a filled out AVFrame and an image buffer.

The AVFrame holds a video frame, yuv420p, 720x576.

The image buffer is an RGB24, 88x90.

I want to substitute the upper left corner of the AVFrame with the 
content of the image buffer.

I have the following code where picture is my AVFrame and image_blob is 
my image buffer. Basically I put every third byte of the image buffer 
into AVFrame->data[0].

    offsetSB = 0;
    pipw = 88;
    piph = 90;
    for (line = 0; line < 1; line++)
        for (hTPS = 0; hTPS < piph; hTPS++) {
            for (wTPS = 0; wTPS < pipw; wTPS++) {
                picture->data[line][hTPS * picture->linesize[line] + 
wTPS] =
                    *(image_blob + 3*offsetSB++);

This works fine but I only get a black and white image buffer in the 
upper left part of the AVFrame.

I simply don't know how to get the colors of the image buffer into the 
AFFrame as well.

Any help would be very much appreciated.


Thomas S

More information about the ffmpeg-devel mailing list