From: qydysky Date: Sat, 15 Jun 2024 17:16:08 +0000 (+0000) Subject: Add 配置 flv使用内置头 X-Git-Tag: v0.14.5~4 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=5846daba3c54d374c98f48571cce2aa530e17143;p=bili_danmu%2F.git Add 配置 flv使用内置头 --- diff --git a/Reply/stream.go b/Reply/stream.go index faa10b3..ab48eb2 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -731,13 +731,17 @@ func (t *M4SStream) saveStreamFlv() (e error) { { pipe := pio.NewPipe() var ( - leastReadUnix atomic.Int64 - readTO int64 = 3 + leastReadUnix atomic.Int64 + readTO int64 = 3 + useInterFlvHeader bool = false ) leastReadUnix.Store(time.Now().Unix()) if v, ok := t.common.K_v.LoadV(`flv断流超时s`).(float64); ok && int64(v) > readTO { readTO = int64(v) } + if v, ok := t.common.K_v.LoadV(`flv使用内置头`).(bool); ok && v { + useInterFlvHeader = v + } // read timeout go func() { @@ -820,18 +824,20 @@ func (t *M4SStream) saveStreamFlv() (e error) { } if keyframe.Size() != 0 { if len(t.first_buf) == 0 { - switch v.Codec { - case "hevc": - t.log.L(`W: `, `flv未接收到起始段,使用内置头`) - t.first_buf = t.first_buf[:0] - t.first_buf = append(t.first_buf, flvHeaderHevc...) - t.msg.Push_tag(`load`, t) - case "avc": - t.log.L(`W: `, `flv未接收到起始段,使用内置头`) - t.first_buf = t.first_buf[:0] - t.first_buf = append(t.first_buf, flvHeader...) - t.msg.Push_tag(`load`, t) - default: + if useInterFlvHeader { + switch v.Codec { + case "hevc": + t.log.L(`W: `, `flv未接收到起始段,使用内置头`) + t.first_buf = t.first_buf[:0] + t.first_buf = append(t.first_buf, flvHeaderHevc...) + t.msg.Push_tag(`load`, t) + case "avc": + t.log.L(`W: `, `flv未接收到起始段,使用内置头`) + t.first_buf = t.first_buf[:0] + t.first_buf = append(t.first_buf, flvHeader...) + t.msg.Push_tag(`load`, t) + default: + } } if len(t.first_buf) == 0 { t.log.L(`W: `, `flv未接收到起始段`) diff --git a/demo/config/config_K_v.json b/demo/config/config_K_v.json index 4ae5106..bad780d 100644 --- a/demo/config/config_K_v.json +++ b/demo/config/config_K_v.json @@ -75,6 +75,7 @@ "直播流接收n帧才保存": 3, "flv断流超时s": 5, "flv断流续接": true, + "flv使用内置头": false, "fmp4切片下载超时s": 3, "fmp4获取更多服务器": true, "fmp4跳过解码出错的帧-help": "fmp4跳过解码出错的帧、但可能导致关键帧时间上的跳越",