[FFmpeg-devel] [PATCH] avcodec/gif: fix duration of last packet/frame

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Tue Aug 23 15:37:30 EEST 2022


Andreas Rheinhardt:
> Paul B Mahol:
>> Hi,
>>
>> patch attached.
>>
>>              return ret;
>>      }
>>  
>> +    pkt->duration = av_rescale_q(pict->duration, (AVRational){ 1, 100 },
>> +                                 avctx->time_base);
>>      pkt->size   = outbuf_ptr - pkt->data;
>>      if (s->image || !avctx->frame_number)
>>          pkt->flags |= AV_PKT_FLAG_KEY;
> 
> Where does the magic 1/100 timebase come from? For encoding, the
> AVFrame's time base is supposed to be AVCodecContext.time_base. This
> could actually be done generically for all video-encoders without delay.
> (I know that AVFrame has a time_base of its own that is currently unset
> and unused.)
> 

Strangely, if I do exactly as above, the gifenc tests show weird
durations like:

+0,          0,          0,       10,     1368, 0x6cf0befd

+0,          1,          1,       10,      158, 0xcd173bb4, F=0x0

+0,          2,          2,       10,      163, 0x4f7a451d, F=0x0

+0,          3,          3,       10,      152, 0x17723839, F=0x0

+0,          4,          4,       10,      160, 0x67854056, F=0x0


So somewhere a timebase is wrong or AVFrame.duration is not converted to
a new timebase somewhere.

- Andreas


More information about the ffmpeg-devel mailing list