[FFmpeg-devel] libavcodec/flacenc: Possible bug

Olivier Ayache olivier.ayache at gmail.com
Fri Jul 3 12:23:57 EEST 2020


I am currently working with FLAC encoder and I think I found a bug on pts
setted on AVPacket.
In  flac_encode_frame function the pts provided is frame's pts, if we feed
the encoder with small frames, an encoded packet will be valid after
several frames and the pts of the first packet won't be 0.

    avpkt->pts      = frame->pts;
    avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples);
    avpkt->size     = out_bytes;

    s->next_pts = avpkt->pts + avpkt->duration;

I think a better code would be

    avpkt->pts      = s->next_pts;
    avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples);
    avpkt->size     = out_bytes;

    s->next_pts = avpkt->pts + avpkt->duration;

I can push a patch if you agree with my analysis.

Olivier Ayache


More information about the ffmpeg-devel mailing list