* [FFmpeg-devel] [PR] avformat/demux: don't overwrite already set packet durations with parser ones (PR #21628)
@ 2026-02-02 16:39 James Almer via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: James Almer via ffmpeg-devel @ 2026-02-02 16:39 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: James Almer
PR #21628 opened by James Almer (jamrial)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21628
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21628.patch
Following up on b613eebe78de, if a demuxer that exports complete frames sets a duration, don't overwrite it from the output of the parser.
>From e4cc536f99d0fce8b962361c6d7878c076d62823 Mon Sep 17 00:00:00 2001
From: James Almer <jamrial@gmail.com>
Date: Mon, 2 Feb 2026 13:38:07 -0300
Subject: [PATCH] avformat/demux: don't overwrite already set packet durations
with parser ones
Following up on b613eebe78de, if a demuxer that exports complete frames sets a
duration, don't overwrite it from the output of the parser.
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavformat/demux.c | 2 +-
tests/ref/fate/matroska-encoding-delay | 2 +-
tests/ref/fate/matroska-flac-channel-mapping | 8 ++++----
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/libavformat/demux.c b/libavformat/demux.c
index c68334e1ab..db8f14ad0d 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -1265,7 +1265,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
/* set the duration */
out_pkt->duration = (sti->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) ? pkt->duration : 0;
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
- if (sti->avctx->sample_rate > 0 && sti->parser->duration > 0) {
+ if (sti->avctx->sample_rate > 0 && !out_pkt->duration && sti->parser->duration > 0) {
out_pkt->duration =
av_rescale_q_rnd(sti->parser->duration,
(AVRational) { 1, sti->avctx->sample_rate },
diff --git a/tests/ref/fate/matroska-encoding-delay b/tests/ref/fate/matroska-encoding-delay
index cfa1675b94..31d00882a4 100644
--- a/tests/ref/fate/matroska-encoding-delay
+++ b/tests/ref/fate/matroska-encoding-delay
@@ -21,7 +21,7 @@ ece637ed28526724c88f5c69b8bf7d6f *tests/data/fate/matroska-encoding-delay.matros
1, 86, 86, 24, 1152, 0xc9e85398
1, 110, 110, 24, 1152, 0xda1287d3
0, 120, 120, 40, 238290, 0xbe18b18f
-1, 134, 134, 24, 1152, 0x1c9a6102
+1, 134, 134, 16, 1152, 0x1c9a6102
[PACKET]
codec_type=audio
stream_index=1
diff --git a/tests/ref/fate/matroska-flac-channel-mapping b/tests/ref/fate/matroska-flac-channel-mapping
index 25627d6570..91a778853f 100644
--- a/tests/ref/fate/matroska-flac-channel-mapping
+++ b/tests/ref/fate/matroska-flac-channel-mapping
@@ -16,16 +16,16 @@
1, 4096, 4096, 4096, 26, 0x50d30416
0, 8192, 8192, 4096, 26, 0x51ee046f
1, 8192, 8192, 4096, 26, 0x51ee046f
-0, 12288, 12288, 4096, 26, 0x521d0458
-1, 12288, 12288, 4096, 26, 0x521d0458
+0, 12288, 12288, 4097, 26, 0x521d0458
+1, 12288, 12288, 4097, 26, 0x521d0458
0, 16385, 16385, 4096, 26, 0x531c043d
1, 16385, 16385, 4096, 26, 0x531c043d
0, 20481, 20481, 4096, 26, 0x53cf0442
1, 20481, 20481, 4096, 26, 0x53cf0442
0, 24577, 24577, 4096, 26, 0x536a0473
1, 24577, 24577, 4096, 26, 0x536a0473
-0, 28673, 28673, 4096, 26, 0x5321046c
-1, 28673, 28673, 4096, 26, 0x5321046c
+0, 28673, 28673, 4097, 26, 0x5321046c
+1, 28673, 28673, 4097, 26, 0x5321046c
0, 32770, 32770, 4096, 26, 0x51b00449
1, 32770, 32770, 4096, 26, 0x51b00449
0, 36866, 36866, 4096, 26, 0x518b042e
--
2.52.0
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-02-02 16:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-02 16:39 [FFmpeg-devel] [PR] avformat/demux: don't overwrite already set packet durations with parser ones (PR #21628) James Almer via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git