Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PR] WIP: avformat/demux: in case of no timestamps, calculate dts based on previous dts and duration (PR #21380)
@ 2026-01-05 14:55 Jan Ekström via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: Jan Ekström via ffmpeg-devel @ 2026-01-05 14:55 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Jan Ekström

PR #21380 opened by Jan Ekström (jeeb)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21380
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21380.patch

Adds DTS to packets which would otherwise break tbr calculation
within libavformat, as well as packet rate calculation in ffmpeg.

An example of such input would be an MPEG-TS stream where a whole
GOP is put into a single PES packet.

Co-authored-by: Jan Ekström <jan.ekstrom@24i.com>

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>


From 1d5affdfdef4c361cbd79d65abc16a9a4ab5fd89 Mon Sep 17 00:00:00 2001
From: Martin Machalek <martin.machalek@24i.com>
Date: Fri, 28 Apr 2023 15:09:22 +0200
Subject: [PATCH] avformat/demux: in case of no timestamps, calculate dts based
 on previous dts and duration
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Adds DTS to packets which would otherwise break tbr calculation
within libavformat, as well as packet rate calculation in ffmpeg.

An example of such input would be an MPEG-TS stream where a whole
GOP is put into a single PES packet.

Co-authored-by: Jan Ekström <jan.ekstrom@24i.com>

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
---
 libavformat/demux.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavformat/demux.c b/libavformat/demux.c
index b40739dc3a..67b54aba3b 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -1152,6 +1152,12 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
     if (!onein_oneout)
         // This should happen on the first packet
         update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts, pkt);
+
+    if (pkt->dts == AV_NOPTS_VALUE && pkt->pts == AV_NOPTS_VALUE &&
+        !is_relative(sti->cur_dts) && sti->cur_dts != AV_NOPTS_VALUE &&
+        pkt->duration > 0)
+        pkt->dts = sti->cur_dts + pkt->duration;
+
     if (pkt->dts > sti->cur_dts)
         sti->cur_dts = pkt->dts;
 
-- 
2.49.1

_______________________________________________
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-01-05 14:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-05 14:55 [FFmpeg-devel] [PR] WIP: avformat/demux: in case of no timestamps, calculate dts based on previous dts and duration (PR #21380) Jan Ekström 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