Fix wrong RTSP H264 profile for some cameras

This commit is contained in:
Alexey Khit
2023-01-08 21:05:17 +03:00
parent 57fa6a5530
commit f9cb6fd670
+11
View File
@@ -3,6 +3,7 @@ package h264
import (
"encoding/base64"
"encoding/binary"
"fmt"
"github.com/AlexxIT/go2rtc/pkg/streamer"
"strings"
)
@@ -51,6 +52,16 @@ func GetProfileLevelID(fmtp string) string {
if fmtp == "" {
return ""
}
// some cameras has wrong profile-level-id
// https://github.com/AlexxIT/go2rtc/issues/155
if s := streamer.Between(fmtp, "sprop-parameter-sets=", ","); s != "" {
sps, _ := base64.StdEncoding.DecodeString(s)
if len(sps) >= 4 {
return fmt.Sprintf("%06X", sps[1:4])
}
}
return streamer.Between(fmtp, "profile-level-id=", ";")
}