]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Fix flv未接收到起始段 #118
authorqydysky <qydysky@foxmail.com>
Wed, 5 Jun 2024 13:20:16 +0000 (13:20 +0000)
committerqydysky <qydysky@foxmail.com>
Wed, 5 Jun 2024 13:20:16 +0000 (13:20 +0000)
Reply/flvHeader [new file with mode: 0644]
Reply/stream.go

diff --git a/Reply/flvHeader b/Reply/flvHeader
new file mode 100644 (file)
index 0000000..75362c7
Binary files /dev/null and b/Reply/flvHeader differ
index 9516d14ad579b3e1194df49db51483b5b63dcf55..3a994e29e987d6e2d335b9103f30cf9f1ef87260 100644 (file)
@@ -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)