-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsvg-to-mp4.js
More file actions
29 lines (25 loc) · 842 Bytes
/
svg-to-mp4.js
File metadata and controls
29 lines (25 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var system = require('system'),
args = system.args,
svgPath = args[1],
time = args.length > 2 ? parseInt(args[2]) : 5,
fps = args.length > 3 ? parseInt(args[3]) : 30,
frames = time * fps,
width = args.length > 4 ? parseInt(args[4]) : 1280,
height = args.length > 5 ? parseInt(args[5]) : 720,
slowdownFactor = args.length > 6 ? parseInt(args[6]) : 10,
page = require("webpage").create();
page.viewportSize = { width: width, height: height };
var frame = 0,
trueFps = fps / slowdownFactor,
timingInterval = 1000 / trueFps;
setInterval(function() {
if(frame >= frames)
phantom.exit();
else {
console.log("Writing frame " + frame++);
page.render("/dev/stderr", { format: "png" });
}
}, timingInterval);
page.open(svgPath, function start(status) {
console.log("Opened SVG");
});