[Libav-user] GIF API access

Gustav González xtingray at gmail.com
Sun Mar 5 03:52:26 EET 2017


2017-02-27 11:02 GMT-05:00 Gustav González <xtingray at gmail.com>:

> 2017-02-27 4:30 GMT-05:00 Carl Eugen Hoyos <ceffmpeg at gmail.com>:
>
>> 2017-02-27 4:13 GMT+01:00 Gustav González <xtingray at gmail.com>:
>> > I'm getting closer to create an animated GIF using a (Qt) QImage
>> > array as input.
>>
>> Since your sample code does not use the gif encoder, I don't see
>> how it can lead to an animated gif as output file.
>>
>
> So, the right way to ensure a functional animated GIF is using the*
> avcodec_encode_video2() *function to insert the frames?
>
> --
> ============================
>   Gustav Gonzalez
>   xtingray at gmail.com
> ============================
>
Finally, I could create an animated GIF for the first time. Nevertheless, I
need to adjust the FPS parameter in some point because the animation looks
too slow. I am doing it from the *AVCodecContext* variable, like this:

    int fps = 24;
    AVCodecContext *c;
    c->time_base.den = fps;
    c->time_base.num = 1;

But anyway, it doesn't matter the value I set for the fps variable, the
result is always the same (slow). On the other hand, this is the code I use
to process every QImage object:

        int got_packet = 0;
        AVPacket pkt;
        av_init_packet(&pkt);
        pkt.data = NULL; // packet data will be allocated by the encoder
        pkt.size = 0;

        QImage img = image.convertToFormat(Format_RGB888);
        avpicture_fill((AVPicture *)frame, img.bits(), AV_PIX_FMT_RGB24, w, h);

        int ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);
        if (ret < 0) {
            tError() << "Error encoding video frame!";
            return false;
        }

        if (got_packet) {
            pkt.stream_index = video_st->index;
            ret = av_interleaved_write_frame(oc, &pkt);
        } else {
            ret = 0;
        }

Any suggestion about how to fix the FPS issue? Thanks!
-- 
============================
  Gustav Gonzalez
  xtingray at gmail.com
============================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20170304/35c6e74e/attachment.html>


More information about the Libav-user mailing list