[x264-devel] encode frame

Nuno Cardoso linun77 at gmail.com
Tue Jul 13 15:54:27 CEST 2010


Hi list!

What is the best way to compress an YUV420 frame with x264 lib:

1) like ffmpeg:

uint8_t *buf = pkt->buf;
uint32_t bufsize = pkt->size;
do {
        if (x264_encoder_encode(x4->enc, &nal, &nnal, &x4->pic, &pic_out) <
0) {
            log(LOG_ERROR, "x264 encode error\n");
            return -1;
        }

        bufsize = encode_nals(x4, buf, bufsize, nal, nnal, 0);
        if (bufsize < 0) {
            log(LOG_ERROR, "x264 encode nals error\n");
            return -1;
        }
} while (!bufsize && x264_encoder_delayed_frames(x4->enc));

2) like avdemux:

uint8_t *buf = pkt->buf;
uint32_t bufsize = pkt->size;

if (x264_encoder_encode(x4->enc, &nal, &nnal, &x4->pic, &pic_out) < 0) {
     log(LOG_ERROR, "x264 encode error\n");
     return -1;
}

bufsize = encode_nals(x4, buf, bufsize, nal, nnal, 0);
if (bufsize < 0) {
     log(LOG_ERROR, "x264 encode nals error\n");
     return -1;
}

if (bufsize == 0)
   return 0;

The diference between the two implementations is the while loop with
x264_encoder_delayed_frames(...).

Thanks,
Nuno Cardoso
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x264-devel/attachments/20100713/7a129998/attachment.htm>


More information about the x264-devel mailing list