我正在将一些代码从FFMPEG 0.8转换到FFMPEG 1.2。在调用方法avcodec_open2()
时出现错误:
Specified pixel format %s is invalid or not supported
我将翻译如下:
我使用的格式是:AV_PIX_FMT_RGB24
。它默认应该是启用的,对吗?
以下是我的代码:
av_register_all();
codec = avcodec_find_encoder(AV_CODEC_ID_MPEG2VIDEO);
if(!codec)
{
throw SystemException("codec not found");
}
codecContext = avcodec_alloc_context3(codec);
codecContext->bit_rate = 200000;
codecContext->time_base.den = 1;
codecContext->time_base.num = 90000;
codecContext->gop_size = 8;
codecContext->pix_fmt = AV_PIX_FMT_RGB24;
_codecContext->width = 320
_codecContext->height = 240
if(avcodec_open2(_codecContext, _codec, NULL) < 0)
{
throw SystemException("Unable to open codec");
}