From b45acf05c35af4c3f83b3ce7e93beb1cb27f76bc Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Mon, 10 May 2021 19:11:46 +0300 Subject: [PATCH] Add packet index to mp4f finalize --- format/mp4f/muxer.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/format/mp4f/muxer.go b/format/mp4f/muxer.go index 1e0630b..aa8429e 100644 --- a/format/mp4f/muxer.go +++ b/format/mp4f/muxer.go @@ -405,8 +405,8 @@ func (element *Stream) writePacketV3(pkt av.Packet, rawdur time.Duration, maxFra element.dts += element.timeToTs(rawdur) return got, out, nil } -func (element *Muxer) Finalize() []byte { - stream := element.streams[0] +func (element *Muxer) Finalize(pktIdx int8) []byte { + stream := element.streams[pktIdx] stream.moof.Tracks[0].Run.DataOffset = uint32(stream.moof.Len() + 8) out := make([]byte, stream.moof.Len()+len(stream.buffer)) stream.moof.Marshal(out) @@ -415,7 +415,6 @@ func (element *Muxer) Finalize() []byte { stream.sampleIndex = 0 stream.muxer.fragmentIndex++ return out - } //PutU32BE func