From: qydysky Date: Wed, 5 Jun 2024 13:20:16 +0000 (+0000) Subject: Fix flv未接收到起始段 #118 X-Git-Tag: v0.14.4~1 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=cb1fb73c07b5ad64e8433680f40e002e4bab86d1;p=bili_danmu%2F.git Fix flv未接收到起始段 #118 --- diff --git a/Reply/flvHeader b/Reply/flvHeader new file mode 100644 index 0000000..75362c7 Binary files /dev/null and b/Reply/flvHeader differ diff --git a/Reply/stream.go b/Reply/stream.go index 9516d14..3a994e2 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "crypto/md5" + _ "embed" "encoding/base64" "encoding/json" "errors" @@ -41,6 +42,9 @@ import ( pweb "github.com/qydysky/part/web" ) +//go:embed flvHeader +var flvHeader []byte + type M4SStream struct { Status context.Context //IsLive()是否运行中 exitSign *signal.Signal //IsLive()是否等待退出中 @@ -781,16 +785,19 @@ func (t *M4SStream) saveStreamFlv() (e error) { } if len(front_buf) != 0 && len(t.first_buf) == 0 { t.first_buf = make([]byte, len(front_buf)) - copy(t.first_buf, front_buf) // fmt.Println("write front_buf") // t.Stream_msg.PushLock_tag(`data`, t.first_buf) t.msg.Push_tag(`load`, t) } if keyframe.Size() != 0 { if len(t.first_buf) == 0 { - t.log.L(`W: `, `flv未接收到起始段`) - pctx.PutVal(cancelC, &errCtx, errors.New(`flv未接收到起始段`)) - break + // t.log.L(`W: `, `flv未接收到起始段`) + // pctx.PutVal(cancelC, &errCtx, errors.New(`flv未接收到起始段`)) + // break + // } else { + t.log.L(`W: `, `flv未接收到起始段,使用内置头`) + t.first_buf = flvHeader + t.msg.Push_tag(`load`, t) } buf, unlock := keyframe.GetPureBufRLock() t.bootBufPush(buf)