From: qydysky Date: Sat, 19 Oct 2024 10:56:04 +0000 (+0800) Subject: Add 配置直播流仅类型 X-Git-Tag: v0.14.21~1 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=c2ff2da59273533685959d284ce82c7f392a0d39;p=bili_danmu%2F.git Add 配置直播流仅类型 --- diff --git a/Reply/stream.go b/Reply/stream.go index 431a455..d34e7a4 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -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" diff --git a/demo/config/config_K_v.json b/demo/config/config_K_v.json index bcf35e8..ff121c2 100644 --- a/demo/config/config_K_v.json +++ b/demo/config/config_K_v.json @@ -72,6 +72,8 @@ "直播流仅清晰度": false, "直播流类型-help": "flv,fmp4,flvH,fmp4H,带H后缀的为Hevc格式编码", "直播流类型": "fmp4", + "直播流仅类型-help": "为true时,限制仅录制指定类型,避免类型不可用时自动切换类型。当类型不符时,将等候5s重试。默认为false", + "直播流仅类型": false, "直播流不使用mcdn": false, "直播流停用服务器-help": "正则字符串数组", "直播流停用服务器": [],