mcp-extract-video-frames 0.1.0 → 0.1.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/README.md CHANGED
@@ -4,12 +4,15 @@ Turn local videos into a small, configurable set of PNG screenshots for slide
4
4
  references, illustrated notes, and visual review. Use the same extraction engine
5
5
  from JavaScript, the command line, or an MCP client.
6
6
 
7
- Requires Node.js 22.18+ and npm. FFmpeg is resolved from
8
- `@seydx/node-av-ffmpeg@latest` through npm exec at first media use in each process.
9
- The provider uses npm's download cache. Subsequent FFmpeg calls in that process
10
- reuse the resolved binary; a new process checks for the current provider version.
11
- System FFmpeg and FFprobe are not required. Keep npm optional dependencies enabled.
12
- FFmpeg is distributed under its provider's licenses.
7
+ Requires Node.js 22.18+. FFmpeg is supplied by the JavaScript dependency
8
+ `mcp-ffmpeg-runtime`, declared as `latest` and refreshed when preparing each new
9
+ release. The resolved dependency is saved with the release for reproducible retries.
10
+ At first media use in each process, that runtime checks its current FFmpeg build
11
+ and reuses or updates its binary cache. Subsequent extraction passes reuse the
12
+ resolved command. System FFmpeg and FFprobe are not required. Runtime settings
13
+ such as `FFMPEG_CACHE_DIR`, `FFMPEG_CHANNEL`, `FFMPEG_OFFLINE`, and
14
+ `FFMPEG_PREFER_LOCAL` are handled by mcp-ffmpeg-runtime. Offline or local preference
15
+ can opt out of downloading the current build. FFmpeg has its own licenses.
13
16
 
14
17
  ## CLI
15
18
 
package/package.json CHANGED
@@ -1,19 +1,45 @@
1
1
  {
2
2
  "name": "mcp-extract-video-frames",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Extract adaptive video screenshots through a JavaScript library, CLI, or MCP server.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "Łukasz Kucharski",
8
- "repository": { "type": "git", "url": "git+https://github.com/kucharskill/mcp-extract-video-frames.git" },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/kucharskill/mcp-extract-video-frames.git"
11
+ },
9
12
  "homepage": "https://github.com/kucharskill/mcp-extract-video-frames#readme",
10
- "bugs": { "url": "https://github.com/kucharskill/mcp-extract-video-frames/issues" },
11
- "keywords": ["mcp", "video", "ffmpeg", "screenshots", "frames"],
12
- "engines": { "node": ">=22.18.0" },
13
- "bin": { "mcp-extract-video-frames": "bin/cli.js" },
14
- "exports": { ".": "./src/index.js", "./options": "./src/options.js" },
15
- "files": ["bin/", "src/", "README.md", "LICENSE", ".env.example"],
16
- "publishConfig": { "access": "public" },
13
+ "bugs": {
14
+ "url": "https://github.com/kucharskill/mcp-extract-video-frames/issues"
15
+ },
16
+ "keywords": [
17
+ "mcp",
18
+ "video",
19
+ "ffmpeg",
20
+ "screenshots",
21
+ "frames"
22
+ ],
23
+ "engines": {
24
+ "node": ">=22.18.0"
25
+ },
26
+ "bin": {
27
+ "mcp-extract-video-frames": "bin/cli.js"
28
+ },
29
+ "exports": {
30
+ ".": "./src/index.js",
31
+ "./options": "./src/options.js"
32
+ },
33
+ "files": [
34
+ "bin/",
35
+ "src/",
36
+ "README.md",
37
+ "LICENSE",
38
+ ".env.example"
39
+ ],
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
17
43
  "scripts": {
18
44
  "check": "node scripts/check.mjs",
19
45
  "test": "node --test tests/*.test.mjs",
@@ -25,7 +51,10 @@
25
51
  "@modelcontextprotocol/server": "^2.4.0",
26
52
  "commander": "^15.1.0",
27
53
  "dotenv": "^18.0.10",
54
+ "mcp-ffmpeg-runtime": "latest",
28
55
  "zod": "^4.6.7"
29
56
  },
30
- "devDependencies": { "@modelcontextprotocol/client": "^2.4.0" }
57
+ "devDependencies": {
58
+ "@modelcontextprotocol/client": "^2.4.0"
59
+ }
31
60
  }
package/src/ffmpeg.js CHANGED
@@ -1,10 +1,14 @@
1
1
  import { execFile } from "node:child_process";
2
2
  import { promisify } from "node:util";
3
- import { getFfmpegCommand } from "./ffmpeg-command.js";
3
+ import { resolveBinary } from "mcp-ffmpeg-runtime";
4
4
  const execute = promisify(execFile);
5
+ let runtime;
5
6
  export async function runFfmpeg(args, { signal } = {}) {
6
7
  signal?.throwIfAborted();
7
- return execute(getFfmpegCommand(), ["-nostdin", "-hide_banner", "-nostats", ...args], {
8
+ runtime ??= resolveBinary("ffmpeg").catch(error => { runtime = undefined; throw error; });
9
+ const { command } = await runtime;
10
+ signal?.throwIfAborted();
11
+ return execute(command, ["-nostdin", "-hide_banner", "-nostats", ...args], {
8
12
  windowsHide: true, shell: false, maxBuffer: 16 * 1024 * 1024, signal,
9
13
  });
10
14
  }
package/src/frames.js CHANGED
@@ -61,7 +61,7 @@ export async function renderSelectedFrames(source, directory, timeline, options,
61
61
  const indices = selected.map((sample) => `eq(n,${sample.index})`).join("+");
62
62
  await writeFile(script, `[0:V:0]${settings.filter},select='${indices}',scale=-2:'min(ih,${options.frameMaxHeight})'[frames]`);
63
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")], { signal: options.signal });
64
+ await runFfmpeg(["-loglevel", "error", "-y", "-i", source, "-/filter_complex", script, "-map", "[frames]", "-fps_mode", "vfr", "-enc_time_base", "1:1000", join(directory, "sample-%012d.png")], { signal: options.signal });
65
65
  } finally { await rm(script, { force: true }); }
66
66
  const files = (await readdir(directory)).filter((name) => /^sample-\d+\.png$/.test(name));
67
67
  if (files.length !== selected.length) throw new Error("Selected frame count does not match extracted images.");
package/src/index.js CHANGED
@@ -72,7 +72,7 @@ export async function extractFrames(file, { outputDir, timeline, signal, envFile
72
72
  if(retained.originalSeconds > duration + 0.1)throw new Error("Timeline extends beyond the source video duration.");
73
73
  const settings = frameFilter(retained,options);
74
74
  await writeFile(script,`[0:V:0]${settings.filter},scale=96:96:force_original_aspect_ratio=decrease,format=gray,pad=96:96:(ow-iw)/2:(oh-ih)/2,showinfo=checksum=0[frames]`);
75
- const scanned = await runFfmpeg(["-loglevel","info","-y","-i",input,"-filter_complex_script",script,"-map","[frames]","-fps_mode","passthrough","-threads","1","-f","rawvideo",scanFile],{signal});
75
+ const scanned = await runFfmpeg(["-loglevel","info","-y","-i",input,"-/filter_complex",script,"-map","[frames]","-fps_mode","passthrough","-threads","1","-f","rawvideo",scanFile],{signal});
76
76
  await writeFile(log,scanned.stderr);
77
77
  const result = await renderSelectedFrames(input,directory,retained,{...options,signal},scanFile,scanned.stderr,settings);
78
78
  const manifest = result.count ? JSON.parse(await readFile(result.manifest,"utf8")) : {source:input,timestamps:"original",settings:options,frames:[]};
@@ -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(), "extract-video-frames", "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,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 }));