<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div>2012/8/16 Michael Bradshaw <span dir="ltr"><<a href="mailto:mbradshaw@sorensonmedia.com" target="_blank">mbradshaw@sorensonmedia.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


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

</div></blockquote><div><br></div><div><div>detailing more...</div><div><br></div><div>Using <i>avpicture_alloc</i> or not, the error occurs when i try to scale to YUV format..<br><br><i>    img_convert_ctx = sws_getContext(FRAME_WIDTH,<br>
            FRAME_HEIGHT, PIX_FMT_BGR24,<br>            FRAME_WIDTH, FRAME,<br>            PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL );<br><br>    sws_scale(img_convert_ctx, pFrameRaw->data, pFrameRaw->linesize, 0,FRAME_HEIGHT, tmp_picture->data, tmp_picture->linesize);</i><br>
<br><br><br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><span><font color="#888888">
<div><br></div><div>Jorge. </div></font></span><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
--Michael<br>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
</blockquote></div></div><br>
</blockquote></div><br>