mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-05 15:46:58 +08:00
add SPS and PTS before IDRs of all incoming H264 streams; stop filtering H264 inside single protocols
This commit is contained in:
@@ -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,
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user