From 7fb25692da50bdb2f3fa2de0732c2f308640dad5 Mon Sep 17 00:00:00 2001 From: Lidashuang Date: Sat, 23 Mar 2024 18:42:30 +0800 Subject: [PATCH] Add quque clean --- format/rtspv2/demuxer.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/format/rtspv2/demuxer.go b/format/rtspv2/demuxer.go index a4092d5..7efc9df 100644 --- a/format/rtspv2/demuxer.go +++ b/format/rtspv2/demuxer.go @@ -299,6 +299,7 @@ func (client *RTSPClient) appendAudioPacket(retmap []*av.Packet, nal []byte, dur } func (client *RTSPClient) appendVideoPacket(retmap []*av.Packet, nal []byte, isKeyFrame bool) []*av.Packet { + var realVideoMs int64 duration := time.Duration(float32(client.timestamp-client.PreVideoTS)/TimeBaseFactor) * time.Millisecond sdpDuration := client.durationFromSDP() if sdpDuration != 0 && duration > sdpDuration { @@ -314,9 +315,11 @@ func (client *RTSPClient) appendVideoPacket(retmap []*av.Packet, nal []byte, isK } else { client.keyFrameIterateDrua += duration.Milliseconds() } - realVideoMs := client.keyFrameRealVideoTs * 1000 + if client.realVideoTs != 0 { + realVideoMs = client.keyFrameRealVideoTs * 1000 + realVideoMs += client.keyFrameIterateDrua + } - realVideoMs += client.keyFrameIterateDrua return append(retmap, &av.Packet{ Data: append(binSize(len(nal)), nal...), CompositionTime: time.Duration(TimeDelay) * time.Millisecond,