dsh-bili-watch 0.2.25 → 0.2.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/tools/look.mjs +12 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-bili-watch",
3
- "version": "0.2.25",
3
+ "version": "0.2.26",
4
4
  "private": false,
5
5
  "description": "把 B 站视频读成文本给 DSH agent 用:元数据、评论、弹幕、字幕、本地转写、抽帧 OCR;支持 b23.tv 短链与 av 号,抽帧缓存目录可换。只读命令零依赖。",
6
6
  "type": "module",
package/tools/look.mjs CHANGED
@@ -433,7 +433,7 @@ function findFfmpeg(arg) {
433
433
  for (const c of cands) {
434
434
  if (c !== 'ffmpeg' && !existsSync(c)) continue
435
435
  try {
436
- execFileSync(c, ['-version'], { stdio: 'ignore' })
436
+ execFileSync(c, ['-version'], { stdio: 'ignore', timeout: 300000 })
437
437
  return c
438
438
  } catch {}
439
439
  }
@@ -623,12 +623,12 @@ async function grabFrames(bv, { step = 0, outDir, ffmpeg, fresh = false, p: page
623
623
  // 场景吸附:逐点 -ss 抽帧
624
624
  frameTimes.forEach((t, i) => {
625
625
  const out = join(dir, `${bv}-${String(i + 1).padStart(2, '0')}.jpg`)
626
- execFileSync(bin, ['-y', '-threads', '2', '-ss', String(t), '-i', mp4, '-frames:v', '1', '-q:v', '2', out], { stdio: 'ignore' })
626
+ execFileSync(bin, ['-y', '-threads', '2', '-ss', String(t), '-i', mp4, '-frames:v', '1', '-q:v', '2', out], { stdio: 'ignore', timeout: 300000 })
627
627
  })
628
628
  } else {
629
629
  // 默认等间隔
630
630
  const pattern = join(dir, `${bv}-%02d.jpg`)
631
- execFileSync(bin, ['-y', '-threads', '2', '-i', mp4, '-vf', `fps=1/${useStep}`, '-q:v', '2', pattern], { stdio: 'ignore' })
631
+ execFileSync(bin, ['-y', '-threads', '2', '-i', mp4, '-vf', `fps=1/${useStep}`, '-q:v', '2', pattern], { stdio: 'ignore', timeout: 300000 })
632
632
  }
633
633
 
634
634
  const n = jpgs().length
@@ -1364,7 +1364,7 @@ async function cmdSheet(bv, opts = {}) {
1364
1364
  if (!bin) { process.exitCode = 1; console.log('✗ 找不到 ffmpeg:' + FFMPEG_HINT); return }
1365
1365
  const out = join(CACHE, 'sheets', `${bv}-p${opts.p ?? 1}-${grid}.jpg`)
1366
1366
  mkdirSync(dirname(out), { recursive: true })
1367
- execFileSync(bin, ['-y', '-threads', '2', '-i', join(tmp, '%02d.jpg'), '-vf', `scale=640:-1,tile=${cols}x${rows}`, '-frames:v', '1', out], { stdio: 'ignore' })
1367
+ execFileSync(bin, ['-y', '-threads', '2', '-i', join(tmp, '%02d.jpg'), '-vf', `scale=640:-1,tile=${cols}x${rows}`, '-frames:v', '1', out], { stdio: 'ignore', timeout: 300000 })
1368
1368
  console.log(`拼图: ${out}(${(statSync(out).size / 1024).toFixed(0)} KiB,共 ${picked.length} 帧)`)
1369
1369
  console.log('读这张图就能过一遍画面;要精确读字用 ocr <BV>。')
1370
1370
  }
@@ -1385,7 +1385,7 @@ async function cmdSubstrip(bv, opts = {}) {
1385
1385
  if (!bin) { process.exitCode = 1; console.log('✗ 找不到 ffmpeg:' + FFMPEG_HINT); return }
1386
1386
  const out = join(CACHE, 'sheets', `${bv}-p${opts.p ?? 1}-substrip.jpg`)
1387
1387
  mkdirSync(dirname(out), { recursive: true })
1388
- execFileSync(bin, ['-y', '-threads', '2', '-i', join(tmp, '%02d.jpg'), '-vf', `crop=iw:ih*0.20:0:ih*0.80,scale=1280:-1,tile=1x${take}`, '-frames:v', '1', out], { stdio: 'ignore' })
1388
+ execFileSync(bin, ['-y', '-threads', '2', '-i', join(tmp, '%02d.jpg'), '-vf', `crop=iw:ih*0.20:0:ih*0.80,scale=1280:-1,tile=1x${take}`, '-frames:v', '1', out], { stdio: 'ignore', timeout: 300000 })
1389
1389
  console.log(`字幕带: ${out}(${(statSync(out).size / 1024).toFixed(0)} KiB,共 ${take} 条)`)
1390
1390
  console.log('一张图里是整片底部字幕;硬字幕视频用它比逐帧 OCR 省很多。')
1391
1391
  }
@@ -1782,6 +1782,11 @@ async function cmdText(bv, credPath, opts = {}) {
1782
1782
  // 这时候转写出来的「字」只是把杂音听成了字,继续往下走 OCR 更靠谱。
1783
1783
  const rate = v.dur > 0 ? a.chars / v.dur : 0
1784
1784
  if (rate >= 2) {
1785
+ // T40:ASR 也会把杂音/背景音听成字,主入口同样要过诱饵信号(原先只有字幕分支有)
1786
+ const asrBait = baitSignals(a.text, v, credibility(v, a.text))
1787
+ if (asrBait.suspect) {
1788
+ say(`[track] ⚠ 转写可疑:${asrBait.reasons.join(';')}(机器转写本来就可能听错,要看画面加 --verify 再跑一次)`)
1789
+ }
1785
1790
  if (emitText(opts, {
1786
1791
  video: { bv, title: v.title, up: v.owner, dur: v.dur, p: v.p, pages: v.pages },
1787
1792
  source: 'asr',
@@ -2011,7 +2016,7 @@ function findYtDlp() {
2011
2016
  for (const c of cands) {
2012
2017
  if (c !== 'yt-dlp' && !existsSync(c)) continue
2013
2018
  try {
2014
- execFileSync(c, ['--version'], { stdio: 'ignore' })
2019
+ execFileSync(c, ['--version'], { stdio: 'ignore', timeout: 300000 })
2015
2020
  return c
2016
2021
  } catch {}
2017
2022
  }
@@ -2151,7 +2156,7 @@ async function grabFramesLocal(mp4, tag, dur, { step = 0 } = {}) {
2151
2156
  const bin = findFfmpeg()
2152
2157
  if (!bin) throw new Error('找不到 ffmpeg:' + FFMPEG_HINT)
2153
2158
  const pattern = join(dir, `${tag}-%02d.jpg`)
2154
- execFileSync(bin, ['-y', '-threads', '2', '-i', mp4, '-vf', `fps=1/${useStep}`, '-q:v', '2', pattern], { stdio: 'ignore' })
2159
+ execFileSync(bin, ['-y', '-threads', '2', '-i', mp4, '-vf', `fps=1/${useStep}`, '-q:v', '2', pattern], { stdio: 'ignore', timeout: 300000 })
2155
2160
  const n = jpgs().length
2156
2161
  if (!n) throw new Error('抽帧没产出图片(可能源流异常)')
2157
2162
  writeManifest(dir, { ok: true, tag, step: useStep, scene: false, frames: n })