From 7e13ea4ba9f166781705b1db47e9584400e123b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 15 Sep 2022 18:11:10 +0300 Subject: [PATCH] fmp4mux: Drop gap buffers before further processing They would potentially change timestamps and will break in ONVIF mode. --- generic/fmp4/src/fmp4mux/imp.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/generic/fmp4/src/fmp4mux/imp.rs b/generic/fmp4/src/fmp4mux/imp.rs index 306ec687..2e9ff88f 100644 --- a/generic/fmp4/src/fmp4mux/imp.rs +++ b/generic/fmp4/src/fmp4mux/imp.rs @@ -889,6 +889,15 @@ impl FMP4Mux { } } + // Remove all GAP buffers before processing them further + for buffers in &mut drain_buffers { + buffers.retain(|buf| { + !buf.buffer.flags().contains(gst::BufferFlags::GAP) + || !buf.buffer.flags().contains(gst::BufferFlags::DROPPABLE) + || buf.buffer.size() != 0 + }); + } + let mut max_end_utc_time = None; // For ONVIF, replace all timestamps with timestamps based on UTC times. if class.as_ref().variant == super::Variant::ONVIF { @@ -1196,13 +1205,6 @@ impl FMP4Mux { if interleaved_buffers.is_empty() { assert!(timeout || at_eos); } else { - // Remove all GAP buffers before writing them out - interleaved_buffers.retain(|buf| { - !buf.buffer.flags().contains(gst::BufferFlags::GAP) - || !buf.buffer.flags().contains(gst::BufferFlags::DROPPABLE) - || buf.buffer.size() != 0 - }); - let min_earliest_pts_position = min_earliest_pts_position.unwrap(); let min_earliest_pts = min_earliest_pts.unwrap(); let max_end_pts = max_end_pts.unwrap();