[FFmpeg-user] [ffmpeg-user]Query on Conversion format using SWSCONTEXT

suresh kumar ch.sureshkumar.24 at gmail.com
Wed Jul 25 16:15:35 CEST 2012


Hi,
    I have done piece of code for conversion from RGB24 to YUV420P. After
converting i am giving YUV420P data to encode purpose after than it writes
the data. The frame size is 320x240.
   My problem is my project is closed automatically due to encode problem.
I refer sample code and documentation , it seems not clear idea i get. I am
working in MSVC2010.

        c->pix_fmt=PIX_FMT_RGB24;
        static struct SwsContext *img_convert_fromRGBtoYUV;
if(c->pix_fmt!=PIX_FMT_YUV420P)
{
if(img_convert_fromRGBtoYUV==NULL)
{
img_convert_fromRGBtoYUV =
sws_getContext(c->width,c->height,c->pix_fmt,c->width,c->height,PIX_FMT_YUV420P,sws_flags,NULL,NULL,NULL);
if(img_convert_fromRGBtoYUV==NULL)
{
printf("Cannot initialize the conversion context\n");
exit(1);
}
avpicture_fill((AVPicture*)pict2[q],RGBdata,PIX_FMT_RGB24,c->width,c->height);
sws_scale(img_convert_fromRGBtoYUV,pict2[q]->data,pict2[q]->linesize,0,c->height,temp_pict[q]->data,temp_pict[q]->linesize);
avpicture_layout((AVPicture*)temp_pict[q],PIX_FMT_YUV420P,c->width,c->height,YUVdata,115200);
}
}
    /* encode the image */
        out_size = avcodec_encode_video(c, video_outbuf[q],
video_outbuf_size[q],temp_pict[q]);



 Can any one help me on this.


More information about the ffmpeg-user mailing list