dsh-ffmpeg 0.7.0 → 0.7.1

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
@@ -4,6 +4,11 @@
4
4
 
5
5
  [历史英文记录](docs/CHANGELOG.en.md)
6
6
 
7
+ ## 0.7.1 (2026-10-29)
8
+
9
+ - 修复极短、分数帧率视频的采样时间取整越过最后一帧:向下取微秒精度,源文件保持不变。
10
+ - Avoid rounding past the final frame when sampling short fractional-frame-rate clips.
11
+
7
12
  ## 0.7.0 (2026-10-29)
8
13
 
9
14
  - 新增 ffmpeg_storyboard:均匀采样并拼成单张 PNG 总览图,附每格采样目标时间;可指定片段范围,保留原视频与已有成品。失败或取消会清理临时采样,不发布半成品。
package/docs/USAGE.en.md CHANGED
@@ -75,7 +75,7 @@ ffmpeg_gif { input: E:\videos\raw.mp4, duration: 3, width: 480 }
75
75
 
76
76
  ```bash
77
77
  pnpm install
78
- pnpm test # build + 120 tests
78
+ pnpm test # build + 121 tests
79
79
  ```
80
80
 
81
81
  ## License
package/docs/USAGE.md CHANGED
@@ -79,7 +79,7 @@ ffmpeg_adjust { input: E:\videos\raw.mp4, volume: +2dB }
79
79
 
80
80
  ```bash
81
81
  pnpm install
82
- pnpm test # 构建 + 120 个测试
82
+ pnpm test # 构建 + 121 个测试
83
83
  ```
84
84
 
85
85
  ## License
package/lib/storyboard.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { constants, copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, rmSync } from 'node:fs';
2
2
  import { tmpdir } from 'node:os';
3
3
  import { dirname, extname, join } from 'node:path';
4
- import { fmtSeconds, probeArgs } from './args.js';
4
+ import { probeArgs } from './args.js';
5
5
  import { parseTimeArg } from './config.js';
6
6
  import { parseProbeJson } from './ffprobe.js';
7
7
  import { assertInputFile, assertOutputNotSource, resolveOutputPath } from './paths.js';
@@ -79,13 +79,15 @@ export function createStoryboardTool(config, runner) {
79
79
  const lastFrame = info.video.fps && info.video.fps > 0 ? Math.max(0, duration - 1 / info.video.fps) : duration;
80
80
  if (start > lastFrame)
81
81
  throw new Error('所选范围太靠近结尾,无法取得视频帧;请提前 start。');
82
- const frames = Array.from({ length: count }, (_, i) => ({ index: i + 1, row: Math.floor(i / columns) + 1, column: i % columns + 1, seconds: Number(fmtSeconds(Math.min(lastFrame, start + (end - start) * i / count))) }));
82
+ // Round down to FFmpeg's microsecond clock. Millisecond rounding can seek
83
+ // beyond the final frame of a short fractional-frame-rate video.
84
+ const frames = Array.from({ length: count }, (_, i) => ({ index: i + 1, row: Math.floor(i / columns) + 1, column: i % columns + 1, seconds: Math.floor(Math.min(lastFrame, start + (end - start) * i / count) * 1e6) / 1e6 }));
83
85
  const scratch = mkdtempSync(join(tmpdir(), 'dsh-ffmpeg-storyboard-'));
84
86
  try {
85
87
  for (const frame of frames) {
86
88
  const image = join(scratch, 'frame-' + String(frame.index).padStart(3, '0') + '.png');
87
89
  const filter = 'scale=' + cellWidth + ':' + cellHeight + ':force_original_aspect_ratio=decrease,pad=' + cellWidth + ':' + cellHeight + ':(ow-iw)/2:(oh-ih)/2:color=black,setsar=1';
88
- await invoke([config.ffmpegPath, '-nostdin', '-v', 'error', '-n', '-ss', fmtSeconds(frame.seconds), '-i', input, '-map', '0:v:0', '-frames:v', '1', '-an', '-vf', filter, '-update', '1', image], '采样 #' + frame.index);
90
+ await invoke([config.ffmpegPath, '-nostdin', '-v', 'error', '-n', '-ss', frame.seconds.toFixed(6), '-i', input, '-map', '0:v:0', '-frames:v', '1', '-an', '-vf', filter, '-update', '1', image], '采样 #' + frame.index);
89
91
  if (!existsSync(image) || !lstatSync(image).isFile() || lstatSync(image).size === 0)
90
92
  throw new Error('无法取得第 ' + frame.index + ' 格(' + frame.seconds + ' 秒)的画面,请缩短采样范围后重试。');
91
93
  }
@@ -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.0","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.1","label":"FFmpeg","labelEn":"FFmpeg","suiteComponent":true}));
441
441
 
442
442
  /* STARDUSTLC_UPDATE_CLIENT_BODY_END */
443
443
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ffmpeg",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "DSH 音视频处理:本机 FFmpeg 裁切、转码、字幕、音轨、GIF、抽帧与视频总览图。欢迎提交 issues 和 PR。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",