From cf21bfabf253f4d905fe381ad6e50b2c499c525c Mon Sep 17 00:00:00 2001 From: Antonio Kevo Date: Wed, 10 May 2023 16:02:12 +0200 Subject: [PATCH] fmp4: Use updated start_pts when checking stream filled After calculating the earliest pts, the fragment_start_pts and chunk_start_pts in State are updated. However, when checking if the stream is filled, the previous start_pts (set to None) is used instead. This means that chunk_filled and fragment_filled will be false the first time aggregate() is called, assuming timeout is false, all_eos is false, and the sinkpad is not EOS. This requires aggregate() having to be called a second time before the first fragment is sent. Part-of: --- mux/fmp4/src/fmp4mux/imp.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mux/fmp4/src/fmp4mux/imp.rs b/mux/fmp4/src/fmp4mux/imp.rs index 38e48dd0..d96f0199 100644 --- a/mux/fmp4/src/fmp4mux/imp.rs +++ b/mux/fmp4/src/fmp4mux/imp.rs @@ -1117,9 +1117,6 @@ impl FMP4Mux { return; } - let fragment_start_pts = state.fragment_start_pts; - let chunk_start_pts = state.chunk_start_pts; - // Calculate the earliest PTS after queueing input if we can now. let mut earliest_pts = None; let mut start_dts = None; @@ -1228,6 +1225,9 @@ impl FMP4Mux { upstream_events.push((stream.sinkpad.clone(), fku)); } + let fragment_start_pts = state.fragment_start_pts; + let chunk_start_pts = state.chunk_start_pts; + // Check if any of the streams are already filled enough for the first chunk/fragment. for stream in &mut state.streams { self.check_stream_filled(