Skip to content

Commit f1e031c

Browse files
authored
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.
1 parent d23fb08 commit f1e031c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

internal/recorder/format_fmp4.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ func (f *formatFMP4) initialize() bool {
611611
Payload: packet,
612612
},
613613
dts: pts,
614-
ntp: tunit.NTP.Add(timestampToDuration(pts, clockRate)),
614+
ntp: tunit.NTP.Add(timestampToDuration(pts-tunit.PTS, clockRate)),
615615
})
616616
if err != nil {
617617
return err
@@ -649,7 +649,7 @@ func (f *formatFMP4) initialize() bool {
649649
Payload: au,
650650
},
651651
dts: pts,
652-
ntp: tunit.NTP.Add(timestampToDuration(pts, clockRate)),
652+
ntp: tunit.NTP.Add(timestampToDuration(pts-tunit.PTS, clockRate)),
653653
})
654654
if err != nil {
655655
return err
@@ -771,7 +771,7 @@ func (f *formatFMP4) initialize() bool {
771771
Payload: frame,
772772
},
773773
dts: pts,
774-
ntp: tunit.NTP.Add(timestampToDuration(pts, clockRate)),
774+
ntp: tunit.NTP.Add(timestampToDuration(pts-tunit.PTS, clockRate)),
775775
})
776776
if err != nil {
777777
return err

0 commit comments

Comments
 (0)