From d34c9832f49477409ec6305bd67f81ca0462870f Mon Sep 17 00:00:00 2001 From: Alexander Tumin Date: Sun, 10 Mar 2024 01:40:45 +0300 Subject: [PATCH] fix audio sample reset, chunk restart --- integration/nicovideo/mp4.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/integration/nicovideo/mp4.go b/integration/nicovideo/mp4.go index d7c15fc..f25cd41 100644 --- a/integration/nicovideo/mp4.go +++ b/integration/nicovideo/mp4.go @@ -346,9 +346,10 @@ func defragmentMP4Samples( for _, s := range trun.Samples { idx := len(trak.Mdia.Minf.Stbl.Stts.SampleTimeDelta) - 1 + if idx < 0 || trak.Mdia.Minf.Stbl.Stts.SampleTimeDelta[idx] != s.Dur { - trak.Mdia.Minf.Stbl.Stts.SampleCount = []uint32{1} - trak.Mdia.Minf.Stbl.Stts.SampleTimeDelta = []uint32{s.Dur} + trak.Mdia.Minf.Stbl.Stts.SampleCount = append(trak.Mdia.Minf.Stbl.Stts.SampleCount, 1) + trak.Mdia.Minf.Stbl.Stts.SampleTimeDelta = append(trak.Mdia.Minf.Stbl.Stts.SampleTimeDelta, s.Dur) } else { trak.Mdia.Minf.Stbl.Stts.SampleCount[idx]++ } @@ -539,6 +540,8 @@ func (defrag *defragmenter) next(tracksamples [][]sampleoffset, traks []*mp4.Tra if err != nil { return } + + defrag.init = false } return