From 7964b1743b0d216029080000aece9125816cb8c4 Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Sat, 29 Oct 2022 11:29:53 +0300 Subject: [PATCH] Fix RTSP processing for Amcrest IP4M-1051 --- pkg/h264/helper.go | 11 ++++++----- pkg/h264/rtp.go | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/h264/helper.go b/pkg/h264/helper.go index e06e9f98..e073c4b1 100644 --- a/pkg/h264/helper.go +++ b/pkg/h264/helper.go @@ -8,11 +8,12 @@ import ( ) const ( - NALUTypePFrame = 1 - NALUTypeIFrame = 5 - NALUTypeSEI = 6 - NALUTypeSPS = 7 - NALUTypePPS = 8 + NALUTypePFrame = 1 // Coded slice of a non-IDR picture + NALUTypeIFrame = 5 // Coded slice of an IDR picture + NALUTypeSEI = 6 // Supplemental enhancement information (SEI) + NALUTypeSPS = 7 // Sequence parameter set + NALUTypePPS = 8 // Picture parameter set + NALUTypeAUD = 9 // Access unit delimiter ) func NALUType(b []byte) byte { diff --git a/pkg/h264/rtp.go b/pkg/h264/rtp.go index 9f84f745..0a80bfcc 100644 --- a/pkg/h264/rtp.go +++ b/pkg/h264/rtp.go @@ -40,11 +40,13 @@ func RTPDepay(track *streamer.Track) streamer.WrapperFunc { } if len(buf) == 0 { + // Amcrest IP4M-1051: 9, 7, 8, 6, 28... + // Amcrest IP4M-1051: 9, 6, 1 switch NALUType(payload) { case NALUTypeIFrame: // fix IFrame without SPS,PPS buf = append(buf, ps...) - case NALUTypeSEI: + case NALUTypeSEI, NALUTypeAUD: // fix ffmpeg with transcoding first frame i := int(4 + binary.BigEndian.Uint32(payload))