On Mon, Aug 2, 2010 at 2:38 AM, Hoang Ong <[email protected]> wrote:
>  Hi Experts,
>
> I'm try to extract frames from mp4 video. I got the frame that I want to do
> the output, but I get stuck when I convert frame to PIX_FMT_RGB24 image
> type. My code is :
>
> //store formated frame
> AVFrame *pFrameRGB;
>                    pFrameRGB=avcodec_alloc_frame();
>
>
>                    SwsContext* convert_ctx;
>                    convert_ctx = sws_getContext( pCodecCtx->width,
>                                                  pCodecCtx->height,
>                                                  pCodecCtx->pix_fmt,
>                                                  pCodecCtx->width,
>                                                  pCodecCtx->height,
>                                                  PIX_FMT_RGB24,
>                                                  SWS_BILINEAR, NULL, NULL,
> NULL);
>                    if (convert_ctx == NULL)
>                    {
>                        cout << "Cannot init scale context!\n";
>                        return;
>                    }
>
>                    uint8_t *buffer;
>                    int sizeBuffer =
> avpicture_get_size(PIX_FMT_RGB24,pCodecCtx->width,
>                                                        pCodecCtx->height);
>                    buffer = new uint8_t[sizeBuffer];

memory alignment is required!
try use av_malloc()/av_free()



-- 
-----------------------------------------------------------------------------------------
My key fingerprint: d1:03:f5:32:26:ff:d7:3c:e4:42:e3:51:ec:92:78:b2
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to