File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,23 @@ func UnmarshalSDP(rawSDP []byte) ([]*core.Media, error) {
7575 if codec .FmtpLine == "" {
7676 codec .FmtpLine = findFmtpLine (codec .PayloadType , sd .MediaDescriptions )
7777 }
78+ case core .CodecH265 :
79+ if codec .FmtpLine != "" {
80+ // All three parameters are needed for a valid fmtp line. If we're missing one
81+ // then discard the entire line. The bitstream should contain the data in NAL units
82+ //
83+ // Some camera brands (notable Hikvision) don't include the vps property, rendering the entire
84+ // line invalid, because the sps property references the non-existent vps proper. This invalid
85+ // data will cause FFmpeg to crash with a `Could not write header (incorrect codec parameters ?): Invalid data found when processing input`
86+ // error when attempting to repackage the HEVC stream into outgoing RTSP stream. Removing the
87+ // fmtp line forces FFmpeg to rely on the bitstream directly, fixing this issue.
88+ valid := strings .Contains (codec .FmtpLine , "sprop-vps=" )
89+ valid = valid && strings .Contains (codec .FmtpLine , "sprop-sps=" )
90+ valid = valid && strings .Contains (codec .FmtpLine , "sprop-pps=" )
91+ if ! valid {
92+ codec .FmtpLine = ""
93+ }
94+ }
7895 case core .CodecOpus :
7996 // fix OPUS for some cameras https://datatracker.ietf.org/doc/html/rfc7587
8097 codec .ClockRate = 48000
You can’t perform that action at this time.
0 commit comments