@gehdoc/svg-to-video 0.34.0 → 0.35.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.
package/README.md CHANGED
@@ -73,7 +73,7 @@ For automated or batch processing, use the CLI tool. It is built to run in a hea
73
73
 
74
74
  ### Quick Start
75
75
 
76
- Ensure [Node.js](https://nodejs.org/) and [FFmpeg](https://ffmpeg.org/) are installed.
76
+ Ensure [Node.js](https://nodejs.org/) is installed. Chrome/Chromium is managed automatically by Puppeteer (override via `PUPPETEER_EXECUTABLE_PATH`). System [FFmpeg](https://ffmpeg.org/) is used if available, or a bundled static fallback is automatically used (override via `--ffmpeg-path <path>` or the `FFMPEG_PATH` environment variable).
77
77
 
78
78
  ```bash
79
79
  # Node.js (auto-detected duration)
@@ -171,9 +171,9 @@ For instructions on contributing, build commands, security standards, and the te
171
171
 
172
172
  If you find this tool helpful, please consider supporting its development:
173
173
 
174
- [![Donate](https://img.shields.io/badge/Donate-PayPal-blue.svg)](https://paypal.me/GehDoc)
174
+ [![Sponsor](https://img.shields.io/badge/Sponsor-GitHub-ea4aaa?logo=githubsponsors)](https://github.com/sponsors/GehDoc)
175
175
 
176
- Your support helps cover maintenance and further development of the tool. Thank you!
176
+ Your support directly fuels my agentic engineering harness and helps keep this tool free, secure, and privacy-first. Thank you!
177
177
 
178
178
  ---
179
179
 
package/dist/src/index.js CHANGED
@@ -7,6 +7,7 @@ import path from 'path';
7
7
  import { seekAnimations } from '#shared/animation-engine.js';
8
8
  import { compositeFrame } from '#shared/canvasCompositing.js';
9
9
  import { validateOptions } from './utils/validateOptions.js';
10
+ import { resolveFfmpegPath } from './utils/ffmpegResolver.js';
10
11
  import { analyzeSvgAnimation, parseSvgDimensions, calculateAspectRatio, } from '#shared/analyzeSvgAnimation.js';
11
12
  import { formatRegistry } from './formats/registry.js';
12
13
  import { pkg } from './utils/packageInfo.js';
@@ -61,6 +62,7 @@ Resources:
61
62
  .option('--bg-color <hex>', 'background color for the video (e.g., #FFFFFF)')
62
63
  .option('--metadata <items...>', 'metadata tags (e.g., --metadata title="My Video" author="Me")')
63
64
  .option('--format <format>', `output format: ${formatRegistry.getSupportedFormatNames().join(', ')}`)
65
+ .option('--ffmpeg-path <path>', 'custom path to ffmpeg executable (overrides system PATH and FFMPEG_PATH)')
64
66
  .option('-q, --quiet', 'suppress interactive progress output', false)
65
67
  .option('--silent', 'alias for --quiet', false)
66
68
  .option('--json', 'output final conversion result as JSON (implies quiet mode)', false)
@@ -170,6 +172,7 @@ async function run(svgPath, fps, outDir, options) {
170
172
  process.once('SIGTERM', sigtermListener);
171
173
  try {
172
174
  fs.mkdirSync(outDir, { recursive: true });
175
+ const ffmpegPath = resolveFfmpegPath(options.ffmpegPath, logger);
173
176
  await renderAndEncodeFrames({
174
177
  svg,
175
178
  parsedDim,
@@ -178,6 +181,7 @@ async function run(svgPath, fps, outDir, options) {
178
181
  padWidth,
179
182
  outDir,
180
183
  outputFileName,
184
+ ffmpegPath,
181
185
  puppeteerArgs,
182
186
  resolutionPreset: options.resolution,
183
187
  scaleFactor: options.scale,
@@ -290,7 +294,7 @@ async function renderAndEncodeFrames(params) {
290
294
  };
291
295
  const args = params.generator.buildFfmpegArgs(formatOptions);
292
296
  params.logger.info('📦 Encoding output with FFmpeg...');
293
- const ffmpegProcess = child_process.spawn('ffmpeg', args, {
297
+ const ffmpegProcess = child_process.spawn(params.ffmpegPath, args, {
294
298
  stdio: ['pipe', 'ignore', 'pipe'],
295
299
  });
296
300
  params.onFfmpegCreated(ffmpegProcess);
@@ -0,0 +1,64 @@
1
+ import fs from 'fs';
2
+ import child_process from 'child_process';
3
+ import { createRequire } from 'module';
4
+ const require = createRequire(import.meta.url);
5
+ /**
6
+ * Checks if system FFmpeg is available on PATH.
7
+ */
8
+ export function findSystemFfmpeg() {
9
+ try {
10
+ const result = child_process.spawnSync('ffmpeg', ['-version'], {
11
+ stdio: 'ignore',
12
+ });
13
+ return result.status === 0;
14
+ }
15
+ catch {
16
+ return false;
17
+ }
18
+ }
19
+ /**
20
+ * Resolves static binary path from optionalDependency ffmpeg-static if installed and available.
21
+ */
22
+ export function getBundledFfmpeg() {
23
+ try {
24
+ const ffmpegStatic = require('ffmpeg-static');
25
+ if (typeof ffmpegStatic === 'string' && fs.existsSync(ffmpegStatic)) {
26
+ return ffmpegStatic;
27
+ }
28
+ }
29
+ catch {
30
+ // optionalDependency not installed or unavailable
31
+ }
32
+ return null;
33
+ }
34
+ /**
35
+ * Resolves FFmpeg executable path with priority:
36
+ * 1. Explicit path parameter or FFMPEG_PATH / FFMPEG_EXECUTABLE_PATH environment variable
37
+ * 2. System FFmpeg executable found on PATH
38
+ * 3. Bundled static binary via ffmpeg-static optionalDependency
39
+ */
40
+ export function resolveFfmpegPath(explicitPath, logger) {
41
+ // 1. Explicit path or ENV
42
+ const candidate = explicitPath ||
43
+ process.env.FFMPEG_PATH ||
44
+ process.env.FFMPEG_EXECUTABLE_PATH;
45
+ if (candidate) {
46
+ if (fs.existsSync(candidate)) {
47
+ return candidate;
48
+ }
49
+ throw new Error(`Configured FFmpeg path not found or not executable: ${candidate}`);
50
+ }
51
+ // 2. System PATH
52
+ if (findSystemFfmpeg()) {
53
+ return 'ffmpeg';
54
+ }
55
+ // 3. Bundled ffmpeg-static fallback
56
+ const bundled = getBundledFfmpeg();
57
+ if (bundled) {
58
+ logger?.info('🔍 System FFmpeg not found, using bundled static FFmpeg...');
59
+ return bundled;
60
+ }
61
+ // 4. Failure with actionable instructions
62
+ throw new Error('FFmpeg is required to convert SVG animations to video, but was not found on your system.\n' +
63
+ 'Please install FFmpeg (e.g. via brew, apt, or winget) or set the FFMPEG_PATH environment variable.');
64
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gehdoc/svg-to-video",
3
3
  "mcpName": "io.github.GehDoc/svg-to-video",
4
- "version": "0.34.0",
4
+ "version": "0.35.0",
5
5
  "type": "module",
6
6
  "description": "Professional animated SVG (CSS & SMIL) to Video (MP4/WebM/MKV/MOV) and Animated Image (aPNG/GIF) converter featuring frame-accurate rendering, CLI automation, Model Context Protocol (MCP) server integration, and a serverless Web Studio.",
7
7
  "imports": {
@@ -17,7 +17,8 @@
17
17
  },
18
18
  "homepage": "https://gehdoc.github.io/svg-to-video/",
19
19
  "funding": {
20
- "url": "https://github.com/GehDoc/svg-to-video/?sponsor=1"
20
+ "type": "github",
21
+ "url": "https://github.com/sponsors/GehDoc"
21
22
  },
22
23
  "engines": {
23
24
  "node": ">=22.22.2"
@@ -60,8 +61,8 @@
60
61
  "@umami/node": "^0.4.0",
61
62
  "commander": "^15.0.0",
62
63
  "jsdom": "^30.1.1",
63
- "supergateway": "^4.1.0",
64
64
  "puppeteer": "^25.8.0",
65
+ "supergateway": "^4.1.0",
65
66
  "tsx": "^4.23.0"
66
67
  },
67
68
  "devDependencies": {
@@ -106,6 +107,7 @@
106
107
  "check": "npm run lint && npm run format && npm run type-check && npm run test",
107
108
  "check:fast": "npm run lint && npm run format && npm run type-check",
108
109
  "fix": "npm run lint:fix && npm run format:fix",
110
+ "benchmark:ci": "tsx scripts/compare-ci.ts",
109
111
  "prepare": "husky"
110
112
  },
111
113
  "lint-staged": {
@@ -134,5 +136,8 @@
134
136
  "@modelcontextprotocol/sdk": "$@modelcontextprotocol/sdk",
135
137
  "@modelcontextprotocol/client": "2.4.0",
136
138
  "@modelcontextprotocol/server": "2.4.0"
139
+ },
140
+ "optionalDependencies": {
141
+ "ffmpeg-static": "^5.3.0"
137
142
  }
138
143
  }