]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Add 配置直播流仅类型
authorqydysky <qydysky@foxmail.com>
Sat, 19 Oct 2024 10:56:04 +0000 (18:56 +0800)
committerqydysky <qydysky@foxmail.com>
Sat, 19 Oct 2024 10:56:04 +0000 (18:56 +0800)
Reply/stream.go
demo/config/config_K_v.json

index 431a45525f04aabbeb298d448ae676f2b446083e..d34e7a46a1a7bce746d22377a659603f57f6a0ef 100644 (file)
@@ -290,6 +290,50 @@ func (t *M4SStream) fetchCheckStream() bool {
                }
        }
 
+       // 直播流仅类型
+       if v, ok := t.common.K_v.LoadV("直播流仅类型").(bool); ok && v {
+               // 期望类型
+               if vt, ok := t.common.K_v.LoadV(`直播流类型`).(string); ok {
+                       var (
+                               pass   bool
+                               cuType string
+                               cuCode string
+                       )
+
+                       if strings.Contains(t.common.Live[0].Codec, `hevc`) {
+                               cuCode = `hevc`
+                       } else if strings.Contains(t.common.Live[0].Codec, `avc`) {
+                               cuCode = `avc`
+                       } else {
+                               cuCode = `unknow`
+                       }
+
+                       if strings.Contains(t.common.Live[0].Url, `m3u8`) {
+                               cuType = `m3u8`
+                       } else if strings.Contains(t.common.Live[0].Url, `flv`) {
+                               cuType = `flv`
+                       } else {
+                               cuType = `unknow`
+                       }
+
+                       switch vt {
+                       case `fmp4H`:
+                               pass = cuType == `m3u8` && cuCode == `hevc`
+                       case `fmp4`:
+                               pass = cuType == `m3u8` && cuCode == `avc`
+                       case `flvH`:
+                               pass = cuType == `flv` && cuCode == `hevc`
+                       case `flv`:
+                               pass = cuType == `flv` && cuCode == `avc`
+                       }
+
+                       if !pass {
+                               _log.L(`W: `, `仅类型true,当前类型`, cuType, cuCode)
+                               return false
+                       }
+               }
+       }
+
        // 保存流类型
        if strings.Contains(t.common.Live[0].Url, `m3u8`) {
                t.stream_type = "mp4"
index bcf35e833655e860a433cd057a1cda78595736cb..ff121c2bc4342c56d3fbd673922b98bffc9d5b61 100644 (file)
@@ -72,6 +72,8 @@
     "直播流仅清晰度": false,
     "直播流类型-help": "flv,fmp4,flvH,fmp4H,带H后缀的为Hevc格式编码",
     "直播流类型": "fmp4",
+    "直播流仅类型-help": "为true时,限制仅录制指定类型,避免类型不可用时自动切换类型。当类型不符时,将等候5s重试。默认为false",
+    "直播流仅类型": false,
     "直播流不使用mcdn": false,
     "直播流停用服务器-help": "正则字符串数组",
     "直播流停用服务器": [],