mcp-speechmatics-transcribe 0.1.20 → 0.1.22

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/README.md CHANGED
@@ -3,7 +3,8 @@
3
3
  Turn local audio and video recordings into searchable transcripts, speaker-labeled
4
4
  subtitles, and readable Markdown with Speechmatics. Use the CLI for individual
5
5
  files or connect the MCP server to a compatible client.
6
- Requires Node.js 22.18+ and npm. FFmpeg is resolved through npm exec from the provider's latest published package and reused from the npm/npx cache.
6
+ Requires Node.js 22.18+. FFmpeg and adaptive screenshots are provided by the
7
+ public npm dependencies mcp-ffmpeg-runtime and mcp-extract-video-frames.
7
8
 
8
9
  ## Quick start
9
10
 
@@ -99,11 +100,16 @@ through unchanged, based on their extension. Other inputs are prepared as MP3;
99
100
  audio extraction first tries stream copying where possible. Edited audio is encoded
100
101
  to MP3. Prepared files stay in the output folder. Missing audio and conversion
101
102
  failures are reported before upload. System FFmpeg and FFprobe are not required.
102
- The first media operation in each CLI process checks @seydx/node-av-ffmpeg@latest
103
- with npm exec --prefer-online. npm/npx caches the provider and platform binary, so
104
- unchanged versions are reused. Subsequent FFmpeg calls in the same process reuse
105
- the resolved binary. Keep npm optional dependencies enabled for the platform package.
106
- FFmpeg is provided by @seydx/node-av-ffmpeg under its own licenses.
103
+ The shared mcp-ffmpeg-runtime library manages FFmpeg downloads and its binary
104
+ cache. The runtime dependency requires ^0.1.4, and the screenshot library uses the latest
105
+ npm tag. Both are refreshed within their declared ranges when preparing
106
+ a new release; the resolved versions are retained for reproducible release retries.
107
+ The runtime checks and updates its FFmpeg build at media use and reuses the cached
108
+ binary. FFMPEG_CACHE_DIR, FFMPEG_CHANNEL, FFMPEG_OFFLINE, and FFMPEG_PREFERRED_RUNTIME
109
+ configure that runtime. The default uses its managed binary; offline and local
110
+ preferences can opt out of downloading the current build. The default omits a
111
+ runtime preference and uses latest. FFMPEG_PREFERRED_RUNTIME accepts latest, cached,
112
+ local, an npm semver range, or a build ID. FFmpeg has its own licenses.
107
113
 
108
114
  ## Configuration
109
115
 
@@ -2,7 +2,7 @@ import { writeFile, rm } from "node:fs/promises";
2
2
  import { extname, join } from "node:path";
3
3
  import { runFfmpeg, convertAudio } from "./media-process.js";
4
4
  import { buildTimeline } from "./timeline.js";
5
- import { frameFilter, renderSelectedFrames, createFrameDirectory } from "./frames.js";
5
+ import { extractFrames } from "mcp-extract-video-frames";
6
6
 
7
7
  export function parseAnalysis(stdout, stderr, options) {
8
8
  const values = [...stdout.matchAll(/^out_time_us=(\d+)/gm)];
@@ -57,32 +57,25 @@ export async function prepareMedia(input, directory, id, options) {
57
57
  filters.push(`${timeline.segments.map((_, i) => `[a${i}]`).join("")}concat=n=${timeline.segments.length}:v=0:a=1[audio]`);
58
58
  }
59
59
  else if (renderAudio && !copyAudio) filters.push("[0:a:0]aresample=16000:async=1:first_pts=0[audio]");
60
- let frameSettings, framesDirectory;
61
- if (extract) {
62
- frameSettings = frameFilter(timeline, options);
63
- filters.push(`[0:v:0]${frameSettings.filter},scale=96:96:force_original_aspect_ratio=decrease,format=gray,pad=96:96:(ow-iw)/2:(oh-ih)/2,showinfo=checksum=0[frames]`);
64
- framesDirectory = join(directory, `frames-${id}`);
65
- await createFrameDirectory(framesDirectory);
66
- }
67
- if (renderAudio || extract) {
60
+ if (renderAudio) {
68
61
  const script = join(directory, `filters-${id}.txt`);
69
62
  await writeFile(script, filters.join(";\n"));
70
- const args = ["-loglevel", extract ? "info" : "error", "-y", "-i", input];
71
- if (filters.length) args.push("-filter_complex_script", script);
72
- if (renderAudio) {
73
- args.push("-map", copyAudio ? "0:a:0" : "[audio]", "-c:a", copyAudio ? "copy" : "libmp3lame");
74
- if (!copyAudio) args.push("-q:a", "2");
75
- args.push(output); file = output;
76
- conversion = cut ? "silence_removed" : normalizeAudio ? "timeline_normalized" : copyAudio ? "copy" : "encoded";
77
- }
78
- const scanFile = extract ? join(framesDirectory, "scan.raw") : null;
79
- if (extract) args.push("-map", "[frames]", "-fps_mode", "passthrough", "-threads", "1", "-f", "rawvideo", scanFile);
80
- let rendered;
81
- try { rendered = await runFfmpeg(args); }
82
- catch (error) { await rm(output, { force: true }); if (scanFile) await rm(scanFile, { force: true }); throw new Error(`Media preparation failed: ${error.stderr?.trim() || error.message}`); }
63
+ const args = ["-loglevel", "error", "-y", "-i", input];
64
+ if (filters.length) args.push("-/filter_complex", script);
65
+ args.push("-map", copyAudio ? "0:a:0" : "[audio]", "-c:a", copyAudio ? "copy" : "libmp3lame");
66
+ if (!copyAudio) args.push("-q:a", "2");
67
+ args.push(output); file = output;
68
+ conversion = cut ? "silence_removed" : normalizeAudio ? "timeline_normalized" : copyAudio ? "copy" : "encoded";
69
+ try { await runFfmpeg(args); }
70
+ catch (error) { await rm(output, { force: true }); throw new Error(`Media preparation failed: ${error.stderr?.trim() || error.message}`); }
83
71
  finally { await rm(script, { force: true }); }
84
- if (extract) frames = await renderSelectedFrames(input, framesDirectory, timeline, options, scanFile, rendered.stderr, frameSettings);
85
72
  }
86
- if (!renderAudio && !compressed) { conversion = await convertAudio(input, output); file = output; }
73
+ if (extract) frames = await extractFrames(input, {
74
+ outputDir: join(directory, `frames-${id}`), timeline,
75
+ frameMode: options.frameMode, frameIntervalSeconds: options.frameIntervalSeconds,
76
+ frameMaxCount: options.frameMaxCount, frameMaxHeight: options.frameMaxHeight,
77
+ frameChangeThreshold: options.frameChangeThreshold,
78
+ });
79
+
87
80
  return { file, conversion, timeline, timelineFile, frames };
88
81
  }
@@ -1,11 +1,16 @@
1
1
  import { execFile } from "node:child_process";
2
2
  import { promisify } from "node:util";
3
3
  import { rm } from "node:fs/promises";
4
- import { getFfmpegCommand } from "./ffmpeg.js";
4
+ import { resolveBinary } from "mcp-ffmpeg-runtime";
5
5
 
6
6
  const execute = promisify(execFile);
7
+ let runtime;
7
8
  export async function runFfmpeg(args) {
8
- try { return await execute(getFfmpegCommand(), ["-nostdin", "-hide_banner", "-nostats", ...args], { windowsHide: true, maxBuffer: 16 * 1024 * 1024 }); }
9
+ try {
10
+ runtime ??= resolveBinary("ffmpeg").catch(error => { runtime = undefined; throw new Error(`FFmpeg provider is unavailable: ${error.message}`); });
11
+ const { command } = await runtime;
12
+ return await execute(command, ["-nostdin", "-hide_banner", "-nostats", ...args], { windowsHide: true, shell: false, maxBuffer: 16 * 1024 * 1024 });
13
+ }
9
14
  catch (error) {
10
15
  if (error.code === "ENOENT") throw new Error("FFmpeg provider binary could not be started. Check npm connectivity and optional dependencies.");
11
16
  throw error;
package/modules/tools.js CHANGED
@@ -11,7 +11,7 @@ export function createTools(configuredDefaults) {
11
11
  return {
12
12
  transcribe: {
13
13
  definition: {
14
- description: `${description} Silence removal is enabled by default for every format. Optional adaptive video screenshots can help create illustrated notes. JSON, Markdown, subtitles, and PNG names use original recording timestamps. FFmpeg is resolved from the provider latest package through the npm/npx cache. Return paths to JSON, segments, WebVTT subtitles, Markdown, timeline, and optional frames.`,
14
+ description: `${description} Silence removal is enabled by default for every format. Optional adaptive video screenshots can help create illustrated notes. JSON, Markdown, subtitles, and PNG names use original recording timestamps. FFmpeg and screenshots use shared npm libraries with a managed binary cache. Return paths to JSON, segments, WebVTT subtitles, Markdown, timeline, and optional frames.`,
15
15
  inputSchema: z.strictObject({
16
16
  file: z.string().min(1).describe("Absolute path to a local audio or video file."),
17
17
  model: optionFields.model.optional().describe(`Configured default: ${configuredDefaults.model}. enhanced: highest accuracy for a selected language. standard: faster processing and archival transcription. melia-1: MULTILANGUAGE, language switching within recordings. oak-1: MULTILANGUAGE, healthcare recordings. Use language=multi for melia-1 and oak-1; neither supports audio events.`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-speechmatics-transcribe",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "description": "Transcribe audio and video files with Speechmatics through a CLI and MCP server.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -49,6 +49,8 @@
49
49
  "@modelcontextprotocol/server": "^2.4.0",
50
50
  "commander": "^15.1.0",
51
51
  "dotenv": "^18.0.10",
52
+ "mcp-extract-video-frames": "latest",
53
+ "mcp-ffmpeg-runtime": "^0.1.4",
52
54
  "proper-lockfile": "^4.1.2",
53
55
  "zod": "^4.6.7"
54
56
  },
@@ -1,18 +0,0 @@
1
- const { createRequire } = require("node:module");
2
- const { delimiter, dirname, join } = require("node:path");
3
- const { platform, arch } = process;
4
- const musl = platform === "linux" && !process.report.getReport().header.glibcVersionRuntime;
5
- const variant = `${platform}-${arch}${musl ? "-musl" : ""}`;
6
- let provider;
7
- for (const directory of process.env.PATH.split(delimiter)) {
8
- if (!/[\\/]node_modules[\\/]\.bin$/.test(directory)) continue;
9
- try {
10
- const candidate = createRequire(join(dirname(directory), "@seydx/node-av-ffmpeg/package.json"));
11
- candidate.resolve("./package.json");
12
- provider = candidate;
13
- break;
14
- } catch { /* Continue through npm's injected dependency directories. */ }
15
- }
16
- if (!provider) throw new Error("npm exec did not provide the FFmpeg package.");
17
- const command = provider.resolve(`@seydx/node-av-ffmpeg-${variant}/ffmpeg${platform === "win32" ? ".exe" : ""}`);
18
- process.stdout.write(JSON.stringify({ command }));
package/modules/ffmpeg.js DELETED
@@ -1,31 +0,0 @@
1
- import { accessSync, constants, existsSync, mkdirSync } from "node:fs";
2
- import { execFileSync } from "node:child_process";
3
- import { dirname, delimiter, join, resolve } from "node:path";
4
- import { tmpdir } from "node:os";
5
- import { fileURLToPath } from "node:url";
6
-
7
- let command;
8
- export function getFfmpegCommand() {
9
- if (command) return command;
10
- const candidates = [process.env.npm_execpath,
11
- join(dirname(process.execPath), "node_modules/npm/bin/npm-cli.js"),
12
- resolve(dirname(process.execPath), "../lib/node_modules/npm/bin/npm-cli.js"),
13
- ...(process.env.PATH ?? "").split(delimiter).map(directory => join(directory, "node_modules/npm/bin/npm-cli.js")),
14
- ].filter(Boolean);
15
- const npm = candidates.find(file => /npm-cli\.js$/i.test(file) && existsSync(file));
16
- if (!npm) throw new Error("FFmpeg provider requires npm. Install Node.js with npm available.");
17
- const cwd = join(tmpdir(), "transcription", "ffmpeg");
18
- mkdirSync(cwd, { recursive: true });
19
- const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => !/^npm_config_(package|call)$/i.test(key)));
20
- try {
21
- const output = execFileSync(process.execPath, [npm, "exec", "--yes", "--prefer-online", "--package=@seydx/node-av-ffmpeg@latest", "--", process.execPath, fileURLToPath(new URL("./ffmpeg-provider.cjs", import.meta.url))], {
22
- cwd, env, stdio: ["ignore", "pipe", "pipe"], shell: false, windowsHide: true, encoding: "utf8", timeout: 180000, maxBuffer: 1024 * 1024,
23
- });
24
- const result = JSON.parse(output.trim());
25
- accessSync(result.command, constants.X_OK);
26
- command = result.command;
27
- return command;
28
- } catch (error) {
29
- throw new Error(`FFmpeg provider could not resolve @seydx/node-av-ffmpeg@latest through npm exec. Check npm connectivity and optional dependencies. ${error.message}`);
30
- }
31
- }
@@ -1,158 +0,0 @@
1
- const scanSize = 96;
2
- const sampleSize = scanSize ** 2;
3
-
4
- export function describeSample(current, previous) {
5
- const signature = new Uint8Array(sampleSize / 9);
6
- let change = 0;
7
- let left = scanSize;
8
- let top = scanSize;
9
- let right = -1;
10
- let bottom = -1;
11
- for (let y = 0; y < scanSize; y += 3) {
12
- for (let x = 0; x < scanSize; x += 3) {
13
- let sum = 0;
14
- for (let dy = 0; dy < 3; dy++) {
15
- for (let dx = 0; dx < 3; dx++) {
16
- const index = (y + dy) * scanSize + x + dx;
17
- const difference = Math.abs(current[index] - previous[index]);
18
- sum += current[index];
19
- change += difference;
20
- if (difference >= 24) {
21
- left = Math.min(left, x + dx);
22
- right = Math.max(right, x + dx);
23
- top = Math.min(top, y + dy);
24
- bottom = Math.max(bottom, y + dy);
25
- }
26
- }
27
- }
28
- signature[(y / 3) * (scanSize / 3) + x / 3] = Math.round(sum / 9);
29
- }
30
- }
31
- const width = right - left + 1;
32
- const height = bottom - top + 1;
33
- const bounds = width >= 3 && height >= 3 ? { left, top, width, height } : null;
34
- return { signature, change: change / sampleSize, bounds };
35
- }
36
-
37
- function quantile(values, fraction) {
38
- return values.toSorted((a, b) => a - b)[Math.floor((values.length - 1) * fraction)];
39
- }
40
-
41
- function frameDifference(a, b) {
42
- let difference = 0;
43
- let local = 0;
44
- const stride = scanSize / 3;
45
- for (let y = 0; y < stride; y += 4) {
46
- for (let x = 0; x < stride; x += 4) {
47
- let block = 0;
48
- for (let dy = 0; dy < 4; dy++) {
49
- for (let dx = 0; dx < 4; dx++) {
50
- const i = (y + dy) * stride + x + dx;
51
- block += Math.abs(a.signature[i] - b.signature[i]);
52
- }
53
- }
54
- difference += block;
55
- local = Math.max(local, block / 16);
56
- }
57
- }
58
- return { average: difference / a.signature.length, local };
59
- }
60
-
61
- function similar(a, b, detail = false, threshold = 4.5) {
62
- const { average, local } = frameDifference(a, b);
63
- return average < threshold && (!detail || local < threshold * 2);
64
- }
65
-
66
- export function selectFrames(samples, options) {
67
- if (!samples.length) return [];
68
- if (options.frameMode === "interval") {
69
- const count = Math.min(samples.length, options.frameMaxCount);
70
- return Array.from({length: count}, (_, i) => samples[count === 1 ? 0 : Math.round(i * (samples.length - 1) / (count - 1))]);
71
- }
72
- const duration = samples.at(-1).time;
73
- const budget = Math.min(options.frameMaxCount, 12 + 4 * Math.ceil(Math.log2(Math.max(1, duration / 30))));
74
- const activity = samples.map((sample, i) => {
75
- const neighborhood = samples.slice(Math.max(0, i - 1), i + 2).map(other => other.change);
76
- return Math.max(quantile(neighborhood, 0.5), sample.change * 0.55);
77
- });
78
- const baseline = quantile(activity, 0.25);
79
- const floor = Math.max(0.5, baseline * 1.25);
80
- const active = activity.filter(change => change > floor);
81
- const selected = [samples[0]];
82
- if (!active.length) return selected;
83
- const ceiling = quantile(active, 0.90);
84
- const strong = activity.map(change => Math.max(0, Math.min(ceiling, change) - floor));
85
- const quiet = activity.map(change => Math.sqrt(Math.max(0, Math.min(ceiling, change) - baseline * 0.7)));
86
- const strongTotal = strong.reduce((sum, change) => sum + change, 0);
87
- const quietTotal = quiet.reduce((sum, change) => sum + change, 0);
88
- const minGap = Math.min(0.85, duration / 24);
89
-
90
- const cumulative = [];
91
- let total = 0;
92
- for (let i = 0; i < samples.length; i++) {
93
- total += 0.65 * strong[i] / Math.max(strongTotal, 1e-9) + 0.35 * quiet[i] / Math.max(quietTotal, 1e-9);
94
- cumulative.push(total);
95
- }
96
- function eligible(sample, detail = false) {
97
- return selected.every(other => {
98
- const distance = Math.abs(other.time - sample.time);
99
- return distance >= minGap && (distance >= 4 || !similar(sample, other, detail, options.frameChangeThreshold));
100
- });
101
- }
102
- function add(sample, detail = false) {
103
- if (selected.length < budget && eligible(sample, detail)) selected.push(sample);
104
- }
105
-
106
- // Small follow-through changes are easily missed by a score averaged over the whole frame.
107
- const cuts = samples.filter(({ index, change }) =>
108
- change > Math.max(12, ceiling * 1.5)
109
- && change > 1.6 * Math.max(samples[index - 1]?.change ?? 0, samples[index + 1]?.change ?? 0),
110
- );
111
- const transitions = [];
112
- for (const [cutIndex, cut] of cuts.entries()) {
113
- const nextCut = cuts[cutIndex + 1]?.time ?? Infinity;
114
- for (let i = cut.index + 1; i < samples.length; i++) {
115
- const after = samples[i];
116
- if (after.time >= nextCut || after.time > cut.time + 1.8) break;
117
- if (after.time < cut.time + 1.1) continue;
118
- const { average, local } = frameDifference(cut, after);
119
- if (average < 4.5 && local >= 9) {
120
- transitions.push({ cut, after, score: local / (1 + average) });
121
- }
122
- }
123
- }
124
- transitions.sort((a, b) => b.score - a.score);
125
- const followed = [];
126
- for (const { cut, after } of transitions) {
127
- if (followed.length >= Math.ceil(budget / 8)) break;
128
- if (followed.some(other => Math.abs(other.time - cut.time) < 2)) continue;
129
- add(cut, true);
130
- add(after, true);
131
- followed.push(cut);
132
- }
133
-
134
- let index = 0;
135
- for (let i = 0; i < budget - 1; i++) {
136
- const target = (i + 0.5) / (budget - 1);
137
- while (index < samples.length - 1 && cumulative[index] < target) index++;
138
- add(samples[index]);
139
- }
140
- while (selected.length < budget) {
141
- let best;
142
- let bestScore = 0;
143
- for (const sample of samples) {
144
- if (!eligible(sample)) continue;
145
- const distance = Math.min(...selected.map(other => Math.abs(sample.time - other.time)));
146
- const motion = Math.min(ceiling, activity[sample.index]);
147
- const score = distance * Math.sqrt(Math.max(0, motion - baseline * 0.7));
148
- if (score > bestScore) {
149
- best = sample;
150
- bestScore = score;
151
- }
152
- }
153
- if (!best) break;
154
- add(best);
155
- }
156
- return selected.sort((a, b) => a.time - b.time);
157
- }
158
-
package/modules/frames.js DELETED
@@ -1,70 +0,0 @@
1
- import { mkdir, readdir, rename, writeFile } from "node:fs/promises";
2
- import { join } from "node:path";
3
- import { originalTime } from "./timeline.js";
4
- import { formatTime } from "./time-format.js";
5
- import { createReadStream } from "node:fs";
6
- import { rm } from "node:fs/promises";
7
- import { describeSample, selectFrames } from "./frame-selection.js";
8
- import { runFfmpeg } from "./media-process.js";
9
-
10
- export function frameFilter(timeline, options) {
11
- const segments = timeline.segments;
12
- const retained = segments.map((s) => `gte(t,${s.originalStart})*lt(t,${s.originalEnd})`).join("+");
13
- let removed = 0;
14
- const offsets = segments.map((segment) => {
15
- const total = segment.originalStart - segment.compactStart;
16
- const gap = total - removed; removed = total;
17
- return gap > 0 ? `gte(T,${segment.originalStart})*${gap}` : null;
18
- }).filter(Boolean);
19
- const mapping = offsets.length ? `T-(${offsets.join("+")})` : "T";
20
- const interval = Math.max(options.frameIntervalSeconds || (options.frameMode === "changes" ? 0.2 : Math.min(60, Math.max(0.2, timeline.compactSeconds / 20))), timeline.compactSeconds / 19999);
21
- const filters = [`select='${retained}'`, `setpts='(${mapping})/TB'`, `select='isnan(prev_selected_t)+gte(t-prev_selected_t,${interval})'`];
22
- return { filter: filters.join(","), intervalSeconds: interval };
23
- }
24
-
25
- export async function finishFrames(directory, source, timeline, settings, selected) {
26
- const frames = [];
27
- for (const name of (await readdir(directory)).filter((name) => /^sample-\d+\.png$/.test(name)).sort()) {
28
- const compactSeconds = selected?.[frames.length]?.time ?? Number(name.match(/\d+/)[0]) / 1000;
29
- const sourceSeconds = originalTime(compactSeconds, timeline);
30
- const stem = `frame-${formatTime(sourceSeconds, { filename: true, milliseconds: true })}`;
31
- const file = `${stem}-${String(frames.length + 1).padStart(4, "0")}.png`;
32
- await rename(join(directory, name), join(directory, file));
33
- frames.push({ file, sourceSeconds, compactSeconds });
34
- }
35
- const manifest = join(directory, "manifest.json");
36
- await writeFile(manifest, JSON.stringify({ source, timestamps: "original", settings, frames }, null, 2) + "\n", { flag: "wx" });
37
- return { directory, manifest, count: frames.length, status: "complete" };
38
- }
39
- export const createFrameDirectory = (directory) => mkdir(directory, { recursive: true });
40
-
41
- export async function renderSelectedFrames(source, directory, timeline, options, scanFile, scanLog, settings) {
42
- const times = [...scanLog.matchAll(/\bn:\s*\d+\s+pts:\s*-?\d+\s+pts_time:\s*([\d.e+-]+)/g)].map((match) => Number(match[1]));
43
- const samples = [];
44
- let frame = Buffer.alloc(96 * 96), previous = Buffer.alloc(96 * 96), offset = 0;
45
- try {
46
- for await (const chunk of createReadStream(scanFile)) {
47
- let cursor = 0;
48
- while (cursor < chunk.length) {
49
- const copied = chunk.copy(frame, offset, cursor, cursor + frame.length - offset);
50
- cursor += copied; offset += copied;
51
- if (offset === frame.length) {
52
- samples.push({ ...describeSample(frame, samples.length ? previous : frame), index: samples.length, time: times[samples.length] });
53
- [previous, frame] = [frame, previous]; offset = 0;
54
- }
55
- }
56
- }
57
- if (offset || samples.length !== times.length || !samples.every((sample) => Number.isFinite(sample.time))) throw new Error("Incomplete frame scan timestamps.");
58
- const selected = selectFrames(samples, options);
59
- if (!selected.length) return { directory, count: 0, status: "no_frames" };
60
- const script = join(directory, "render-filter.txt");
61
- const indices = selected.map((sample) => `eq(n,${sample.index})`).join("+");
62
- await writeFile(script, `[0:v:0]${settings.filter},select='${indices}',scale=-2:'min(ih,${options.frameMaxHeight})'[frames]`);
63
- try {
64
- await runFfmpeg(["-loglevel", "error", "-y", "-i", source, "-filter_complex_script", script, "-map", "[frames]", "-fps_mode", "vfr", "-enc_time_base", "1:1000", join(directory, "sample-%012d.png")]);
65
- } finally { await rm(script, { force: true }); }
66
- const files = (await readdir(directory)).filter((name) => /^sample-\d+\.png$/.test(name));
67
- if (files.length !== selected.length) throw new Error("Selected frame count does not match extracted images.");
68
- return await finishFrames(directory, source, timeline, { mode: options.frameMode, intervalSeconds: settings.intervalSeconds, maxCount: options.frameMaxCount, maxHeight: options.frameMaxHeight, changeThreshold: options.frameChangeThreshold, scannedFrames: samples.length }, selected);
69
- } finally { await rm(scanFile, { force: true }); }
70
- }