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];
avpicture_fill((AVPicture*)&pFrameRGB,buffer,
PIX_FMT_RGB24,pCodecCtx->width,
pCodecCtx->height);
//pFrame is the frame that I got from previous code.
//I think there is no problem with this variable because I can use this
to make the output, but the format of output is not fit to my purpose. I
want it in PIX_FMT_RGB24.
sws_scale(convert_ctx, pFrame->data,
pFrame->linesize, 0,
pCodecCtx->height, pFrameRGB->data,
pFrameRGB->linesize);
the line of function sws_scale is crashed everytime I run application.
It's look similar to ffmpeg.c but I dont know why it does not work.
Thank in advance
Hoang Ong
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user