From efcfc1100e683ba02af2914dab55b4771aa8bdb5 Mon Sep 17 00:00:00 2001 From: Jae-Sung Lee Date: Fri, 21 Jul 2023 06:31:25 +0000 Subject: [PATCH] fix: overflow pcr --- pkg/mpegts/pack.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/mpegts/pack.go b/pkg/mpegts/pack.go index b4d1ecd..103fe31 100644 --- a/pkg/mpegts/pack.go +++ b/pkg/mpegts/pack.go @@ -116,10 +116,14 @@ func (frame *Frame) Pack() []byte { // reserved // program_clock_reference_extension // -------------------------------------- - packet[3] |= 0x20 // adaptation_field_control 设置Adaptation - packet[4] = 7 // adaptation_field_length - packet[5] = 0x50 // random_access_indicator + PCR_flag - packPcr(packet[6:], frame.Dts-delay) // using 6 byte + packet[3] |= 0x20 // adaptation_field_control 设置Adaptation + packet[4] = 7 // adaptation_field_length + packet[5] = 0x50 // random_access_indicator + PCR_flag + pcr := uint64(0) + if frame.Dts > delay { + pcr = frame.Dts - delay + } + packPcr(packet[6:], pcr) // using 6 byte wpos += 8 }