From 5863cab885c3c92ae45c7b80633bfe67c19e3052 Mon Sep 17 00:00:00 2001 From: James Almer Date: Fri, 13 Feb 2026 13:01:54 -0300 Subject: [PATCH] avcodec/libmp3lame: rescale packet duration when calculating discarded samples Signed-off-by: James Almer --- libavcodec/libmp3lame.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c index 01b8985b8c..339505ccfe 100644 --- a/libavcodec/libmp3lame.c +++ b/libavcodec/libmp3lame.c @@ -285,7 +285,7 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts, &avpkt->duration); - discard_padding = avctx->frame_size - avpkt->duration; + discard_padding = avctx->frame_size - ff_samples_from_time_base(avctx, avpkt->duration); // Check if subtraction resulted in an overflow if ((discard_padding < avctx->frame_size) != (avpkt->duration > 0)) { av_log(avctx, AV_LOG_ERROR, "discard padding overflow\n");