handle panic error on non-existing packet index (for audio, as example)

This commit is contained in:
Dimitrii Lopanov 2020-06-26 08:34:23 +03:00
parent ce2edddbeb
commit 0435cfa11a

View File

@ -154,6 +154,9 @@ func (self *Muxer) WriteHeader(streams []av.CodecData) (err error) {
}
func (self *Muxer) WritePacket(pkt av.Packet) (err error) {
if int(pkt.Idx) >= len(self.streams) {
return fmt.Errorf("Wrong stream index: %d", pkt.Idx)
}
stream := self.streams[pkt.Idx]
pkt.Time += time.Second