2017-02-27 11:02 GMT-05:00 Gustav González <[email protected]>:

> 2017-02-27 4:30 GMT-05:00 Carl Eugen Hoyos <[email protected]>:
>
>> 2017-02-27 4:13 GMT+01:00 Gustav González <[email protected]>:
>> > 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
>   [email protected]
> ============================
>
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
  [email protected]
============================
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to