Fix RTSP processing for Amcrest IP4M-1051

This commit is contained in:
Alexey Khit
2022-10-29 11:29:53 +03:00
parent 49773a1ece
commit 7964b1743b
2 changed files with 9 additions and 6 deletions
+6 -5
View File
@@ -8,11 +8,12 @@ import (
) )
const ( const (
NALUTypePFrame = 1 NALUTypePFrame = 1 // Coded slice of a non-IDR picture
NALUTypeIFrame = 5 NALUTypeIFrame = 5 // Coded slice of an IDR picture
NALUTypeSEI = 6 NALUTypeSEI = 6 // Supplemental enhancement information (SEI)
NALUTypeSPS = 7 NALUTypeSPS = 7 // Sequence parameter set
NALUTypePPS = 8 NALUTypePPS = 8 // Picture parameter set
NALUTypeAUD = 9 // Access unit delimiter
) )
func NALUType(b []byte) byte { func NALUType(b []byte) byte {
+3 -1
View File
@@ -40,11 +40,13 @@ func RTPDepay(track *streamer.Track) streamer.WrapperFunc {
} }
if len(buf) == 0 { if len(buf) == 0 {
// Amcrest IP4M-1051: 9, 7, 8, 6, 28...
// Amcrest IP4M-1051: 9, 6, 1
switch NALUType(payload) { switch NALUType(payload) {
case NALUTypeIFrame: case NALUTypeIFrame:
// fix IFrame without SPS,PPS // fix IFrame without SPS,PPS
buf = append(buf, ps...) buf = append(buf, ps...)
case NALUTypeSEI: case NALUTypeSEI, NALUTypeAUD:
// fix ffmpeg with transcoding first frame // fix ffmpeg with transcoding first frame
i := int(4 + binary.BigEndian.Uint32(payload)) i := int(4 + binary.BigEndian.Uint32(payload))