mp4mux: Don't write gap edit lists if their duration would be zero

The track might start later than the earliest track by less than one
timescale units, in which case writing an empty gap edit list would be
useless and confusing.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1014>
This commit is contained in:
Sebastian Dröge 2022-12-15 18:45:19 +02:00
parent f8024f072f
commit ed429d570e

View file

@ -1646,16 +1646,18 @@ fn write_elst(
let min_earliest_pts = header.streams.iter().map(|s| s.earliest_pts).min().unwrap();
if min_earliest_pts != stream.earliest_pts {
let gap = (stream.earliest_pts - min_earliest_pts)
.nseconds()
.mul_div_round(timescale as u64, gst::ClockTime::SECOND.nseconds())
.context("too big gap")?;
if gap > 0 {
// Entry count
v.extend(2u32.to_be_bytes());
// First entry for the gap
// Edit duration
let gap = (stream.earliest_pts - min_earliest_pts)
.nseconds()
.mul_div_round(timescale as u64, gst::ClockTime::SECOND.nseconds())
.context("too big gap")?;
v.extend(gap.to_be_bytes());
// Media time
@ -1668,6 +1670,10 @@ fn write_elst(
// Entry count
v.extend(1u32.to_be_bytes());
}
} else {
// Entry count
v.extend(1u32.to_be_bytes());
}
// Edit duration
let duration = (stream.end_pts - stream.earliest_pts)