Hi<br>I need to using H264 to live broadcast and it need 25 frames in one second., so I need to encode 25 frames <br>in one second. If the frame is 160*120 or 320*240 ,it is ok. But if it is 640*480, it need more than 70ms to <br>
encode one frame. Does anyone have suggestion about how to increase encode and decode speed?<br><br>Thanks  Hongzhen Nan<br><br>------------------------------------------<br><br>libx264 compile: ../configure ---enable-static --disable-lavf --disable-ffms --disable-gpac --enable-win32thread --disable-swscale<br>
ffmpeg compile:  ../configure --enable-static --enable-gpl --disable-mmx --enable-libx264 --disable-ffmpeg --disable-ffmplay<br> --disable-ffprobe --disable-ffserver --disable-postproc --enable-w32threads<br><br>H264 encode:<br>
<span style=" color:#c0c0c0;">              </span><span style=" color:#800000;">pCodec</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span>avcodec_find_encoder<span style=" color:#000000;">(</span><span style=" color:#800080;">CODEC_ID_H264</span><span style=" color:#000000;">);</span>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span>avcodec_alloc_context<span style=" color:#000000;">();</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">width</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">v_width</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">height</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">v_height</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">pix_fmt</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">PIX_FMT_YUV420P</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">time_base</span><span style=" color:#000000;">.</span><span style=" color:#800000;">den</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">1</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">time_base</span><span style=" color:#000000;">.</span><span style=" color:#800000;">num</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">= 25;</span><span style=" color:#c0c0c0;"></span><span style=" color:#800080;"></span><span style=" color:#000000;"></span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">coder_type</span><span style=" color:#000000;">=</span>FF_CODER_TYPE_AC<span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">flags</span><span style=" color:#000000;">|=(</span>CODEC_FLAG_LOOP_FILTER<span style=" color:#000000;">);</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">me_cmp</span><span style=" color:#000000;">|=</span><span style=" color:#000080;">1</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">partitions</span><span style=" color:#000000;">|=(</span>X264_PART_I8X8<span style=" color:#000000;">|</span>X264_PART_I4X4<span style=" color:#000000;">|</span>X264_PART_P8X8<span style=" color:#000000;">|</span>X264_PART_B8X8<span style=" color:#000000;">);</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">me_method</span><span style=" color:#000000;">=</span><span style=" color:#800080;">ME_HEX</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">me_subpel_quality</span><span style=" color:#000000;">=</span><span style=" color:#000080;">7</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">me_range</span><span style=" color:#000000;">=</span><span style=" color:#000080;">16</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">gop_size</span><span style=" color:#000000;">=</span><span style=" color:#000080;">20</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">scenechange_threshold</span><span style=" color:#000000;">=</span><span style=" color:#000080;">40</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">qcompress</span><span style=" color:#000000;">=</span><span style=" color:#000080;">0.6</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">qmin</span><span style=" color:#000000;">=</span><span style=" color:#000080;">10</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">qmax</span><span style=" color:#000000;">=</span><span style=" color:#000080;">51</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">max_qdiff</span><span style=" color:#000000;">=</span><span style=" color:#000080;">4</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">max_b_frames</span><span style=" color:#000000;">=</span><span style=" color:#000080;">3</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">refs</span><span style=" color:#000000;">=</span><span style=" color:#000080;">3</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">flags2</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">|=(</span>CODEC_FLAG2_BPYRAMID<span style=" color:#000000;">|</span>CODEC_FLAG2_MIXED_REFS<span style=" color:#000000;">|</span>CODEC_FLAG2_WPRED<span style=" color:#000000;">|</span>CODEC_FLAG2_8X8DCT<span style=" color:#000000;">|</span>CODEC_FLAG2_FASTPSKIP<span style=" color:#000000;">);</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">weighted_p_pred</span><span style=" color:#000000;">=</span><span style=" color:#000080;">2</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">rc_lookahead</span><span style=" color:#000000;">=</span><span style=" color:#000080;">0</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">-></span><span style=" color:#800000;">crf</span><span style=" color:#000000;">=</span><span style=" color:#000080;">22</span><span style=" color:#000000;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#808000;">while</span><span style=" color:#000000;">(</span>avcodec_open<span style=" color:#000000;">(</span><span style=" color:#800000;">pCodecCtx</span><span style=" color:#000000;">,</span><span style=" color:#800000;">pCodec</span><span style=" color:#000000;">)<</span><span style=" color:#000080;">0</span><span style=" color:#000000;">);</span></pre>
<br>