[fix] rtmp2mpegts: 确保pts有值

pull/293/head
q191201771 2 years ago
parent 863ef3e110
commit 257d82bd8b

@ -146,6 +146,7 @@ func (s *Rtmp2MpegtsRemuxer) FlushAudio() {
var frame mpegts.Frame
frame.Cc = s.audioCc
frame.Dts = s.audioCacheFirstFramePts
frame.Cts = 0
frame.Pts = s.audioCacheFirstFramePts
frame.Key = false
frame.Raw = s.audioCacheFrames
@ -374,6 +375,7 @@ func (s *Rtmp2MpegtsRemuxer) feedVideo(msg base.RtmpMsg) {
frame.Cc = s.videoCc
frame.Dts = dts
frame.Cts = msg.Cts()
frame.Pts = frame.Dts + 90*uint64(frame.Cts)
frame.Key = msg.IsVideoKeyNalu()
frame.Raw = s.videoOut
frame.Pid = mpegts.PidVideo

@ -45,9 +45,9 @@ func (f *Rtmp2MpegtsTimestampFilter) Do(frame *mpegts.Frame) {
}
if frame.Dts < f.basicAudioDts {
Log.Warnf("[%s] audio dts invalid. dts=%d, base=%d, frame=%s", f.uk, frame.Dts, f.basicAudioDts, frame.DebugString())
return
} else {
frame.Dts -= f.basicAudioDts
}
frame.Dts -= f.basicAudioDts
frame.Pts = frame.Dts + 90*uint64(frame.Cts)
} else if frame.Sid == mpegts.StreamIdVideo {
if f.basicVideoDts == math.MaxUint64 {
@ -55,9 +55,9 @@ func (f *Rtmp2MpegtsTimestampFilter) Do(frame *mpegts.Frame) {
}
if frame.Dts < f.basicVideoDts {
Log.Warnf("[%s] video dts invalid. dts=%d, base=%d, frame=%s", f.uk, frame.Dts, f.basicVideoDts, frame.DebugString())
return
} else {
frame.Dts -= f.basicVideoDts
}
frame.Dts -= f.basicVideoDts
frame.Pts = frame.Dts + 90*uint64(frame.Cts)
}
}

Loading…
Cancel
Save