[x264-devel] Does x264 encoder has 2 frame delay?

Liulifeng llfeng1999 at yahoo.cn
Mon May 11 04:56:35 CEST 2009


Thanks for your answers.Indeed my CPU is dual-core.As your says when I change the thread_count to 1, the encoder doesn't have delay,the encoding time increase slightly.But I still confused to enable parallel encoding get 2 frame delay.Is there a way to enable parallel encoding without encoding delay?
Thanks again.

Leon

--- 09年5月8日,周五, Tisch Dániel <tisch.daniel at gmail.com> 写道:
发件人: Tisch Dániel <tisch.daniel at gmail.com>
主题: Re: [x264-devel] Does x264 encoder has 2 frame delay?
收件人: "Mailing list for x264 developers" <x264-devel at videolan.org>
日期: 2009,58,周五,5:53下午




  
Hi,



this is the normal behaviour of x264 for 0 bframes (max_b_frames = 0)
and 3 threads.

The thread_count = 0 directs x264 to use enough threads to load all
your CPU cores during encode. So you probably run the tests on a dual
core machine (2 cores will have 3 threads). To get x264 encode without
delay, set thread_count = 1.



Cheers,



Daniel





Liulifeng wrote:

  
    
      
        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

        
      
    
  
  

  
好玩贺卡等你发,邮箱贺卡全新上线!
  
_______________________________________________
x264-devel mailing list
x264-devel at videolan.org
http://mailman.videolan.org/listinfo/x264-devel
  

 
_______________________________________________
x264-devel mailing list
x264-devel at videolan.org
http://mailman.videolan.org/listinfo/x264-devel



      ___________________________________________________________ 
  好玩贺卡等你发,邮箱贺卡全新上线! 
http://card.mail.cn.yahoo.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x264-devel/attachments/20090511/7e566ff1/attachment.htm>


More information about the x264-devel mailing list