dsh-ffmpeg 0.7.4 → 0.7.5

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # 更新记录
2
2
 
3
+ ## 0.7.5 (2026-10-30)
4
+
5
+ - `ffmpeg_health` 现在输出实际探测的可执行文件路径,失败时附 1-3 步修复指引(安装 FFmpeg / 加入 PATH / 配置 ffmpegPath 或 DSH_FFMPEG_PATH / 重启 DSH)并在结构化结果里给出 `hint`;工具结果文本同步显示。
6
+ - 可执行文件缺失(ENOENT)时,各工具直接给出可行动的修复文案并点名 `ffmpeg_health`,其他错误(如 EACCES)保持原样不被改写;取消语义不变。
7
+ - 使用说明新增「故障排查」表:ENOENT、退出码失败、超时、4MB 输出截断、覆盖拒绝、源文件保护与总览图时间含义。
8
+ - Health now prints the probed executable paths, adds numbered next steps and a structured hint on failure; missing binaries produce actionable tool errors that point at ffmpeg_health while other errors stay untouched; new troubleshooting docs.
9
+
3
10
  ## 0.7.4 (2026-10-30)
4
11
 
5
12
  - 重整中英文首页:用途、三步流程图、安装入口与操作示例;详细配置与边界集中到完整说明。
package/docs/USAGE.en.md CHANGED
@@ -63,6 +63,20 @@ ffmpeg_extract { input: E:\videos\raw.webm, what: audio }
63
63
  ffmpeg_gif { input: E:\videos\raw.mp4, duration: 3, width: 480 }
64
64
  ```
65
65
 
66
+ ## Troubleshooting
67
+
68
+ Run `ffmpeg_health` first: it probes ffmpeg and ffprobe separately, prints the executable actually used, and adds numbered next steps when a check fails.
69
+
70
+ | Symptom | Cause and fix |
71
+ | :-- | :-- |
72
+ | `spawn ffmpeg ENOENT` / "could not start: executable not found" | FFmpeg is missing or not on PATH. Install FFmpeg (with ffprobe), or set `ffmpegPath` / `ffprobePath` in `cordis.patch.yml`, or `DSH_FFMPEG_PATH` / `DSH_FFPROBE_PATH` (absolute paths), then restart DSH and run `ffmpeg_health` again |
73
+ | `failed (exit code N): …` | The tail of ffmpeg's own stderr. Read the last line first; unsupported codecs, subtitle paths and filter arguments are the usual causes |
74
+ | The operation timed out | The default per-operation limit is 5 minutes. Raise `timeoutMs` (up to 2 hours) for large files or multi-input concat, or process in `start`/`end` slices |
75
+ | "output over 4MB was truncated" | The probe output was truncated by the host and cannot be parsed. Narrow the probe (cut a slice first) or use a smaller input |
76
+ | "frame output already exists … refusing to overwrite" | Frame sequences default to a fresh `<name>-frames/run-*` directory; with an explicit output, change the prefix or set `overwrite: true` |
77
+ | "output path equals the input file" | Overwrite protection. Choose another output path; same-name outputs are auto-suffixed with `_1`/`_2` |
78
+ | Reported times do not match exact frames | `ffmpeg_storyboard` reports sampling targets, and uniform sampling is not shot detection. For exact timecodes use `ffmpeg_probe` plus `ffmpeg_extract` |
79
+
66
80
  ## Safety
67
81
 
68
82
  - **No shell**: every argument is passed as its own argv element — user input cannot inject commands
@@ -75,7 +89,7 @@ ffmpeg_gif { input: E:\videos\raw.mp4, duration: 3, width: 480 }
75
89
 
76
90
  ```bash
77
91
  pnpm install
78
- pnpm test # build + 121 tests
92
+ pnpm test # build + 123 tests
79
93
  ```
80
94
 
81
95
  ## License
package/docs/USAGE.md CHANGED
@@ -67,6 +67,20 @@ ffmpeg_gif { input: E:\videos\raw.mp4, duration: 3, width: 480 }
67
67
  ffmpeg_adjust { input: E:\videos\raw.mp4, volume: +2dB }
68
68
  ```
69
69
 
70
+ ## 故障排查
71
+
72
+ 遇到问题先运行 `ffmpeg_health`:它会分别探测 ffmpeg 与 ffprobe,输出实际使用的可执行文件路径;失败时附「下一步」修复步骤。
73
+
74
+ | 现象 | 原因与处理 |
75
+ | :-- | :-- |
76
+ | `spawn ffmpeg ENOENT` / 提示「找不到可执行文件」 | ffmpeg 未安装或不在 PATH。安装 FFmpeg(含 ffprobe),或在 `cordis.patch.yml` 配置 `ffmpegPath` / `ffprobePath`,也可设置 `DSH_FFMPEG_PATH` / `DSH_FFPROBE_PATH`(绝对路径),重启 DSH 后重跑 `ffmpeg_health` |
77
+ | `失败(退出码 N):…` | 直接来自 ffmpeg 的 stderr 尾部。先看最后一行,常见原因是输入编码、字幕文件路径或滤镜参数不支持 |
78
+ | 操作超时 | 单次操作默认 5 分钟。大文件或多路拼接可调大 `timeoutMs`(上限 2 小时),或用 `start`/`end` 分段处理 |
79
+ | 「输出超过 4MB 已截断」 | 探测输出被宿主截断无法解析。缩小探测范围(先 `ffmpeg_cut` 截出片段再 probe),或改用更小的输入 |
80
+ | 「抽帧输出已存在…已拒绝覆盖」 | 帧序列默认写入新的 `<名称>-frames/run-*` 目录;显式指定 output 时请更换文件名前缀或使用 `overwrite: true` |
81
+ | 「输出路径与输入文件相同」 | 防覆写保护:换输出路径或文件名。同名成品默认自动加 `_1`/`_2` 序号 |
82
+ | 结果里的时间不是精确帧 | `ffmpeg_storyboard` 报告的是采样目标时间,均匀采样不等于镜头检测;需要精确时间码时用 `ffmpeg_probe` + `ffmpeg_extract` |
83
+
70
84
  ## 安全设计
71
85
 
72
86
  - **无 shell**:所有参数以独立 argv 数组传递,用户输入不可能注入命令
@@ -79,7 +93,7 @@ ffmpeg_adjust { input: E:\videos\raw.mp4, volume: +2dB }
79
93
 
80
94
  ```bash
81
95
  pnpm install
82
- pnpm test # 构建 + 121 个测试
96
+ pnpm test # 构建 + 123 个测试
83
97
  ```
84
98
 
85
99
  ## License
package/lib/tools.js CHANGED
@@ -75,10 +75,28 @@ function throwIfAborted(signal) {
75
75
  if (signal?.aborted === true)
76
76
  throw signal.reason;
77
77
  }
78
+ /**
79
+ * 可执行文件缺失时给可行动的修复指引;其他错误返回 undefined 以免掩盖真实原因。
80
+ * 取消信号在调用处先处理,不会被这里改写。
81
+ */
82
+ function missingBinaryMessage(label, error) {
83
+ const text = error instanceof Error ? error.message : String(error);
84
+ if (!/ENOENT|not found|no such file|无法找到|找不到/i.test(text))
85
+ return undefined;
86
+ return label + ' 无法启动:找不到可执行文件(' + text + ')。请先运行 ffmpeg_health 自检;安装 FFmpeg / ffprobe 并加入 PATH,或在 cordis.patch.yml 配置 ffmpegPath / ffprobePath(也可用 DSH_FFMPEG_PATH / DSH_FFPROBE_PATH),重启 DSH 后重试。';
87
+ }
78
88
  /** 执行并检查退出码;非零抛中文错误(附 stderr 尾部)。 */
79
89
  async function runChecked(runner, argv, timeoutMs, label, signal) {
80
90
  throwIfAborted(signal);
81
- const result = await runner.run(argv, { timeoutMs, ...(signal === undefined ? {} : { signal }) });
91
+ let result;
92
+ try {
93
+ result = await runner.run(argv, { timeoutMs, ...(signal === undefined ? {} : { signal }) });
94
+ }
95
+ catch (error) {
96
+ throwIfAborted(signal);
97
+ const hint = missingBinaryMessage(label, error);
98
+ throw hint === undefined ? error : new Error(hint);
99
+ }
82
100
  throwIfAborted(signal);
83
101
  if (result.exitCode !== 0) {
84
102
  const tail = result.stderr.trim().split(/\r?\n/).slice(-6).join(' | ');
@@ -89,6 +107,8 @@ async function runChecked(runner, argv, timeoutMs, label, signal) {
89
107
  function buildTextRenderer(lines) {
90
108
  return (args, value) => [{ type: 'text', text: lines(args, value).join('\n') }];
91
109
  }
110
+ /** 自检失败时的修复步骤;与 docs/USAGE.md「故障排查」保持一致。 */
111
+ const HEALTH_HINT = '下一步:\n1. 安装 FFmpeg(含 ffprobe),确认终端里 ffmpeg -version 与 ffprobe -version 都可用。\n2. 若不在 PATH 中:在 profile 的 cordis.patch.yml 里给 dsh-ffmpeg 配置 ffmpegPath / ffprobePath,或设置环境变量 DSH_FFMPEG_PATH / DSH_FFPROBE_PATH(绝对路径)。\n3. 重启 DSH 后再次运行 ffmpeg_health;超时、覆盖拒绝或抽帧占位符问题见 docs/USAGE.md「故障排查」。';
92
112
  // ---------- 输出 JSON Schema ----------
93
113
  const baseSchema = { type: 'object', additionalProperties: true };
94
114
  const videoStreamSchema = {
@@ -637,8 +657,11 @@ export function buildFfmpegTools(config, runner) {
637
657
  const lines = ['dsh-ffmpeg 自检' + (rec.ok === true ? ':正常。' : ':发现问题。')];
638
658
  for (const item of checks) {
639
659
  const c = asRecord(item);
640
- lines.push('- ' + c.name + ':' + (c.ok === true ? '✅ ' + String(c.version ?? '') : '❌ ' + String(c.detail ?? '')));
660
+ const where = typeof c.path === 'string' && c.path !== '' && c.path !== c.name ? '(' + c.path + ')' : '';
661
+ lines.push('- ' + c.name + where + ':' + (c.ok === true ? '✅ ' + String(c.version ?? '') : '❌ ' + String(c.detail ?? '')));
641
662
  }
663
+ if (rec.ok !== true)
664
+ lines.push('', ...HEALTH_HINT.split('\n'));
642
665
  return lines;
643
666
  }),
644
667
  },
@@ -662,10 +685,10 @@ export function buildFfmpegTools(config, runner) {
662
685
  catch (error) {
663
686
  throwIfAborted(exec?.signal);
664
687
  ok = false;
665
- checks.push({ name: label, ok: false, path: bin, detail: error instanceof Error ? error.message : String(error) });
688
+ checks.push({ name: label, ok: false, path: bin, detail: '无法执行:' + (error instanceof Error ? error.message : String(error)) + '(修复步骤见下方「下一步」)' });
666
689
  }
667
690
  }
668
- return { ok, plugin: 'dsh-ffmpeg', checks };
691
+ return { ok, plugin: 'dsh-ffmpeg', checks, ...(ok ? {} : { hint: HEALTH_HINT }) };
669
692
  },
670
693
  timeoutMs: 30000,
671
694
  };
@@ -437,7 +437,7 @@ function __stardustUpdatesClient(ctx, React, require, shared) {
437
437
  }
438
438
 
439
439
  /* STARDUSTLC_UPDATE_CLIENT_BODY_START */
440
- window.__ModuleLoader__.load(__stardustUpdatesWrap({id:"dsh-ffmpeg",factory:require=>({apply(){}})},{"name":"dsh-ffmpeg","version":"0.1.0","hasWorkbench":false,"packageVersion":"0.7.4","label":"FFmpeg","labelEn":"FFmpeg","suiteComponent":true}));
440
+ window.__ModuleLoader__.load(__stardustUpdatesWrap({id:"dsh-ffmpeg",factory:require=>({apply(){}})},{"name":"dsh-ffmpeg","version":"0.1.0","hasWorkbench":false,"packageVersion":"0.7.5","label":"FFmpeg","labelEn":"FFmpeg","suiteComponent":true}));
441
441
 
442
442
  /* STARDUSTLC_UPDATE_CLIENT_BODY_END */
443
443
  })();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-ffmpeg",
3
- "version": "0.7.4",
4
- "description": "把已有音视频处理成需要的成品。 需要本机 FFmpeg / ffprobe 欢迎提交 issues 和 PR。",
3
+ "version": "0.7.5",
4
+ "description": "DSH 音视频处理:本机 FFmpeg 裁切、转码、字幕、音轨、GIF、抽帧与视频总览图。欢迎提交 issues 和 PR。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -26,8 +26,8 @@
26
26
  "scripts": {
27
27
  "build": "tsc -p tsconfig.json && node scripts/build-updates.mjs",
28
28
  "typecheck": "tsc -p tsconfig.json --noEmit",
29
- "test": "pnpm run build && node --test \"test/*.test.mjs\"",
30
- "prepublishOnly": "pnpm run build"
29
+ "test": "npm run build && node --test \"test/*.test.mjs\"",
30
+ "prepublishOnly": "npm run build"
31
31
  },
32
32
  "dsh": {
33
33
  "bundle": {