]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Fix v0.16.0 不生成ass #172 (#173)
authorqydysky <qydysky@foxmail.com>
Mon, 24 Feb 2025 14:02:49 +0000 (22:02 +0800)
committerGitHub <noreply@github.com>
Mon, 24 Feb 2025 14:02:49 +0000 (22:02 +0800)
* Fix v0.16.0 不生成ass #172

* Fix v0.16.0 不生成ass #172

Reply/F.go
Reply/stream.go

index ae43844c781b719f544d4242326491e2ce3bcdd9..8954bf371a56ea51e7d6a1751580ad9330574d81 100644 (file)
@@ -1461,6 +1461,9 @@ func StartRecDanmu(ctx context.Context, filePath string) {
                msglog.L(`E: `, e)
        }
 
+       // Ass
+       replyFunc.Ass.ToAss(filePath)
+
        Recoder.Stop()
 }
 
index 8da7e8217bf6b21760e9dc43f8f09bb8b482903b..b9f857c3f18f1e6dd7e6f35b0b45a9b1ca856b5c 100644 (file)
@@ -1378,10 +1378,12 @@ func (t *M4SStream) Start() bool {
                                                return false
                                        }
 
-                                       // 当cut时,取消上次录制
-                                       contextC, cancel := context.WithCancel(mainCtx)
+                                       ctx, cancel := context.WithCancel(mainCtx)
                                        fc.FlashWithCallback(cancel)
 
+                                       // 当cut时,取消上次录制
+                                       ctx1, done := pctx.WithWait(ctx, 3, time.Second*30)
+
                                        // 分段时长min
                                        if l, ok := ms.common.K_v.LoadV("分段时长min").(float64); ok && l > 0 {
                                                cutT := time.Duration(int64(time.Minute) * int64(l))
@@ -1406,7 +1408,7 @@ func (t *M4SStream) Start() bool {
                                        startf := func(_ *M4SStream) error {
                                                l.L(`T: `, `开始`)
                                                //弹幕分值统计
-                                               replyFunc.DanmuCountPerMin.Rec(contextC, ms.common.Roomid, ms.GetSavePath())(ms.common.K_v.LoadV("弹幕分值"))
+                                               replyFunc.DanmuCountPerMin.Rec(ctx1, ms.common.Roomid, ms.GetSavePath())(ms.common.K_v.LoadV("弹幕分值"))
                                                return nil
                                        }
                                        stopf := func(_ *M4SStream) error {
@@ -1420,22 +1422,24 @@ func (t *M4SStream) Start() bool {
                                        }
 
                                        // savestate
-                                       if e, _ := videoInfo.Save.Run(contextC, ms); e != nil {
+                                       if e, _ := videoInfo.Save.Run(ctx1, ms); e != nil {
                                                l.L(`E: `, e)
                                        }
 
                                        //保存弹幕
-                                       go StartRecDanmu(contextC, ms.GetSavePath())
+                                       go StartRecDanmu(ctx1, ms.GetSavePath())
 
                                        path := ms.GetSavePath() + `0.` + ms.GetStreamType()
                                        startT := time.Now()
-                                       if e := ms.PusherToFile(contextC, path, startf, stopf); e != nil {
+                                       if e := ms.PusherToFile(ctx1, path, startf, stopf); e != nil {
                                                l.L(`E: `, e)
                                        }
                                        duration := time.Since(startT)
 
-                                       // Ass
-                                       replyFunc.Ass.ToAss(ms.GetSavePath())
+                                       // wait all goroutine exit
+                                       if e := done(); e != nil {
+                                               l.L(`E: `, e)
+                                       }
 
                                        //PusherToFile fin genFastSeed
                                        if disableFastSeed, ok := ms.common.K_v.LoadV("禁用快速索引生成").(bool); !ok || !disableFastSeed {