@cloud411716/fancy-webnovel 4.23.0 → 4.24.0

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.
@@ -205,6 +205,7 @@ id / kind / subkind / name / tags / genres / note / source
205
205
  - 独立视频作品会先尝试下载原片并用 ffmpeg 抽帧;下载失败时退化为播放器元素截图。
206
206
  视频时长超过 1 分钟直接跳过;前 5 秒与网文创作无关也跳过。
207
207
  - 场景切换点本身常是过渡虚影。插件会在密集采样后用 ffmpeg blurdetect 给每帧打分,在每个稳定画面段的清晰中段选一帧,避免把文字尚未完全出现的模糊帧交给 LLM。
208
+ - 稳定画面段可能漏掉只出现 0.3–0.5 秒的短字幕。每个视频页会额外生成一张覆盖全片的密集预览图(15 秒内约每 0.4 秒一帧),LLM 必须同时读取关键帧拼图和密集预览,补齐短字幕后再去重。
208
209
  - 帧选择版本是 `frame_version: 3`;旧版本缓存的截图/关键帧会自动重新采集。
209
210
  - 子 Agent 或 DSH 在分析途中中断时,作品任务保持 pending;下次运行会复用已采集文件重新分析。旧版本留下的 aborted/failed 任务会在启动采集时自动恢复为 pending。
210
211
  - 抖音 DOM/类名会变,`scan-account.cjs`、`crawl-note.cjs` 和 `crawl-video.cjs`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "4.23.0",
3
+ "version": "4.24.0",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -679,6 +679,7 @@ async function analyzeVideo(ctx, invocation, session, {
679
679
  accountUrl,
680
680
  video,
681
681
  frames: video.frames || [],
682
+ overview: video.overview_file ? { file: video.overview_file, interval: video.overview_interval } : null,
682
683
  targetFile: target,
683
684
  workspace: root,
684
685
  queryScript: materialTools.queryScript,
@@ -732,6 +733,7 @@ function analysisPromptForJob(job, root, materialTools) {
732
733
  accountUrl: job.accountUrl,
733
734
  video: job.video,
734
735
  frames: job.video.frames || [],
736
+ overview: job.video.overview_file ? { file: job.video.overview_file, interval: job.video.overview_interval } : null,
735
737
  targetFile: job.target,
736
738
  workspace: root,
737
739
  queryScript: materialTools.queryScript,
@@ -12,6 +12,7 @@
12
12
  {{SCREENSHOT_LIST}}
13
13
 
14
14
  截图可能来自图片页,也可能是同一页视频的关键帧拼图。带“第 X 页(视频……)”的图片属于同一页素材,请按从左到右读取拼图里的多个瞬间,合并提取,不要把同一页的多个瞬间当成多条素材。视频关键帧里的动态字幕、标语、口播文字也要提取到 `name`、`tags` 或 `note` 中;不要只看封面图。
15
+ 如果同一视频页同时提供关键帧拼图和密集预览图,必须逐格读取密集预览,补齐只出现很短时间的字幕或画面,再与关键帧去重。
15
16
 
16
17
  ## 图片专用补充
17
18
 
@@ -15,6 +15,12 @@
15
15
 
16
16
  {{FRAME_LIST}}
17
17
 
18
+ ## 密集预览图
19
+
20
+ {{OVERVIEW_LIST}}
21
+
22
+ 密集预览图用于兜底:关键帧可能漏掉只出现很短时间的字幕或画面。必须逐格读取密集预览,补齐短字幕/短画面,再与关键帧去重。
23
+
18
24
  ## 视频专用补充
19
25
 
20
26
  - 关键帧按时间顺序看,先看前 5 秒,再看后续。
@@ -16,6 +16,7 @@ const {
16
16
  } = require('./lib.cjs');
17
17
  const {
18
18
  probeDuration, detectSceneTimes, fixedShortTimes, extractDenseFramesAt,
19
+ createVideoOverviewSheet,
19
20
  } = require('./video-frames.cjs');
20
21
 
21
22
  const UA = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36';
@@ -426,6 +427,11 @@ async function captureSlides(page, context, outDir) {
426
427
  slides.push(slide);
427
428
  const contact = createVideoContactSheet(frames, outDir, slideNo);
428
429
  slide.contact_file = contact;
430
+ const overview = fs.existsSync(videoFile)
431
+ ? createVideoOverviewSheet(videoFile, outDir, 'slide_' + String(slideNo).padStart(2, '0'), { duration: slide.duration })
432
+ : null;
433
+ slide.overview_file = overview ? overview.file : '';
434
+ slide.overview_interval = overview ? overview.interval : null;
429
435
  if (contact) {
430
436
  const times = frames.map((frame) => frame.time + ' 秒').join(' / ');
431
437
  screenshots.push({
@@ -450,6 +456,18 @@ async function captureSlides(page, context, outDir) {
450
456
  });
451
457
  }
452
458
  }
459
+ if (overview) {
460
+ screenshots.push({
461
+ index: screenshots.length + 1,
462
+ slide: slideNo,
463
+ type: 'video_overview',
464
+ duration: slide.duration,
465
+ interval: overview.interval,
466
+ file: overview.file,
467
+ label: '第 ' + slideNo + ' 页(视频 ' + (slide.duration ? slide.duration.toFixed(1) + ' 秒' : '')
468
+ + ',密集预览:每 ' + overview.interval + ' 秒一帧,按从左到右、从上到下读取)',
469
+ });
470
+ }
453
471
  } else {
454
472
  const file = path.join(outDir, 'slide_' + String(slideNo).padStart(2, '0') + '.jpg');
455
473
  let saved = false;
@@ -20,6 +20,7 @@ const {
20
20
  } = require('./lib.cjs');
21
21
  const {
22
22
  probeDuration, detectSceneTimes, fixedVideoTimes, extractDenseFramesAt,
23
+ createVideoOverviewSheet,
23
24
  } = require('./video-frames.cjs');
24
25
 
25
26
  const UA = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36';
@@ -317,6 +318,9 @@ async function main() {
317
318
  const captured = await captureFramesFromPage(page, outDir, duration, times);
318
319
  frames = captured.frames;
319
320
  }
321
+ const overview = videoFile && fs.existsSync(videoFile)
322
+ ? createVideoOverviewSheet(videoFile, outDir, 'video', { duration })
323
+ : null;
320
324
  first5s = frames.filter((frame) => Number(frame.time) < FIRST_SECONDS);
321
325
  if (!first5s.length) first5s = frames.slice(0, 1);
322
326
  if (!frames.length) throw new Error('没有抽取到视频关键帧');
@@ -348,6 +352,8 @@ async function main() {
348
352
  fixed_times: fixedTimes,
349
353
  video_file: videoFile,
350
354
  download_error: downloadError,
355
+ overview_file: overview ? overview.file : '',
356
+ overview_interval: overview ? overview.interval : null,
351
357
  frame_version: 3,
352
358
  crawled_at: new Date().toISOString(),
353
359
  dir: outDir,
@@ -358,6 +358,47 @@ function selectDenseFrameTimes(samples, {
358
358
  return [...new Set(picked.map((item) => Math.round(item.sample.time * 100) / 100))].sort((a, b) => a - b);
359
359
  }
360
360
 
361
+ /**
362
+ * Build one compact contact sheet from evenly spaced frames across the whole
363
+ * clip. It is a coverage safety net: short captions can fall between stable
364
+ * keyframes, but they still appear in the dense preview.
365
+ */
366
+ function createVideoOverviewSheet(file, outDir, prefix, {
367
+ duration = null,
368
+ columns = 4,
369
+ rows = 5,
370
+ width = 480,
371
+ timeout = 120000,
372
+ } = {}) {
373
+ fs.mkdirSync(outDir, { recursive: true });
374
+ const total = Number.isFinite(Number(duration)) && Number(duration) > 0
375
+ ? Number(duration)
376
+ : probeDuration(file);
377
+ if (!total) return null;
378
+ const cells = Math.max(1, Number(columns) * Number(rows));
379
+ const base = total <= SHORT_VIDEO_SECONDS ? 0.4 : 1;
380
+ const interval = Math.round(Math.max(base, total / Math.max(1, cells - 1)) * 100) / 100;
381
+ const fps = Math.round((1 / interval) * 1000) / 1000;
382
+ const target = path.join(outDir, prefix + '_overview.jpg');
383
+ const scale = 'fps=' + fps + ',scale=' + width + ':-2';
384
+ const label = "drawtext=text='%{pts\\:hms}':x=8:y=8:fontsize=22:fontcolor=yellow:box=1:boxcolor=black@0.6";
385
+ const tile = ',tile=' + columns + 'x' + rows;
386
+ const args = (filter) => [
387
+ '-y', '-hide_banner', '-loglevel', 'error',
388
+ '-i', file, '-vf', filter, '-frames:v', '1', target,
389
+ ];
390
+ let result = spawnSync('ffmpeg', args(scale + ',' + label + tile), {
391
+ encoding: 'utf8', timeout,
392
+ });
393
+ if (result.status !== 0 || !fs.existsSync(target)) {
394
+ result = spawnSync('ffmpeg', args(scale + tile), {
395
+ encoding: 'utf8', timeout,
396
+ });
397
+ }
398
+ if (result.status !== 0 || !fs.existsSync(target)) return null;
399
+ return { file: target, interval, columns, rows };
400
+ }
401
+
361
402
  /**
362
403
  * Dense sample + stable-state selection + frame extraction. Returns the
363
404
  * selected frames along with the sampling metadata for note.json/video.json.
@@ -403,4 +444,5 @@ module.exports = {
403
444
  analyzeDenseFrames,
404
445
  selectDenseFrameTimes,
405
446
  extractDenseFramesAt,
447
+ createVideoOverviewSheet,
406
448
  };
@@ -121,6 +121,12 @@ function frameListText(frames) {
121
121
  .join('\n');
122
122
  }
123
123
 
124
+ function overviewListText(overview) {
125
+ if (!overview || !overview.file) return '(没有密集预览图)';
126
+ const interval = Number(overview.interval);
127
+ return `- \`${overview.file}\`(密集预览:每 ${Number.isFinite(interval) ? interval : '?'} 秒一帧,按从左到右、从上到下读取)`;
128
+ }
129
+
124
130
  export function capabilityPrompt({ capabilityFile }) {
125
131
  return renderTemplate(CAPABILITY_PROMPT_FILE, {
126
132
  CAPABILITY_FILE: capabilityFile,
@@ -205,6 +211,7 @@ export function videoAnalysisPrompt({
205
211
  accountUrl,
206
212
  video,
207
213
  frames,
214
+ overview,
208
215
  targetFile,
209
216
  workspace,
210
217
  queryScript,
@@ -216,6 +223,7 @@ export function videoAnalysisPrompt({
216
223
  VIDEO_TITLE: read(video.title, '(无标题)'),
217
224
  VIDEO_DURATION: Number.isFinite(Number(video.duration)) ? String(Number(video.duration)) : '未知',
218
225
  FRAME_LIST: frameListText(frames) || '(没有关键帧)',
226
+ OVERVIEW_LIST: overviewListText(overview),
219
227
  WORK_ID: read(video.id, ''),
220
228
  FACET_CANDIDATES: renderFacetCandidates(),
221
229
  TARGET_FILE: targetFile,