From f1e031c5c8e8351bcd33af97fa6399de773f7c04 Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Sat, 21 Dec 2024 11:18:23 +0100 Subject: [PATCH] fix recording timestamp with some audio codecs (#3969) (#4041) (#4062) When a stream contained an Opus, MPEG-4 audio or AC3 track, timestamp in the segment file name was increasing at twice the speed. --- internal/recorder/format_fmp4.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/recorder/format_fmp4.go b/internal/recorder/format_fmp4.go index 90885d7bbf7..b58e2ddaba9 100644 --- a/internal/recorder/format_fmp4.go +++ b/internal/recorder/format_fmp4.go @@ -611,7 +611,7 @@ func (f *formatFMP4) initialize() bool { Payload: packet, }, dts: pts, - ntp: tunit.NTP.Add(timestampToDuration(pts, clockRate)), + ntp: tunit.NTP.Add(timestampToDuration(pts-tunit.PTS, clockRate)), }) if err != nil { return err @@ -649,7 +649,7 @@ func (f *formatFMP4) initialize() bool { Payload: au, }, dts: pts, - ntp: tunit.NTP.Add(timestampToDuration(pts, clockRate)), + ntp: tunit.NTP.Add(timestampToDuration(pts-tunit.PTS, clockRate)), }) if err != nil { return err @@ -771,7 +771,7 @@ func (f *formatFMP4) initialize() bool { Payload: frame, }, dts: pts, - ntp: tunit.NTP.Add(timestampToDuration(pts, clockRate)), + ntp: tunit.NTP.Add(timestampToDuration(pts-tunit.PTS, clockRate)), }) if err != nil { return err