From a0e81a6738e8b99d9440d283c50ddb93d5e4ff8a Mon Sep 17 00:00:00 2001 From: qydysky Date: Mon, 24 Feb 2025 22:02:49 +0800 Subject: [PATCH] =?utf8?q?Fix=20v0.16.0=20=E4=B8=8D=E7=94=9F=E6=88=90ass?= =?utf8?q?=20#172=20(#173)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * Fix v0.16.0 不生成ass #172 * Fix v0.16.0 不生成ass #172 --- Reply/F.go | 3 +++ Reply/stream.go | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Reply/F.go b/Reply/F.go index ae43844..8954bf3 100644 --- a/Reply/F.go +++ b/Reply/F.go @@ -1461,6 +1461,9 @@ func StartRecDanmu(ctx context.Context, filePath string) { msglog.L(`E: `, e) } + // Ass + replyFunc.Ass.ToAss(filePath) + Recoder.Stop() } diff --git a/Reply/stream.go b/Reply/stream.go index 8da7e82..b9f857c 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -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 { -- 2.39.2