<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">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?<br>Thanks again.<br><br>Leon<br><br>--- <b>09年5月8日,周五, Tisch Dániel <i>&lt;tisch.daniel@gmail.com&gt;</i></b> 写道:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">发件人: Tisch Dániel &lt;tisch.daniel@gmail.com&gt;<br>主题: Re: [x264-devel] Does x264 encoder has 2 frame delay?<br>收件人: "Mailing list for x264 developers" &lt;x264-devel@videolan.org&gt;<br>日期: 2009,58,周五,5:53下午<br><br><div id="yiv21750485">


  
Hi,<br>
<br>
this is the normal behaviour of x264 for 0 bframes (max_b_frames = 0)
and 3 threads.<br>
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.<br>
<br>
Cheers,<br>
<br>
Daniel<br>
<br>
<br>
Liulifeng wrote:
<blockquote type="cite">
  <table border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">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.<br>
&nbsp; The following code shows my ffmpeg h264 encoder setting.<br>
bool CH264::initEncode(const CVideoStreamParams* params)<br>
{<br>
&nbsp;&nbsp; mpCodec = avcodec_find_encoder(CODEC_ID_H264);<br>
&nbsp;&nbsp; if (mpCodec == NULL)<br>
&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;<br>
&nbsp;&nbsp; }<br>
        <br>
&nbsp;&nbsp; mpCodecContext= avcodec_alloc_context();<br>
&nbsp;&nbsp; mpPicture= avcodec_alloc_frame();<br>
        <br>
&nbsp;&nbsp; mpPictureSrc = new AVPicture();<br>
&nbsp;&nbsp; avpicture_alloc(mpPictureSrc, PIX_FMT_BGR24,
params-&gt;getFrameWidth(), params-&gt;getFrameHeight());<br>
        <br>
&nbsp;&nbsp;&nbsp;&nbsp; mpPictureDest = new AVPicture();<br>
&nbsp;&nbsp;&nbsp;&nbsp; avpicture_alloc(mpPictureDest, PIX_FMT_YUV420P,
params-&gt;getFrameWidth(), params-&gt;getFrameHeight());<br>
        <br>
&nbsp;&nbsp;&nbsp; mpCodecContext-&gt;coder_type = FF_CODER_TYPE_VLC; // CAVLC entropy
coding<br>
&nbsp;&nbsp;&nbsp; mpCodecContext-&gt;max_b_frames = 0;<br>
&nbsp;&nbsp;&nbsp; mpCodecContext-&gt;refs = 3;<br>
&nbsp;&nbsp;&nbsp; AVRational ar = av_d2q(1. / mStreamParams.getFrameRate(),
H264_TIMESTAMP_FREQ);<br>
&nbsp;&nbsp;&nbsp; mpCodecContext-&gt;time_base.num = ar.num;<br>
&nbsp;&nbsp;&nbsp; mpCodecContext-&gt;time_base.den = ar.den;<br>
&nbsp;&nbsp;&nbsp; mpCodecContext-&gt;gop_size =
mpCodecContext-&gt;time_base.den/mpCodecContext-&gt;time_base.num;<br>
&nbsp;&nbsp;&nbsp; mpCodecContext-&gt;width = mStreamParams.getFrameWidth();<br>
&nbsp;&nbsp;&nbsp; mpCodecContext-&gt;height = mStreamParams.getFrameHeight();<br>
&nbsp;&nbsp;&nbsp; mpCodecContext-&gt;pix_fmt = PIX_FMT_YUV420P;<br>
        <br>
&nbsp;&nbsp; mpCodecContext-&gt;crf = 23;<br>
&nbsp;&nbsp; mpCodecContext-&gt;flags2 |= CODEC_FLAG2_FASTPSKIP;<br>
&nbsp;&nbsp; mpCodecContext-&gt;me_method = 7;<br>
&nbsp;&nbsp; mpCodecContext-&gt;me_subpel_quality = 4;&nbsp; <br>
&nbsp;&nbsp; mpCodecContext-&gt;trellis = 0;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp; mpCodecContext-&gt;thread_count = 0;<br>
&nbsp;&nbsp; // open codec<br>
&nbsp;&nbsp; if (avcodec_open(mpCodecContext, mpCodec) &lt; 0)<br>
&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; freeEncode();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;<br>
&nbsp;&nbsp; }<br>
return true;<br>
}<br>
        <br>
Is the problem of x264 or my settings?How to reduce the delay to 0
frame?Thanks.<br>
        <br>
        <br>
Leon<br>
        </td>
      </tr>
    </tbody>
  </table>
  <br>
  <hr size="1"><a rel="nofollow" target="_blank" href="http://cn.rd.yahoo.com/mail_cn/tagline/card/*http://card.mail.cn.yahoo.com/">
好玩贺卡等你发,邮箱贺卡全新上线!</a>
  <pre><hr size="4" width="90%"><br>_______________________________________________<br>x264-devel mailing list<br><a rel="nofollow" class="moz-txt-link-abbreviated" target="_blank" href="mailto:x264-devel@videolan.org">x264-devel@videolan.org</a><br><a rel="nofollow" class="moz-txt-link-freetext" target="_blank" href="http://mailman.videolan.org/listinfo/x264-devel">http://mailman.videolan.org/listinfo/x264-devel</a><br>  </pre>
</blockquote>
 
</div><pre>_______________________________________________<br>x264-devel mailing list<br>x264-devel@videolan.org<br>http://mailman.videolan.org/listinfo/x264-devel<br></pre></blockquote></td></tr></table><br>


      <hr size=1><a href="http://cn.rd.yahoo.com/mail_cn/tagline/card/*http://card.mail.cn.yahoo.com/">  好玩贺卡等你发,邮箱贺卡全新上线!</a>