[x264-devel] Does x264 encoder has 2 frame delay?
Liulifeng
llfeng1999 at yahoo.cn
Fri May 8 11:40:52 CEST 2009
I am using FFMpeg+x264 as a h264 encoder to encode video
stream in my application.But the encoder has 2 frame delay in my APP.The function
avcodec_encode_video() return 0 for the first 2 frames of the video stream, and the third
encoding output gets this of the first input video frame.I don't know whether it is the problem of x264 or my ffmpeg settings.
The following code shows my ffmpeg h264 encoder setting.
bool CH264::initEncode(const CVideoStreamParams* params)
{
mpCodec = avcodec_find_encoder(CODEC_ID_H264);
if (mpCodec == NULL)
{
return false;
}
mpCodecContext= avcodec_alloc_context();
mpPicture= avcodec_alloc_frame();
mpPictureSrc = new AVPicture();
avpicture_alloc(mpPictureSrc, PIX_FMT_BGR24, params->getFrameWidth(), params->getFrameHeight());
mpPictureDest = new AVPicture();
avpicture_alloc(mpPictureDest, PIX_FMT_YUV420P, params->getFrameWidth(), params->getFrameHeight());
mpCodecContext->coder_type = FF_CODER_TYPE_VLC; // CAVLC entropy coding
mpCodecContext->max_b_frames = 0;
mpCodecContext->refs = 3;
AVRational ar = av_d2q(1. / mStreamParams.getFrameRate(), H264_TIMESTAMP_FREQ);
mpCodecContext->time_base.num = ar.num;
mpCodecContext->time_base.den = ar.den;
mpCodecContext->gop_size = mpCodecContext->time_base.den/mpCodecContext->time_base.num;
mpCodecContext->width = mStreamParams.getFrameWidth();
mpCodecContext->height = mStreamParams.getFrameHeight();
mpCodecContext->pix_fmt = PIX_FMT_YUV420P;
mpCodecContext->crf = 23;
mpCodecContext->flags2 |= CODEC_FLAG2_FASTPSKIP;
mpCodecContext->me_method = 7;
mpCodecContext->me_subpel_quality = 4;
mpCodecContext->trellis = 0;
mpCodecContext->thread_count = 0;
// open codec
if (avcodec_open(mpCodecContext, mpCodec) < 0)
{
freeEncode();
return false;
}
return true;
}
Is the problem of x264 or my settings?How to reduce the delay to 0 frame?Thanks.
Leon
___________________________________________________________
好玩贺卡等你发,邮箱贺卡全新上线!
http://card.mail.cn.yahoo.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x264-devel/attachments/20090508/22ee9e38/attachment.htm>
More information about the x264-devel
mailing list