<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><tisch.daniel@gmail.com></i></b> 写道:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">发件人: Tisch Dániel <tisch.daniel@gmail.com><br>主题: Re: [x264-devel] Does x264 encoder has 2 frame delay?<br>收件人: "Mailing list for x264 developers" <x264-devel@videolan.org><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>
The following code shows my ffmpeg h264 encoder setting.<br>
bool CH264::initEncode(const CVideoStreamParams* params)<br>
{<br>
mpCodec = avcodec_find_encoder(CODEC_ID_H264);<br>
if (mpCodec == NULL)<br>
{<br>
return false;<br>
}<br>
<br>
mpCodecContext= avcodec_alloc_context();<br>
mpPicture= avcodec_alloc_frame();<br>
<br>
mpPictureSrc = new AVPicture();<br>
avpicture_alloc(mpPictureSrc, PIX_FMT_BGR24,
params->getFrameWidth(), params->getFrameHeight());<br>
<br>
mpPictureDest = new AVPicture();<br>
avpicture_alloc(mpPictureDest, PIX_FMT_YUV420P,
params->getFrameWidth(), params->getFrameHeight());<br>
<br>
mpCodecContext->coder_type = FF_CODER_TYPE_VLC; // CAVLC entropy
coding<br>
mpCodecContext->max_b_frames = 0;<br>
mpCodecContext->refs = 3;<br>
AVRational ar = av_d2q(1. / mStreamParams.getFrameRate(),
H264_TIMESTAMP_FREQ);<br>
mpCodecContext->time_base.num = ar.num;<br>
mpCodecContext->time_base.den = ar.den;<br>
mpCodecContext->gop_size =
mpCodecContext->time_base.den/mpCodecContext->time_base.num;<br>
mpCodecContext->width = mStreamParams.getFrameWidth();<br>
mpCodecContext->height = mStreamParams.getFrameHeight();<br>
mpCodecContext->pix_fmt = PIX_FMT_YUV420P;<br>
<br>
mpCodecContext->crf = 23;<br>
mpCodecContext->flags2 |= CODEC_FLAG2_FASTPSKIP;<br>
mpCodecContext->me_method = 7;<br>
mpCodecContext->me_subpel_quality = 4; <br>
mpCodecContext->trellis = 0; <br>
mpCodecContext->thread_count = 0;<br>
// open codec<br>
if (avcodec_open(mpCodecContext, mpCodec) < 0)<br>
{<br>
freeEncode();<br>
return false;<br>
}<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>