Hi list!<br><br>What is the best way to compress an YUV420 frame with x264 lib:<br><br>1) like ffmpeg:<br><br>uint8_t *buf = pkt-&gt;buf;<br>uint32_t bufsize = pkt-&gt;size;<br>do {<br>        if (x264_encoder_encode(x4-&gt;enc, &amp;nal, &amp;nnal, &amp;x4-&gt;pic, &amp;pic_out) &lt; 0) {<br>
            log(LOG_ERROR, &quot;x264 encode error\n&quot;);<br>            return -1;<br>        }<br><br>        bufsize = encode_nals(x4, buf, bufsize, nal, nnal, 0);<br>        if (bufsize &lt; 0) {<br>            log(LOG_ERROR, &quot;x264 encode nals error\n&quot;);<br>
            return -1;<br>        }<br>} while (!bufsize &amp;&amp; x264_encoder_delayed_frames(x4-&gt;enc));<br><br>2) like avdemux:<br><br>uint8_t *buf = pkt-&gt;buf;<br>uint32_t bufsize = pkt-&gt;size;<br><br>if (x264_encoder_encode(x4-&gt;enc, &amp;nal, &amp;nnal, &amp;x4-&gt;pic, &amp;pic_out) &lt; 0) {<br>
     log(LOG_ERROR, &quot;x264 encode error\n&quot;);<br>     return -1;<br>}<br><br>bufsize = encode_nals(x4, buf, bufsize, nal, nnal, 0);<br>if (bufsize &lt; 0) {<br>     log(LOG_ERROR, &quot;x264 encode nals error\n&quot;);<br>
     return -1;<br>}<br><br>if (bufsize == 0)<br>   return 0; <br><br>The diference between the two implementations is the while loop with x264_encoder_delayed_frames(...).<br><br>Thanks,<br>Nuno Cardoso<br> <br>