feat: transform more than once from same stream

This commit is contained in:
langhuihui
2024-10-07 13:58:34 +08:00
parent fc790cfe06
commit 39f69441a7
50 changed files with 531 additions and 496 deletions

View File

@@ -20,7 +20,7 @@ import (
type (
H26xCtx struct {
RTPCtx
dtsEst *util.DTSEstimator
dtsEst util.DTSEstimator
}
H264Ctx struct {
H26xCtx
@@ -68,7 +68,6 @@ func (r *Video) Parse(t *AVTrack) (err error) {
ctx = t.ICodecCtx.(*H264Ctx)
} else {
ctx = &H264Ctx{}
ctx.dtsEst = util.NewDTSEstimator()
ctx.parseFmtpLine(r.RTPCodecParameters)
var sps, pps []byte
//packetization-mode=1; sprop-parameter-sets=J2QAKaxWgHgCJ+WagICAgQ==,KO48sA==; profile-level-id=640029
@@ -91,6 +90,7 @@ func (r *Video) Parse(t *AVTrack) (err error) {
return
}
pts := r.Packets[0].Timestamp
dts := ctx.dtsEst.Feed(pts)
r.DTS = time.Duration(dts) * time.Millisecond / 90
r.CTS = time.Duration(pts-dts) * time.Millisecond / 90
@@ -114,7 +114,6 @@ func (r *Video) Parse(t *AVTrack) (err error) {
ctx = t.ICodecCtx.(*H265Ctx)
} else {
ctx = &H265Ctx{}
ctx.dtsEst = util.NewDTSEstimator()
ctx.parseFmtpLine(r.RTPCodecParameters)
var vps, sps, pps []byte
if sprop_sps, ok := ctx.Fmtp["sprop-sps"]; ok {