Skip to content

Commit

Permalink
fix audio sample reset, chunk restart
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtakingiteasy committed Mar 9, 2024
1 parent e983c3f commit d34c983
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions integration/nicovideo/mp4.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]++
}
Expand Down Expand Up @@ -539,6 +540,8 @@ func (defrag *defragmenter) next(tracksamples [][]sampleoffset, traks []*mp4.Tra
if err != nil {
return
}

defrag.init = false
}

return
Expand Down

0 comments on commit d34c983

Please sign in to comment.