add SPS and PTS before IDRs of all incoming H264 streams; stop filtering H264 inside single protocols

This commit is contained in:
aler9
2022-03-06 17:33:16 +01:00
committed by Alessandro Ros
parent a34a01ebd9
commit dffe63f1bc
5 changed files with 41 additions and 84 deletions

View File

@@ -184,21 +184,9 @@ func (s *rtmpSource) runInner() bool {
return err
}
var outNALUs [][]byte
for _, nalu := range nalus {
// remove SPS, PPS and AUD, not needed by RTSP / RTMP
typ := h264.NALUType(nalu[0] & 0x1F)
switch typ {
case h264.NALUTypeSPS, h264.NALUTypePPS, h264.NALUTypeAccessUnitDelimiter:
continue
}
outNALUs = append(outNALUs, nalu)
}
pts := pkt.Time + pkt.CTime
pkts, err := h264Encoder.Encode(outNALUs, pts)
pkts, err := h264Encoder.Encode(nalus, pts)
if err != nil {
return fmt.Errorf("error while encoding H264: %v", err)
}
@@ -213,8 +201,8 @@ func (s *rtmpSource) runInner() bool {
} else {
res.stream.writeData(videoTrackID, &data{
rtp: pkt,
ptsEqualsDTS: h264.IDRPresent(outNALUs),
h264NALUs: outNALUs,
ptsEqualsDTS: h264.IDRPresent(nalus),
h264NALUs: nalus,
h264PTS: pts,
})
}