Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mux/mp4
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2022-12-15 19:45:19 +0300
committerSebastian Dröge <sebastian@centricular.com>2022-12-15 19:45:19 +0300
commited429d570e7494367cd8ef0135885547c39008a4 (patch)
tree17f26cea16d0f17b6bfdfb28d00ab0a53375c859 /mux/mp4
parentf8024f072f360d5672cf7674c6516aa032dd225c (diff)
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>
Diffstat (limited to 'mux/mp4')
-rw-r--r--mux/mp4/src/mp4mux/boxes.rs30
1 files changed, 18 insertions, 12 deletions
diff --git a/mux/mp4/src/mp4mux/boxes.rs b/mux/mp4/src/mp4mux/boxes.rs
index 219dc75dd..4309c9cd8 100644
--- a/mux/mp4/src/mp4mux/boxes.rs
+++ b/mux/mp4/src/mp4mux/boxes.rs
@@ -1646,24 +1646,30 @@ fn write_elst(
let min_earliest_pts = header.streams.iter().map(|s| s.earliest_pts).min().unwrap();
if min_earliest_pts != stream.earliest_pts {
- // 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
- v.extend((-1i64).to_be_bytes());
+ if gap > 0 {
+ // Entry count
+ v.extend(2u32.to_be_bytes());
- // Media rate
- v.extend(1u16.to_be_bytes());
- v.extend(0u16.to_be_bytes());
+ // First entry for the gap
+
+ // Edit duration
+ v.extend(gap.to_be_bytes());
+
+ // Media time
+ v.extend((-1i64).to_be_bytes());
+
+ // Media rate
+ v.extend(1u16.to_be_bytes());
+ v.extend(0u16.to_be_bytes());
+ } else {
+ // Entry count
+ v.extend(1u32.to_be_bytes());
+ }
} else {
// Entry count
v.extend(1u32.to_be_bytes());