Hi All,
I am not able to open codec.
Every time when i call API avcodec_open, it returns error.
please go through the following code snippet and point me
where i am wrong.
AVCodecContext *context = avcodec_alloc_context();
if (NULL == context)
{
char buffer [] = "Fail to Allocate Memory\n";
fwrite (buffer, sizeof buffer,1, Fptr);
fflush (Fptr);
}
else
{
context->bit_rate = 400000;
context->pix_fmt = PIX_FMT_YUV420P;
context->codec_type = CODEC_TYPE_VIDEO;
context->width = 352;//img->width;
context->height = 288;//img->height;
context->time_base.den = 1;
context->time_base.num = 25;
context->gop_size = 10;
context->max_b_frames = 1;
AVCodec *codec = avcodec_find_encoder (CODEC_ID_MPEG4);
if (NULL == codec)
{
char buffer [] = "Fail to Find Codec\n";
fwrite (buffer, sizeof buffer,1, Fptr);
fflush (Fptr);
}
else
{
char buffer [] = "Codec has been successfully found\n";
fwrite (buffer, sizeof buffer,1, Fptr);
fflush (Fptr);
}
/* open it */
if (avcodec_open (context, codec) < 0)
{
char buffer [] = "Fail to Open Codec\n";
fwrite (buffer, sizeof buffer,1, Fptr);
fflush (Fptr);
}
else
{
char buffer [] = "Codec has been Successfully Opened\n";
fwrite (buffer, sizeof buffer,1, Fptr);
fflush (Fptr);
}
}
Any help would be highly appreciated.
Thanks in Advance.
