mp4mux: Don't write empty chunks at the end if the last buffer of a stream started a new chunk and happened to be a from a gap event

Empty chunks are not valid in MP4.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1014>
This commit is contained in:
Sebastian Dröge 2022-12-15 17:44:03 +02:00
parent 42385c81be
commit f8024f072f

View file

@ -779,6 +779,16 @@ impl MP4Mux {
&& buffer.buffer.size() == 0
{
gst::trace!(CAT, obj: stream.sinkpad, "Skipping gap buffer {buffer:?}");
// If a new chunk was just started for the gap buffer, don't bother and get rid
// of this chunk again for now and search for the next stream.
if let Some(chunk) = stream.chunks.last() {
if chunk.samples.is_empty() {
let _ = stream.chunks.pop();
state.current_stream_idx = None;
}
}
continue;
}