PR #25826 opened by Forgejo_Fairy
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25826
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25826.patch

When edit lists are disabled, movenc can warn that an edit list was required 
without identifying the affected track or its start timestamp. With 
`-use_editlist 0 -movflags +negative_cts_offsets`, this makes the loss of AAC 
priming compensation or an intentional track offset difficult to diagnose.

Include the MP4 track ID and start DTS, in track ticks and milliseconds, in the 
existing warning, and mention the possible A/V synchronization impact. Document 
that negative CTS offsets do not replace edit lists for audio priming or 
differing track start times. The timestamp is diagnostic context, not a 
measurement of total inter-track skew.

Addresses the diagnostic alternative requested in #25775. Timestamp handling is 
unchanged, and the timing regression remains unresolved.

Validation on Linux arm64: `fate-api-movenc` and `git diff --check` passed. 
Seven before/after remux comparisons produced byte-identical MP4 files: default 
output, disabled edit lists, negative CTS offsets, delayed video, explicit 
`avoid_negative_ts=make_zero`, fragmented output, and custom track IDs. The 
supplied example now identifies audio track ID 2 at −1024 ticks / −21.333 ms; 
adding the video offset also identifies video track ID 1 at 6144 ticks / 
500.000 ms.


From edae337e4e29069e2a284a0f8ace2bf1b09dd651 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 7 Nov 2026 03:37:50 +0000
Subject: [PATCH] avformat/movenc: identify tracks requiring disabled edit
 lists

Include the MP4 track ID and start DTS, in track ticks and milliseconds, in the 
warning emitted when an edit list is needed but disabled. Explain the possible 
A/V sync impact, and document that negative_cts_offsets does not replace edit 
lists for audio priming or differing track start times.

This improves the diagnostic requested in issue #25775; it does not change 
timestamp handling.

Assisted-by: Fairy
---
 doc/muxers.texi      | 4 ++++
 libavformat/movenc.c | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index a2489760fcd..e22f07639de 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -549,6 +549,10 @@ reduces the need for edit lists for some cases such as 
video tracks with
 B-frames. Additionally, eases conformance with the DASH-IF interoperability
 guidelines.
 
+This does not eliminate the need for edit lists to preserve audio priming
+or differing track start times. Disabling edit lists with @option{use_editlist}
+can therefore cause audio/video desynchronization even when this flag is set.
+
 This option is implicitly set when writing @samp{ismv} (Smooth
 Streaming) files.
 
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index debe1acb7e0..5f63a19e5ba 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4528,7 +4528,10 @@ static int mov_write_trak_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContext
             mov_write_edts_tag(pb, mov, track);  // PSP Movies and several 
other cases require edts box
         else if ((track->entry && track->cluster[0].dts) || track->mode == 
MODE_PSP || is_clcp_track(track))
             av_log(mov->fc, AV_LOG_WARNING,
-                   "Not writing any edit list even though one would have been 
required\n");
+                   "Track ID %d: not writing any edit list even though one 
would have "
+                   "been required (start DTS %"PRId64", %.3f ms). A/V sync may 
be incorrect.\n",
+                   track->track_id, track->start_dts,
+                   track->start_dts * 1000.0 / track->timescale);
     }
 
     if (mov->is_animated_avif)
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to