[FFmpeg-devel] [PATCH] lavf/mov: Always prefer tfdt over sidx
Thilo Borgmann
thilo.borgmann at mail.de
Wed Nov 3 11:46:26 EET 2021
Hi,
this effectively reverts 071930de724166bfb90fc6d368c748771188fd94 and fixes the underlying issue by always preferring TFDT.
Furthermore, the current solution fails if the -use_tfdt flag is given but no TFDT box is found in the stream.
-Thilo
-------------- next part --------------
From 1ae6d7f213d0ba2360b9b1cf7fde2e3d0adde70d Mon Sep 17 00:00:00 2001
From: Thilo Borgmann <thilo.borgmann at mail.de>
Date: Tue, 2 Nov 2021 22:49:37 +0100
Subject: [PATCH] lavf/mov: Always prefer tfdt over sidx
---
doc/demuxers.texi | 6 ------
libavformat/isom.h | 1 -
libavformat/mov.c | 12 +++++-------
3 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 1c9575b2e8..fa669f88fe 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -689,12 +689,6 @@ Set mfra timestamps as PTS
Don't use mfra box to set timestamps
@end table
- at item use_tfdt
-For fragmented input, set fragment's starting timestamp to @code{baseMediaDecodeTime} from the @code{tfdt} box.
-Default is disabled, which will preferentially use the @code{earliest_presentation_time} from the @code{sidx} box.
-In either case, the timestamp from the @code{mfra} box will be used if it's available and @code{use_mfra_for} is
-set to pts or dts.
-
@item export_all
Export unrecognized boxes within the @var{udta} box as metadata entries. The first four
characters of the box type are set as the key. Default is false.
diff --git a/libavformat/isom.h b/libavformat/isom.h
index f3c18c95be..55e5fa7b23 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -279,7 +279,6 @@ typedef struct MOVContext {
int moov_retry;
int use_mfra_for;
int has_looked_for_mfra;
- int use_tfdt;
MOVFragmentIndex frag_index;
int atom_depth;
unsigned int aax_mode; ///< 'aax' file has been detected
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 3fcb1dc908..00205bb1be 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4828,16 +4828,16 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
dts = frag_stream_info->first_tfra_pts;
av_log(c->fc, AV_LOG_DEBUG, "found mfra time %"PRId64
", using it for dts\n", pts);
- } else if (frag_stream_info->sidx_pts != AV_NOPTS_VALUE && !c->use_tfdt) {
+ } else if (frag_stream_info->tfdt_dts != AV_NOPTS_VALUE) {
+ dts = frag_stream_info->tfdt_dts - sc->time_offset;
+ av_log(c->fc, AV_LOG_DEBUG, "found tfdt time %"PRId64
+ ", using it for dts\n", dts);
+ } else if (frag_stream_info->sidx_pts != AV_NOPTS_VALUE) {
// FIXME: sidx earliest_presentation_time is *PTS*, s.b.
// pts = frag_stream_info->sidx_pts;
dts = frag_stream_info->sidx_pts - sc->time_offset;
av_log(c->fc, AV_LOG_DEBUG, "found sidx time %"PRId64
", using it for pts\n", pts);
- } else if (frag_stream_info->tfdt_dts != AV_NOPTS_VALUE) {
- dts = frag_stream_info->tfdt_dts - sc->time_offset;
- av_log(c->fc, AV_LOG_DEBUG, "found tfdt time %"PRId64
- ", using it for dts\n", dts);
} else {
dts = sc->track_end - sc->time_offset;
av_log(c->fc, AV_LOG_DEBUG, "found track end time %"PRId64
@@ -8533,8 +8533,6 @@ static const AVOption mov_options[] = {
FLAGS, "use_mfra_for" },
{"pts", "pts", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_MFRA_PTS}, 0, 0,
FLAGS, "use_mfra_for" },
- {"use_tfdt", "use tfdt for fragment timestamps", OFFSET(use_tfdt), AV_OPT_TYPE_BOOL, {.i64 = 0},
- 0, 1, FLAGS},
{ "export_all", "Export unrecognized metadata entries", OFFSET(export_all),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = FLAGS },
{ "export_xmp", "Export full XMP metadata", OFFSET(export_xmp),
--
2.20.1 (Apple Git-117)
More information about the ffmpeg-devel
mailing list