fix(format/mp4f): maxFrames should be setable to reduce delay time

This commit is contained in:
Morlay 2022-10-14 10:11:42 +08:00
parent b31edccea5
commit 6d02957c38

View File

@ -26,8 +26,9 @@ type Muxer struct {
}
func NewMuxer(w *os.File) *Muxer {
return &Muxer{}
return &Muxer{maxFrames: 5}
}
func (self *Muxer) SetPath(path string) {
self.path = path
}
@ -291,7 +292,7 @@ func (element *Muxer) WritePacket(pkt av.Packet, GOP bool) (bool, []byte, error)
if stream.lastpkt != nil {
ts = pkt.Time - stream.lastpkt.Time
}
got, buf, err := stream.writePacketV3(pkt, ts, 5)
got, buf, err := stream.writePacketV3(pkt, ts, element.maxFrames)
stream.lastpkt = &pkt
if err != nil {
return false, []byte{}, err
@ -302,7 +303,7 @@ func (element *Muxer) WritePacket(pkt av.Packet, GOP bool) (bool, []byte, error)
if stream.lastpkt != nil {
ts = pkt.Time - stream.lastpkt.Time
}
got, buf, err := stream.writePacketV2(pkt, ts, 5)
got, buf, err := stream.writePacketV2(pkt, ts, element.maxFrames)
stream.lastpkt = &pkt
if err != nil {
return false, []byte{}, err