From 8f8a663555cc048a5af3d4d60f0153f7141e299b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 5 May 2025 16:46:51 +0300 Subject: [PATCH] fmp4mux: Add explanatory comment why tfdt is mapped to the earliest PTS Part-of: --- mux/fmp4/src/fmp4mux/imp.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mux/fmp4/src/fmp4mux/imp.rs b/mux/fmp4/src/fmp4mux/imp.rs index 67e132c3f..65bd4c035 100644 --- a/mux/fmp4/src/fmp4mux/imp.rs +++ b/mux/fmp4/src/fmp4mux/imp.rs @@ -2882,6 +2882,12 @@ impl FMP4Mux { drained_streams.push(( super::FragmentHeaderStream { caps: stream.caps.clone(), + // We're setting the tfdt to the earliest PTS of the fragment as it is supposed + // to be the sum of all sample durations of all previous fragments. + // + // In case of negative DTS this is not the same as the start DTS of the + // fragment (actually negative or negative but the whole PTS/DTS timeline is + // shifted above zero) so instead we work with the earliest PTS. start_time: Some(earliest_pts), start_ntp_time, delta_frames: stream.delta_frames,