From 0c4f6e2d43ce443e957b35c034662b5d5c8170cc Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Tue, 10 May 2022 23:34:25 +0200 Subject: [PATCH] rtmp server: fix bias error in AAC DTS --- internal/core/rtmp_conn.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/core/rtmp_conn.go b/internal/core/rtmp_conn.go index 1a98dba0..26cd3a6d 100644 --- a/internal/core/rtmp_conn.go +++ b/internal/core/rtmp_conn.go @@ -423,18 +423,16 @@ func (c *rtmpConn) runRead(ctx context.Context) error { continue } - for _, au := range aus { + for i, au := range aus { c.conn.SetWriteDeadline(time.Now().Add(time.Duration(c.writeTimeout))) err := c.conn.WritePacket(av.Packet{ Type: av.AAC, Data: au, - Time: pts, + Time: pts + time.Duration(i)*aac.SamplesPerAccessUnit*time.Second/time.Duration(audioTrack.ClockRate()), }) if err != nil { return err } - - pts += aac.SamplesPerAccessUnit * time.Second / time.Duration(audioTrack.ClockRate()) } } }