[Libav-user] Creating animated GIF using libavformat

Gustav González xtingray at gmail.com
Thu May 2 16:12:21 CEST 2013


Hello there,

Currently, I'm working on a Qt-based class to export arrays of images as
movie
clips. The code works perfectly with almost all the extensions, except by
the
GIF format.

This is how I usually create every frame for my animations:

writeVideoFrame(const QImage &image)
    ....
    RGBtoYUV420P(image.bits(), pic_dat, image.depth()/8, true, width,
height);
    avpicture_fill((AVPicture *)picture, pic_dat, PIX_FMT_YUV420P, width,
height);

Now, for the case of GIF animations, I already know that I have to work
with the RGB
pixel format. I figured it out by myself after I got this message:

ERROR: gif only handles the rgb24 pixel format. Use -pix_fmt rgb24.

So, I started to try things like this:

writeVideoFrame(const QImage &image)
    ....
    avpicture_fill((AVPicture *)picture, image.bits(), AV_PIX_FMT_RGB24,
width, height);

Unfortunatelly, the result is not the expected.

This is a little example of my problem. What should be one circle moving
through
the scene, is the same animation scaled and repeated three times:

http://www.maefloresta.com/tmp/test.gif

I know my code is missing some kind of image transformation similar to
RGBtoYUV420P()
but for the case of the GIF RGB24 pixel format. At least, that's my guess.

I really appreciate any hint from you guys. Thank you!

-- 
============================
  Gustav Gonzalez
  xtingray at gmail.com
============================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130502/e8a8a7b1/attachment.html>


More information about the Libav-user mailing list