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->buf;<br>uint32_t bufsize = pkt->size;<br>do {<br> if (x264_encoder_encode(x4->enc, &nal, &nnal, &x4->pic, &pic_out) < 0) {<br>
log(LOG_ERROR, "x264 encode error\n");<br> return -1;<br> }<br><br> bufsize = encode_nals(x4, buf, bufsize, nal, nnal, 0);<br> if (bufsize < 0) {<br> log(LOG_ERROR, "x264 encode nals error\n");<br>
return -1;<br> }<br>} while (!bufsize && x264_encoder_delayed_frames(x4->enc));<br><br>2) like avdemux:<br><br>uint8_t *buf = pkt->buf;<br>uint32_t bufsize = pkt->size;<br><br>if (x264_encoder_encode(x4->enc, &nal, &nnal, &x4->pic, &pic_out) < 0) {<br>
log(LOG_ERROR, "x264 encode error\n");<br> return -1;<br>}<br><br>bufsize = encode_nals(x4, buf, bufsize, nal, nnal, 0);<br>if (bufsize < 0) {<br> log(LOG_ERROR, "x264 encode nals error\n");<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>