@gehdoc/svg-to-video 0.23.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/LICENSE +21 -0
- package/README.md +158 -0
- package/dist/shared/analyzeSvgAnimation.js +218 -0
- package/dist/shared/animation-engine.js +36 -0
- package/dist/shared/apngMetadataInjector.js +45 -0
- package/dist/shared/crc32.js +28 -0
- package/dist/shared/gifMetadataInjector.js +32 -0
- package/dist/shared/metadata.js +6 -0
- package/dist/shared/types.js +16 -0
- package/dist/src/formats/generators/ApngFormatGenerator.js +70 -0
- package/dist/src/formats/generators/GifFormatGenerator.js +76 -0
- package/dist/src/formats/generators/MkvFormatGenerator.js +49 -0
- package/dist/src/formats/generators/MovFormatGenerator.js +49 -0
- package/dist/src/formats/generators/Mp4FormatGenerator.js +43 -0
- package/dist/src/formats/generators/WebmFormatGenerator.js +45 -0
- package/dist/src/formats/registry.js +71 -0
- package/dist/src/formats/types.js +1 -0
- package/dist/src/index.js +291 -0
- package/dist/src/mcp.js +314 -0
- package/dist/src/utils/logger.js +85 -0
- package/dist/src/utils/packageInfo.js +16 -0
- package/dist/src/utils/validateOptions.js +16 -0
- package/package.json +124 -0
- package/skills/svg-to-video/SKILL.md +39 -0
package/dist/src/mcp.js
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import os from 'os';
|
|
8
|
+
import { execFileSync } from 'child_process';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
import { JSDOM } from 'jsdom';
|
|
11
|
+
import { analyzeSvgAnimation } from '../shared/analyzeSvgAnimation.js';
|
|
12
|
+
import { isLoggerJsonOutput } from './utils/logger.js';
|
|
13
|
+
import { getPackageJson } from './utils/packageInfo.js';
|
|
14
|
+
const pkg = getPackageJson(import.meta.url);
|
|
15
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
+
const __dirname = path.dirname(__filename);
|
|
17
|
+
const cliJsPath = path.join(__dirname, 'index.js');
|
|
18
|
+
const cliTsPath = path.join(__dirname, 'index.ts');
|
|
19
|
+
const cliIndexPath = fs.existsSync(cliJsPath) ? cliJsPath : cliTsPath;
|
|
20
|
+
const server = new Server({
|
|
21
|
+
name: 'svg-to-video',
|
|
22
|
+
version: pkg.version,
|
|
23
|
+
}, {
|
|
24
|
+
capabilities: {
|
|
25
|
+
tools: {},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
29
|
+
return {
|
|
30
|
+
tools: [
|
|
31
|
+
{
|
|
32
|
+
name: 'render_svg_to_video',
|
|
33
|
+
description: 'Render an animated SVG (from file path or raw SVG code) into a high-quality video (MP4, WebM, MKV, MOV) or animated image (aPNG, GIF) with optional background transparency.',
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: {
|
|
37
|
+
svgFilePath: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
description: 'Absolute or relative path to the input .svg file.',
|
|
40
|
+
},
|
|
41
|
+
svgContent: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
description: 'Raw SVG string content to render (if svgFilePath is not provided).',
|
|
44
|
+
},
|
|
45
|
+
outDir: {
|
|
46
|
+
type: 'string',
|
|
47
|
+
description: 'Output directory for the generated media file. Defaults to current working directory.',
|
|
48
|
+
},
|
|
49
|
+
fps: {
|
|
50
|
+
type: 'number',
|
|
51
|
+
description: 'Frames per second (e.g. 24, 30, 60). Default: 60.',
|
|
52
|
+
default: 60,
|
|
53
|
+
},
|
|
54
|
+
duration: {
|
|
55
|
+
type: 'number',
|
|
56
|
+
description: 'Desired animation duration in seconds. If omitted, duration is auto-detected.',
|
|
57
|
+
},
|
|
58
|
+
format: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
enum: ['mp4', 'webm', 'gif', 'apng', 'mkv', 'mov'],
|
|
61
|
+
description: 'Output media format. Defaults to webm if transparent is true, otherwise mp4.',
|
|
62
|
+
},
|
|
63
|
+
transparent: {
|
|
64
|
+
type: 'boolean',
|
|
65
|
+
description: 'Render with full alpha-channel transparency (supported for webm, gif, apng, mov).',
|
|
66
|
+
default: false,
|
|
67
|
+
},
|
|
68
|
+
resolution: {
|
|
69
|
+
type: 'string',
|
|
70
|
+
enum: ['original', '1080p', '720p'],
|
|
71
|
+
description: 'Resolution preset. Default: original.',
|
|
72
|
+
default: 'original',
|
|
73
|
+
},
|
|
74
|
+
scale: {
|
|
75
|
+
type: 'number',
|
|
76
|
+
description: 'Scale factor (1-4) when using original resolution. Default: 1.',
|
|
77
|
+
default: 1,
|
|
78
|
+
},
|
|
79
|
+
bgColor: {
|
|
80
|
+
type: 'string',
|
|
81
|
+
description: 'Background color hex code (e.g. #ffffff). Cannot be used with transparent.',
|
|
82
|
+
},
|
|
83
|
+
hold: {
|
|
84
|
+
type: 'number',
|
|
85
|
+
description: 'Seconds to freeze the last frame at the end of the video.',
|
|
86
|
+
default: 0,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'inspect_svg_animation',
|
|
93
|
+
description: 'Analyze an SVG file or raw SVG content to detect CSS keyframe animations, estimate duration, and extract viewBox dimensions.',
|
|
94
|
+
inputSchema: {
|
|
95
|
+
type: 'object',
|
|
96
|
+
properties: {
|
|
97
|
+
svgFilePath: {
|
|
98
|
+
type: 'string',
|
|
99
|
+
description: 'Path to the .svg file to inspect.',
|
|
100
|
+
},
|
|
101
|
+
svgContent: {
|
|
102
|
+
type: 'string',
|
|
103
|
+
description: 'Raw SVG content to inspect.',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
112
|
+
const { name, arguments: args } = request.params;
|
|
113
|
+
if (name === 'inspect_svg_animation') {
|
|
114
|
+
const params = (args || {});
|
|
115
|
+
let svgContent = params.svgContent;
|
|
116
|
+
if (!svgContent && params.svgFilePath) {
|
|
117
|
+
if (!fs.existsSync(params.svgFilePath)) {
|
|
118
|
+
return {
|
|
119
|
+
isError: true,
|
|
120
|
+
content: [
|
|
121
|
+
{
|
|
122
|
+
type: 'text',
|
|
123
|
+
text: `File not found: ${params.svgFilePath}`,
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
svgContent = fs.readFileSync(params.svgFilePath, 'utf-8');
|
|
129
|
+
}
|
|
130
|
+
if (!svgContent) {
|
|
131
|
+
return {
|
|
132
|
+
isError: true,
|
|
133
|
+
content: [
|
|
134
|
+
{
|
|
135
|
+
type: 'text',
|
|
136
|
+
text: 'Either svgFilePath or svgContent must be provided.',
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
const dom = new JSDOM(svgContent);
|
|
142
|
+
const duration = analyzeSvgAnimation(svgContent, dom.window.DOMParser);
|
|
143
|
+
const svgEl = dom.window.document.querySelector('svg');
|
|
144
|
+
let width;
|
|
145
|
+
let height;
|
|
146
|
+
if (svgEl) {
|
|
147
|
+
const viewBox = svgEl.getAttribute('viewBox');
|
|
148
|
+
if (viewBox) {
|
|
149
|
+
const parts = viewBox.trim().split(/[\s,]+/);
|
|
150
|
+
if (parts.length === 4) {
|
|
151
|
+
width = parseFloat(parts[2]);
|
|
152
|
+
height = parseFloat(parts[3]);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (!width || !height) {
|
|
156
|
+
width = parseFloat(svgEl.getAttribute('width') || '');
|
|
157
|
+
height = parseFloat(svgEl.getAttribute('height') || '');
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
content: [
|
|
162
|
+
{
|
|
163
|
+
type: 'text',
|
|
164
|
+
text: JSON.stringify({
|
|
165
|
+
hasAnimation: duration !== undefined && duration > 0,
|
|
166
|
+
estimatedDurationSeconds: duration ?? null,
|
|
167
|
+
dimensions: width && height ? { width, height } : null,
|
|
168
|
+
hasStyles: svgContent.includes('<style>'),
|
|
169
|
+
}, null, 2),
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
if (name === 'render_svg_to_video') {
|
|
175
|
+
const params = (args || {});
|
|
176
|
+
let targetSvgPath = params.svgFilePath;
|
|
177
|
+
let tempSvgFile = false;
|
|
178
|
+
if (!targetSvgPath && params.svgContent) {
|
|
179
|
+
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'svg2vid-mcp-'));
|
|
180
|
+
targetSvgPath = path.join(tempDir, 'input.svg');
|
|
181
|
+
fs.writeFileSync(targetSvgPath, params.svgContent, 'utf-8');
|
|
182
|
+
tempSvgFile = true;
|
|
183
|
+
}
|
|
184
|
+
if (!targetSvgPath || !fs.existsSync(targetSvgPath)) {
|
|
185
|
+
return {
|
|
186
|
+
isError: true,
|
|
187
|
+
content: [
|
|
188
|
+
{
|
|
189
|
+
type: 'text',
|
|
190
|
+
text: `Input SVG not found or not provided: ${targetSvgPath || 'N/A'}`,
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
const outDir = params.outDir || process.cwd();
|
|
196
|
+
const fps = String(params.fps || 60);
|
|
197
|
+
const command = cliIndexPath.endsWith('.ts') ? 'npx' : process.execPath;
|
|
198
|
+
const cliArgs = cliIndexPath.endsWith('.ts')
|
|
199
|
+
? ['tsx', cliIndexPath, targetSvgPath, fps, outDir, '--json', '--force']
|
|
200
|
+
: [cliIndexPath, targetSvgPath, fps, outDir, '--json', '--force'];
|
|
201
|
+
if (params.duration) {
|
|
202
|
+
cliArgs.push('-d', String(params.duration));
|
|
203
|
+
}
|
|
204
|
+
if (params.format) {
|
|
205
|
+
cliArgs.push('--format', params.format);
|
|
206
|
+
}
|
|
207
|
+
if (params.transparent) {
|
|
208
|
+
cliArgs.push('--transparent');
|
|
209
|
+
}
|
|
210
|
+
if (params.resolution) {
|
|
211
|
+
cliArgs.push('--resolution', params.resolution);
|
|
212
|
+
}
|
|
213
|
+
if (params.scale) {
|
|
214
|
+
cliArgs.push('--scale', String(params.scale));
|
|
215
|
+
}
|
|
216
|
+
if (params.bgColor) {
|
|
217
|
+
cliArgs.push('--bg-color', params.bgColor);
|
|
218
|
+
}
|
|
219
|
+
if (params.hold) {
|
|
220
|
+
cliArgs.push('-h', String(params.hold));
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
const rawOutput = execFileSync(command, cliArgs, {
|
|
224
|
+
encoding: 'utf-8',
|
|
225
|
+
cwd: process.cwd(),
|
|
226
|
+
});
|
|
227
|
+
if (tempSvgFile && targetSvgPath) {
|
|
228
|
+
try {
|
|
229
|
+
fs.rmSync(path.dirname(targetSvgPath), {
|
|
230
|
+
recursive: true,
|
|
231
|
+
force: true,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
// ignore cleanup error
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const parsed = JSON.parse(rawOutput.trim());
|
|
239
|
+
if (isLoggerJsonOutput(parsed)) {
|
|
240
|
+
if (parsed.success === true) {
|
|
241
|
+
return {
|
|
242
|
+
content: [
|
|
243
|
+
{
|
|
244
|
+
type: 'text',
|
|
245
|
+
text: JSON.stringify(parsed, null, 2),
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
return {
|
|
252
|
+
isError: true,
|
|
253
|
+
content: [
|
|
254
|
+
{
|
|
255
|
+
type: 'text',
|
|
256
|
+
text: parsed.error || 'Conversion failed',
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
return {
|
|
264
|
+
isError: true,
|
|
265
|
+
content: [
|
|
266
|
+
{
|
|
267
|
+
type: 'text',
|
|
268
|
+
text: 'CLI returned unexpected output format.',
|
|
269
|
+
},
|
|
270
|
+
],
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
catch (error) {
|
|
275
|
+
if (tempSvgFile && targetSvgPath) {
|
|
276
|
+
try {
|
|
277
|
+
fs.rmSync(path.dirname(targetSvgPath), {
|
|
278
|
+
recursive: true,
|
|
279
|
+
force: true,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
catch {
|
|
283
|
+
// ignore cleanup error
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
isError: true,
|
|
288
|
+
content: [
|
|
289
|
+
{
|
|
290
|
+
type: 'text',
|
|
291
|
+
text: `Execution failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
isError: true,
|
|
299
|
+
content: [
|
|
300
|
+
{
|
|
301
|
+
type: 'text',
|
|
302
|
+
text: `Unknown tool: ${name}`,
|
|
303
|
+
},
|
|
304
|
+
],
|
|
305
|
+
};
|
|
306
|
+
});
|
|
307
|
+
async function runMcp() {
|
|
308
|
+
const transport = new StdioServerTransport();
|
|
309
|
+
await server.connect(transport);
|
|
310
|
+
}
|
|
311
|
+
runMcp().catch((err) => {
|
|
312
|
+
console.error('Fatal MCP Server Error:', err);
|
|
313
|
+
process.exit(1);
|
|
314
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export function isLoggerJsonOutput(obj) {
|
|
2
|
+
return (typeof obj === 'object' &&
|
|
3
|
+
obj !== null &&
|
|
4
|
+
'success' in obj &&
|
|
5
|
+
typeof obj.success === 'boolean');
|
|
6
|
+
}
|
|
7
|
+
export class Logger {
|
|
8
|
+
quiet;
|
|
9
|
+
isJson;
|
|
10
|
+
homepage;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.isJson = !!options.json;
|
|
13
|
+
this.quiet = !!options.quiet || this.isJson;
|
|
14
|
+
this.homepage = options.homepage;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Log standard informative messages (suppressed in quiet/json mode)
|
|
18
|
+
*/
|
|
19
|
+
info(...args) {
|
|
20
|
+
if (!this.quiet) {
|
|
21
|
+
console.log(...args);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Write raw progress strings to stdout (e.g., \r progress bar - suppressed in quiet/json mode)
|
|
26
|
+
*/
|
|
27
|
+
writeProgress(msg) {
|
|
28
|
+
if (!this.quiet) {
|
|
29
|
+
process.stdout.write(msg);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Log warning messages (suppressed in quiet/json mode)
|
|
34
|
+
*/
|
|
35
|
+
warn(...args) {
|
|
36
|
+
if (!this.quiet) {
|
|
37
|
+
console.warn(...args);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Log non-fatal error messages (suppressed in json mode to preserve unpolluted stdout)
|
|
42
|
+
*/
|
|
43
|
+
error(...args) {
|
|
44
|
+
if (!this.isJson) {
|
|
45
|
+
console.error(...args);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Called at successful completion of conversion process.
|
|
50
|
+
* Outputs JSON payload if --json is active, or friendly completion summary if not quiet.
|
|
51
|
+
*/
|
|
52
|
+
done(outputFile, data) {
|
|
53
|
+
if (this.isJson) {
|
|
54
|
+
const payload = {
|
|
55
|
+
success: true,
|
|
56
|
+
outputFile,
|
|
57
|
+
...data,
|
|
58
|
+
};
|
|
59
|
+
console.log(JSON.stringify(payload, null, 2));
|
|
60
|
+
}
|
|
61
|
+
else if (!this.quiet) {
|
|
62
|
+
console.log(`\n✅ Done! File saved to ${outputFile}`);
|
|
63
|
+
console.log('\x1b[2m%s\x1b[0m', `Love this tool? Star it on GitHub: ${this.homepage}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Output fatal error (as JSON or stderr string) and terminate execution
|
|
68
|
+
*/
|
|
69
|
+
fatal(msg, details) {
|
|
70
|
+
if (this.isJson) {
|
|
71
|
+
const payload = {
|
|
72
|
+
success: false,
|
|
73
|
+
error: msg,
|
|
74
|
+
...(details ? { details: String(details) } : {}),
|
|
75
|
+
};
|
|
76
|
+
console.log(JSON.stringify(payload, null, 2));
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
console.error(`❌ Error: ${msg}`);
|
|
80
|
+
if (details)
|
|
81
|
+
console.error(details);
|
|
82
|
+
}
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { createRequire } from 'module';
|
|
5
|
+
export function getPackageJson(importMetaUrl) {
|
|
6
|
+
const require = createRequire(importMetaUrl);
|
|
7
|
+
const filename = fileURLToPath(importMetaUrl);
|
|
8
|
+
const dirname = path.dirname(filename);
|
|
9
|
+
const localPkg = path.join(dirname, '../package.json');
|
|
10
|
+
const parentPkg = path.join(dirname, '../../package.json');
|
|
11
|
+
if (fs.existsSync(localPkg))
|
|
12
|
+
return require(localPkg);
|
|
13
|
+
if (fs.existsSync(parentPkg))
|
|
14
|
+
return require(parentPkg);
|
|
15
|
+
return require('../package.json');
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { formatRegistry } from '../formats/registry.js';
|
|
2
|
+
export function validateOptions(options) {
|
|
3
|
+
if (options.duration !== undefined && options.duration <= 0) {
|
|
4
|
+
throw new Error('Duration must be a positive number.');
|
|
5
|
+
}
|
|
6
|
+
if (options.scale !== 1 && options.resolution !== 'original') {
|
|
7
|
+
throw new Error('--scale can only be used with --resolution original.');
|
|
8
|
+
}
|
|
9
|
+
if (options.transparent && options.bgColor !== '#ffffff') {
|
|
10
|
+
throw new Error('--transparent and --bg-color cannot be used together.');
|
|
11
|
+
}
|
|
12
|
+
if (options.format && !formatRegistry.isSupported(options.format)) {
|
|
13
|
+
const supported = formatRegistry.getSupportedFormatNames().join(', ');
|
|
14
|
+
throw new Error(`Invalid format "${options.format}". Supported formats are: ${supported}.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gehdoc/svg-to-video",
|
|
3
|
+
"version": "0.23.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Professional animated SVG to Video (MP4/WebM/MKV/MOV) and Animated Image (aPNG/GIF) converter featuring frame-accurate rendering, CLI automation, and a serverless Web Studio.",
|
|
6
|
+
"imports": {
|
|
7
|
+
"#shared/*": "./dist/shared/*"
|
|
8
|
+
},
|
|
9
|
+
"author": "GehDoc",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/GehDoc/svg-to-video.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/GehDoc/svg-to-video/issues"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/GehDoc/svg-to-video#readme",
|
|
18
|
+
"funding": {
|
|
19
|
+
"url": "https://github.com/GehDoc/svg-to-video/?sponsor=1"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=22.0.0"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"animation",
|
|
26
|
+
"css",
|
|
27
|
+
"video",
|
|
28
|
+
"svg",
|
|
29
|
+
"convert",
|
|
30
|
+
"mp4",
|
|
31
|
+
"webm",
|
|
32
|
+
"apng",
|
|
33
|
+
"gif",
|
|
34
|
+
"gifenc",
|
|
35
|
+
"metadata",
|
|
36
|
+
"transparency",
|
|
37
|
+
"alpha-channel",
|
|
38
|
+
"web-animations-api",
|
|
39
|
+
"mcp",
|
|
40
|
+
"mcp-server",
|
|
41
|
+
"model-context-protocol",
|
|
42
|
+
"agent-skill"
|
|
43
|
+
],
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"dist/",
|
|
50
|
+
"skills/",
|
|
51
|
+
"README.md",
|
|
52
|
+
"LICENSE"
|
|
53
|
+
],
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
56
|
+
"commander": "^15.0.0",
|
|
57
|
+
"jsdom": "^29.1.1",
|
|
58
|
+
"puppeteer": "^25.8.0",
|
|
59
|
+
"tsx": "^4.23.0"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/commander": "^2.12.0",
|
|
63
|
+
"@types/ffprobe-static": "^2.0.3",
|
|
64
|
+
"@types/jsdom": "^28.0.3",
|
|
65
|
+
"@types/node": "^25.4.0",
|
|
66
|
+
"@types/pngjs": "^6.0.5",
|
|
67
|
+
"@vitest/browser-playwright": "4.1.11",
|
|
68
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
69
|
+
"eslint": "^8.0.0",
|
|
70
|
+
"ffprobe": "^1.1.2",
|
|
71
|
+
"ffprobe-static": "^3.1.0",
|
|
72
|
+
"husky": "^9.1.7",
|
|
73
|
+
"lint-staged": "^16.3.2",
|
|
74
|
+
"pngjs": "^7.0.0",
|
|
75
|
+
"prettier": "^3.8.1",
|
|
76
|
+
"prettier-plugin-sh": "^0.19.0",
|
|
77
|
+
"typescript": "^5.0.0",
|
|
78
|
+
"typescript-eslint": "^8.69.0",
|
|
79
|
+
"vitest": "4.1.11"
|
|
80
|
+
},
|
|
81
|
+
"scripts": {
|
|
82
|
+
"build": "tsc -p tsconfig.build.json",
|
|
83
|
+
"prepack": "npm run build",
|
|
84
|
+
"lint": "eslint . && npm run lint -w web",
|
|
85
|
+
"lint:fix": "eslint . --fix && npm run lint:fix -w web",
|
|
86
|
+
"format": "prettier --check .",
|
|
87
|
+
"format:fix": "prettier --write .",
|
|
88
|
+
"mcp": "tsx src/mcp.ts",
|
|
89
|
+
"test:cli": "tsx --test tests/cli.spec.ts",
|
|
90
|
+
"test:mcp": "tsx --test tests/mcp.spec.ts",
|
|
91
|
+
"test:pack": "tsx --test tests/pack.spec.ts",
|
|
92
|
+
"test:unit": "tsx --test src/**/*.test.ts tests/**/*.test.ts && vitest run shared/*.test.ts && npm run test:unit -w web",
|
|
93
|
+
"test": "npm run test:cli && npm run test:mcp && npm run test:pack && npm run test:unit && npm run test:web -w web && npm run test:storybook -w web && npm run test:visual -w web",
|
|
94
|
+
"type-check": "tsc -p tsconfig.json --noEmit && npm run type-check -w web",
|
|
95
|
+
"check": "npm run lint && npm run format && npm run type-check && npm run test",
|
|
96
|
+
"check:fast": "npm run lint && npm run format && npm run type-check",
|
|
97
|
+
"fix": "npm run lint:fix && npm run format:fix",
|
|
98
|
+
"prepare": "husky"
|
|
99
|
+
},
|
|
100
|
+
"lint-staged": {
|
|
101
|
+
"**/*.{js,mjs,ts,tsx,json,md,yml,html,Dockerfile,dockerfile,css,scss}": "prettier --write",
|
|
102
|
+
"src/**/*.ts": "eslint --fix",
|
|
103
|
+
"shared/**/*.ts": "eslint --fix",
|
|
104
|
+
"tests/**/*.ts": "eslint --fix",
|
|
105
|
+
"web/**/*.{ts,tsx,js}": "npm run lint --workspace=web -- --fix"
|
|
106
|
+
},
|
|
107
|
+
"main": "dist/src/index.js",
|
|
108
|
+
"bin": {
|
|
109
|
+
"svg-to-video": "dist/src/index.js",
|
|
110
|
+
"svg-to-video-mcp": "dist/src/mcp.js"
|
|
111
|
+
},
|
|
112
|
+
"workspaces": [
|
|
113
|
+
"web"
|
|
114
|
+
],
|
|
115
|
+
"overrides": {
|
|
116
|
+
"vitest": "$vitest",
|
|
117
|
+
"@vitest/spy": "$vitest",
|
|
118
|
+
"@vitest/expect": "$vitest",
|
|
119
|
+
"@vitest/utils": "$vitest",
|
|
120
|
+
"@vitest/mocker": "$vitest",
|
|
121
|
+
"@vitest/runner": "$vitest",
|
|
122
|
+
"@vitest/snapshot": "$vitest"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: svg-to-video
|
|
3
|
+
description: Convert CSS-animated SVG files or SVG string content into high-quality MP4/WebM/MKV/MOV videos, lightweight animated GIFs, or aPNG images with optional alpha-channel background transparency.
|
|
4
|
+
tools:
|
|
5
|
+
- name: render_svg_to_video
|
|
6
|
+
description: Convert an animated SVG to video or animated image format.
|
|
7
|
+
- name: inspect_svg_animation
|
|
8
|
+
description: Inspect an SVG animation to estimate duration, keyframes, and dimensions.
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# SVG to Video Agent Skill
|
|
12
|
+
|
|
13
|
+
This skill enables AI agents to render animated vector graphics (SVGs with CSS animations, SMIL keyframes, or Web Animations API) into binary video and image assets.
|
|
14
|
+
|
|
15
|
+
## Capabilities
|
|
16
|
+
|
|
17
|
+
1. **Format Export**: Converts SVGs into `mp4`, `webm`, `gif`, `apng`, `mkv`, and `mov`.
|
|
18
|
+
2. **Transparent Backgrounds**: Supports full alpha-channel transparency for `webm`, `gif`, `apng`, and `mov`.
|
|
19
|
+
3. **Auto-Duration Detection**: Automatically detects CSS keyframe and animation loop durations if not specified.
|
|
20
|
+
4. **Resolution Presets**: Supports `original`, `1080p`, `720p`, and custom scaling factors (1x-4x).
|
|
21
|
+
|
|
22
|
+
## Usage Guidelines for AI Agents
|
|
23
|
+
|
|
24
|
+
When asked to generate a video or GIF from an SVG animation:
|
|
25
|
+
|
|
26
|
+
1. **Option A: Via MCP Tools (Recommended)**:
|
|
27
|
+
- Call `render_svg_to_video` directly passing either `svgContent` (raw XML string) or `svgFilePath`.
|
|
28
|
+
- Set `transparent: true` and `format: "webm"` or `format: "gif"` if a transparent overlay is requested.
|
|
29
|
+
|
|
30
|
+
2. **Option B: Via CLI Command**:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npx @gehdoc/svg-to-video input.svg 60 ./out-dir -d 5 --format gif --transparent --json
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
3. **Option C: Via Docker**:
|
|
37
|
+
```bash
|
|
38
|
+
docker run -i --rm -v $(pwd):/app/data gehdoc/svg-to-video mcp
|
|
39
|
+
```
|