mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-25 04:22:00 -08:00
hls muxer: stop normalizing PTS
This commit is contained in:
parent
acd788d632
commit
4073013f68
6 changed files with 7 additions and 20 deletions
2
go.mod
2
go.mod
|
|
@ -5,7 +5,7 @@ go 1.17
|
|||
require (
|
||||
code.cloudfoundry.org/bytefmt v0.0.0-20211005130812-5bb3c17173e5
|
||||
github.com/abema/go-mp4 v0.7.2
|
||||
github.com/aler9/gortsplib v0.0.0-20220602183811-46253a74b083
|
||||
github.com/aler9/gortsplib v0.0.0-20220602202513-787c516d791e
|
||||
github.com/asticode/go-astits v1.10.1-0.20220319093903-4abe66a9b757
|
||||
github.com/fsnotify/fsnotify v1.4.9
|
||||
github.com/gin-gonic/gin v1.7.2
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -6,8 +6,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo
|
|||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||
github.com/aler9/gortsplib v0.0.0-20220602183811-46253a74b083 h1:VmY5jw7jBl4PTX7J9UIrslRRco1ELt9oDteq9CmecqU=
|
||||
github.com/aler9/gortsplib v0.0.0-20220602183811-46253a74b083/go.mod h1:i1e4CEs42IrbidMUNTSNOKmeGPCOHVX9P3BvPxzyMtI=
|
||||
github.com/aler9/gortsplib v0.0.0-20220602202513-787c516d791e h1:OCMAhEoYzacPQ6et2EKt/xy4kXksSoYFLXP9ROlH/1c=
|
||||
github.com/aler9/gortsplib v0.0.0-20220602202513-787c516d791e/go.mod h1:i1e4CEs42IrbidMUNTSNOKmeGPCOHVX9P3BvPxzyMtI=
|
||||
github.com/aler9/rtmp v0.0.0-20210403095203-3be4a5535927 h1:95mXJ5fUCYpBRdSOnLAQAdJHHKxxxJrVCiaqDi965YQ=
|
||||
github.com/aler9/rtmp v0.0.0-20210403095203-3be4a5535927/go.mod h1:vzuE21rowz+lT1NGsWbreIvYulgBpCGnQyeTyFblUHc=
|
||||
github.com/aler9/writerseeker v0.0.0-20220601075008-6f0e685b9c82 h1:9WgSzBLo3a9ToSVV7sRTBYZ1GGOZUpq4+5H3SN0UZq4=
|
||||
|
|
|
|||
|
|
@ -367,6 +367,7 @@ func (c *rtmpConn) runRead(ctx context.Context) error {
|
|||
videoDTSExtractor = h264.NewDTSExtractor()
|
||||
}
|
||||
|
||||
// normalize as this is expected in RTMP
|
||||
pts -= videoFirstIDRPTS
|
||||
|
||||
dts, err := videoDTSExtractor.Extract(data.h264NALUs, pts)
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ type muxerVariantFMP4Segmenter struct {
|
|||
videoFirstIDRReceived bool
|
||||
videoDTSExtractor *h264.DTSExtractor
|
||||
videoSPS []byte
|
||||
startPTS time.Duration
|
||||
currentSegment *muxerVariantFMP4Segment
|
||||
nextSegmentID uint64
|
||||
nextPartID uint64
|
||||
|
|
@ -157,9 +156,6 @@ func (m *muxerVariantFMP4Segmenter) writeH264Entry(sample *fmp4VideoSample) erro
|
|||
}
|
||||
sample.nalus = nil
|
||||
|
||||
sample.pts -= m.startPTS
|
||||
sample.dts -= m.startPTS
|
||||
|
||||
// put samples into a queue in order to
|
||||
// - allow to compute sample duration
|
||||
// - check if next sample is IDR
|
||||
|
|
@ -184,12 +180,6 @@ func (m *muxerVariantFMP4Segmenter) writeH264Entry(sample *fmp4VideoSample) erro
|
|||
m.genPartID,
|
||||
m.onPartFinalized,
|
||||
)
|
||||
|
||||
m.startPTS = sample.pts
|
||||
sample.pts = 0
|
||||
sample.dts = 0
|
||||
sample.next.pts -= m.startPTS
|
||||
sample.next.dts -= m.startPTS
|
||||
}
|
||||
|
||||
m.adjustPartDuration(sample.duration())
|
||||
|
|
@ -252,8 +242,6 @@ func (m *muxerVariantFMP4Segmenter) writeAAC(pts time.Duration, aus [][]byte) er
|
|||
}
|
||||
|
||||
func (m *muxerVariantFMP4Segmenter) writeAACEntry(sample *fmp4AudioSample) error {
|
||||
sample.pts -= m.startPTS
|
||||
|
||||
// put samples into a queue in order to
|
||||
// allow to compute the sample duration
|
||||
sample, m.nextAudioSample = m.nextAudioSample, sample
|
||||
|
|
@ -278,10 +266,6 @@ func (m *muxerVariantFMP4Segmenter) writeAACEntry(sample *fmp4AudioSample) error
|
|||
m.genPartID,
|
||||
m.onPartFinalized,
|
||||
)
|
||||
|
||||
m.startPTS = sample.pts
|
||||
sample.pts = 0
|
||||
sample.next.pts -= m.startPTS
|
||||
}
|
||||
} else {
|
||||
// wait for the video track
|
||||
|
|
|
|||
|
|
@ -188,7 +188,8 @@ func (t *muxerVariantMPEGTSSegment) writeAAC(
|
|||
OptionalHeader: &astits.PESOptionalHeader{
|
||||
MarkerBits: 2,
|
||||
PTSDTSIndicator: astits.PTSDTSIndicatorOnlyPTS,
|
||||
PTS: &astits.ClockReference{Base: int64((pts + mpegtsPTSDTSOffset + mpegtsPCROffset).Seconds() * 90000)},
|
||||
PTS: &astits.ClockReference{Base: int64((pts + mpegtsPTSDTSOffset +
|
||||
mpegtsPCROffset).Seconds() * 90000)},
|
||||
},
|
||||
PacketLength: uint16(len(enc) + 8),
|
||||
StreamID: 192, // audio
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ func (m *muxerVariantMPEGTSSegmenter) writeH264(pts time.Duration, nalus [][]byt
|
|||
m.videoDTSExtractor = h264.NewDTSExtractor()
|
||||
pts = 0
|
||||
} else {
|
||||
// normalize in order to sync with PCR
|
||||
pts -= m.startPTS
|
||||
|
||||
// switch segment
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue