[Libav-user] AVFrame necessary fields to create correctly raw Frame

Jorge Fonseca jcbfonseca at gmail.com
Thu Aug 16 22:47:11 CEST 2012


> 2012/8/16 Michael Bradshaw <mbradshaw at sorensonmedia.com>
>
>> On Thu, Aug 16, 2012 at 1:26 PM, Jorge Fonseca <jcbfonseca at gmail.com>
>> wrote:
>> > Hi All,
>> >
>> > I have a C program using FFmpeg API that:
>> >  - load bmp files and create a video file.
>> >
>> > Its works correctly.
>> >
>> > -------------
>> >
>> > Now, i need to create the same video from a RAW data (char array).
>> > I allocating a frame, and try to set AVFrame directly...
>> >
>> > Question:
>> >
>> >  - Which fields a need to fill?
>> >
>> >    My current code is:
>> >
>> >         pFrameRaw = avcodec_alloc_frame();
>> >         if (!pFrameRaw) {
>> >             printf("Can't allocate memory for AVFrame\n");
>> >             return NULL ;
>> >         }
>> >
>> >
>> >         // Determine required buffer size and allocate buffer
>> >         int numBytes = avpicture_get_size(PIX_FMT_BGR24,FRAME_WIDTH,
>> > FRAME_HEIGHT);
>> >         uint8_t *buffer = (uint8_t *) av_malloc(numBytes *
>> sizeof(uint8_t));
>>
>> Not sure if I understand the question, but this can be simplified if
>> you use avpicture_alloc().
>>
>
> Michael,
> Thanks..
>
> And how to fill raw_data and correct format that will be used in the video
> encode? Only setting data and fmt fields?
>

detailing more...

Using *avpicture_alloc* or not, the error occurs when i try to scale to YUV
format..

*    img_convert_ctx = sws_getContext(FRAME_WIDTH,
            FRAME_HEIGHT, PIX_FMT_BGR24,
            FRAME_WIDTH, FRAME,
            PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL );

    sws_scale(img_convert_ctx, pFrameRaw->data, pFrameRaw->linesize,
0,FRAME_HEIGHT, tmp_picture->data, tmp_picture->linesize);*




> Jorge.
>
>>
>> --Michael
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/libav-user
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120816/365e547e/attachment.html>


More information about the Libav-user mailing list