From 9c43838793c4fc57b05d8bb5dc8f546ce305bb6b Mon Sep 17 00:00:00 2001 From: Alfred Gutierrez Date: Thu, 24 Dec 2020 17:35:13 -0800 Subject: [PATCH] bugfix: fix update_sync_samples in Mp4TrackWriter where sync is not properly set in stss box #38 (#39) --- src/track.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/track.rs b/src/track.rs index 2802c6a..49c4185 100644 --- a/src/track.rs +++ b/src/track.rs @@ -663,16 +663,19 @@ impl Mp4TrackWriter { fn update_sync_samples(&mut self, is_sync: bool) { if let Some(ref mut stss) = self.trak.mdia.minf.stbl.stss { - stss.entries.push(self.sample_id); - } else { - if is_sync { + if !is_sync { return; } - let mut stss = StssBox::default(); - for i in 1..=self.trak.mdia.minf.stbl.stsz.sample_count { - stss.entries.push(i); + stss.entries.push(self.sample_id); + } else { + if !is_sync { + return; } + + // Create the stts box if not found and push the entry. + let mut stss = StssBox::default(); + stss.entries.push(self.sample_id); self.trak.mdia.minf.stbl.stss = Some(stss); }; }