@marcuth/movie.js 0.1.0 → 0.1.2
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/dist/clips/image-clip.d.ts +2 -2
- package/dist/clips/image-clip.js +75 -26
- package/dist/template.js +10 -10
- package/dist/utils/easing-expr.d.ts +1 -0
- package/dist/utils/easing-expr.js +17 -0
- package/package.json +1 -1
- package/dist/utils/font-config.d.ts +0 -9
- package/dist/utils/font-config.js +0 -19
- package/dist/utils/get-eased-expression.d.ts +0 -1
- package/dist/utils/get-eased-expression.js +0 -15
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -17
|
@@ -20,8 +20,8 @@ export declare class ImageClip<RenderData> extends Clip<RenderData> {
|
|
|
20
20
|
readonly path: Path<RenderData>;
|
|
21
21
|
readonly fadeIn?: number;
|
|
22
22
|
readonly fadeOut?: number;
|
|
23
|
-
readonly width
|
|
24
|
-
readonly height
|
|
23
|
+
readonly width: number;
|
|
24
|
+
readonly height: number;
|
|
25
25
|
readonly scroll?: {
|
|
26
26
|
axis?: "auto" | "x" | "y";
|
|
27
27
|
direction?: "forward" | "backward";
|
package/dist/clips/image-clip.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ImageClip = void 0;
|
|
4
4
|
const resolve_path_1 = require("../utils/resolve-path");
|
|
5
5
|
const clip_1 = require("./clip");
|
|
6
|
-
const
|
|
6
|
+
const easing_expr_1 = require("../utils/easing-expr");
|
|
7
7
|
class ImageClip extends clip_1.Clip {
|
|
8
8
|
constructor({ duration, path, width, height, fadeIn, fadeOut, scroll }) {
|
|
9
9
|
super();
|
|
@@ -11,8 +11,8 @@ class ImageClip extends clip_1.Clip {
|
|
|
11
11
|
this.path = path;
|
|
12
12
|
this.fadeIn = fadeIn;
|
|
13
13
|
this.fadeOut = fadeOut;
|
|
14
|
-
this.width = width;
|
|
15
|
-
this.height = height;
|
|
14
|
+
this.width = width || -1;
|
|
15
|
+
this.height = height || -1;
|
|
16
16
|
this.scroll = scroll;
|
|
17
17
|
}
|
|
18
18
|
getInput(path, inputIndex, fps) {
|
|
@@ -32,7 +32,6 @@ class ImageClip extends clip_1.Clip {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
build(data, context) {
|
|
35
|
-
var _a, _b, _c, _d, _e;
|
|
36
35
|
const path = (0, resolve_path_1.resolvePath)({ path: this.path, data: data, index: context.clipIndex });
|
|
37
36
|
const input = this.getInput(path, context.inputIndex, context.fps);
|
|
38
37
|
let currentVideoOutput = input.aliases.video;
|
|
@@ -52,41 +51,91 @@ class ImageClip extends clip_1.Clip {
|
|
|
52
51
|
inputs: anullSrcLabel,
|
|
53
52
|
outputs: currentAudioOutput,
|
|
54
53
|
});
|
|
55
|
-
|
|
54
|
+
const hasCanvas = this.width !== -1 || this.height !== -1;
|
|
55
|
+
if (hasCanvas && this.scroll) {
|
|
56
56
|
const scaleOutput = `scale${context.inputIndex}`;
|
|
57
|
+
const { axis = "auto" } = this.scroll;
|
|
58
|
+
let scaleOptions = null;
|
|
59
|
+
if (axis === "y" || axis === "auto") {
|
|
60
|
+
scaleOptions = {
|
|
61
|
+
w: this.width,
|
|
62
|
+
h: -1,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
else if (axis === "x") {
|
|
66
|
+
scaleOptions = {
|
|
67
|
+
w: -1,
|
|
68
|
+
h: this.height,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (!scaleOptions) {
|
|
72
|
+
throw new Error("Invalid scale options");
|
|
73
|
+
}
|
|
57
74
|
context.filters.push({
|
|
58
75
|
filter: "scale",
|
|
59
|
-
options:
|
|
76
|
+
options: scaleOptions,
|
|
60
77
|
inputs: currentVideoOutput,
|
|
61
78
|
outputs: scaleOutput,
|
|
62
79
|
});
|
|
63
80
|
currentVideoOutput = scaleOutput;
|
|
64
81
|
}
|
|
65
|
-
if (this.scroll) {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
82
|
+
else if (hasCanvas && !this.scroll) {
|
|
83
|
+
const scaleOutput = `scale${context.inputIndex}`;
|
|
84
|
+
context.filters.push({
|
|
85
|
+
filter: "scale",
|
|
86
|
+
options: {
|
|
87
|
+
w: this.width,
|
|
88
|
+
h: this.height,
|
|
89
|
+
force_original_aspect_ratio: "increase",
|
|
90
|
+
},
|
|
91
|
+
inputs: currentVideoOutput,
|
|
92
|
+
outputs: scaleOutput,
|
|
93
|
+
});
|
|
94
|
+
const fitOutput = `fit${context.inputIndex}`;
|
|
70
95
|
context.filters.push({
|
|
71
96
|
filter: "crop",
|
|
72
97
|
options: {
|
|
73
|
-
w:
|
|
74
|
-
h:
|
|
75
|
-
x:
|
|
76
|
-
|
|
77
|
-
max(iw-${this.width},0)*${p},
|
|
78
|
-
0
|
|
79
|
-
)
|
|
80
|
-
`,
|
|
81
|
-
y: `
|
|
82
|
-
if(gt(ih,${this.height}),
|
|
83
|
-
max(ih-${this.height},0)*${p},
|
|
84
|
-
0
|
|
85
|
-
)
|
|
86
|
-
`
|
|
98
|
+
w: this.width,
|
|
99
|
+
h: this.height,
|
|
100
|
+
x: "(iw-ow)/2",
|
|
101
|
+
y: "(ih-oh)/2",
|
|
87
102
|
},
|
|
103
|
+
inputs: scaleOutput,
|
|
104
|
+
outputs: fitOutput,
|
|
105
|
+
});
|
|
106
|
+
currentVideoOutput = fitOutput;
|
|
107
|
+
}
|
|
108
|
+
if (this.scroll) {
|
|
109
|
+
const { axis = "auto", direction = "forward", easing = "linear", } = this.scroll;
|
|
110
|
+
const cropOutput = `scroll${context.inputIndex}`;
|
|
111
|
+
const tNorm = `t/${this.duration}`;
|
|
112
|
+
const eased = (0, easing_expr_1.easingExpr)(easing, tNorm);
|
|
113
|
+
const movement = direction === "backward" ? `1-(${eased})` : eased;
|
|
114
|
+
let cropOptions = null;
|
|
115
|
+
if (axis === "y" || axis === "auto") {
|
|
116
|
+
cropOptions = {
|
|
117
|
+
w: this.width,
|
|
118
|
+
h: this.height,
|
|
119
|
+
x: 0,
|
|
120
|
+
y: `(ih-oh)*(${movement})`,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
if (axis === "x") {
|
|
124
|
+
cropOptions = {
|
|
125
|
+
w: this.width,
|
|
126
|
+
h: this.height,
|
|
127
|
+
x: `(iw-ow)*(${movement})`,
|
|
128
|
+
y: 0,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
if (!cropOptions) {
|
|
132
|
+
throw new Error("Invalid crop options");
|
|
133
|
+
}
|
|
134
|
+
context.filters.push({
|
|
135
|
+
filter: "crop",
|
|
136
|
+
options: cropOptions,
|
|
88
137
|
inputs: currentVideoOutput,
|
|
89
|
-
outputs: cropOutput
|
|
138
|
+
outputs: cropOutput,
|
|
90
139
|
});
|
|
91
140
|
currentVideoOutput = cropOutput;
|
|
92
141
|
}
|
package/dist/template.js
CHANGED
|
@@ -26,16 +26,16 @@ class Template {
|
|
|
26
26
|
video: []
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
if (this.options.debug) {
|
|
30
|
+
command
|
|
31
|
+
.on("start", (commandLine) => {
|
|
32
|
+
console.log("Spawned Ffmpeg with command: " + commandLine);
|
|
33
|
+
})
|
|
34
|
+
.on("error", (err, stdout, stderr) => {
|
|
35
|
+
console.error("Error: " + err.message);
|
|
36
|
+
console.error("ffmpeg stderr: " + stderr);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
39
|
await this.runBuildWithProgress(data, context);
|
|
40
40
|
const concatFilter = context.labels.video
|
|
41
41
|
.map((v, i) => `${v}${context.labels.structuralAudio[i]}`)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function easingExpr(easing: "linear" | "easeIn" | "easeOut" | "easeInOut", t: string): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.easingExpr = easingExpr;
|
|
4
|
+
function easingExpr(easing, t) {
|
|
5
|
+
switch (easing) {
|
|
6
|
+
case "linear":
|
|
7
|
+
return `(${t})`; // Adicionar parênteses para garantir que a expressão seja avaliada
|
|
8
|
+
case "easeIn":
|
|
9
|
+
return `pow(${t},2)`;
|
|
10
|
+
case "easeOut":
|
|
11
|
+
return `1-pow(1-(${t}),2)`; // Adicionar parênteses extras
|
|
12
|
+
case "easeInOut":
|
|
13
|
+
return `if(lt(${t},0.5),2*pow(${t},2),1-2*pow(1-(${t}),2))`; // Adicionar parênteses extras
|
|
14
|
+
default:
|
|
15
|
+
return `(${t})`;
|
|
16
|
+
}
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type FontConfigOptions = {
|
|
2
|
-
color?: string;
|
|
3
|
-
filePath?: string;
|
|
4
|
-
};
|
|
5
|
-
export type PartialFontOptions = {
|
|
6
|
-
size: number;
|
|
7
|
-
color?: string;
|
|
8
|
-
};
|
|
9
|
-
export declare function fontConfig(options: FontConfigOptions): (partialOptions: PartialFontOptions) => TextClipFontOptions;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fontConfig = fontConfig;
|
|
4
|
-
function fontConfig(options) {
|
|
5
|
-
return (partialOptions) => {
|
|
6
|
-
var _a;
|
|
7
|
-
const color = (_a = options.color) !== null && _a !== void 0 ? _a : partialOptions.color;
|
|
8
|
-
const filePath = options.filePath;
|
|
9
|
-
const size = partialOptions.size;
|
|
10
|
-
if (!color) {
|
|
11
|
-
throw new Error("Font color is required");
|
|
12
|
-
}
|
|
13
|
-
return {
|
|
14
|
-
size: size,
|
|
15
|
-
color: color,
|
|
16
|
-
filePath: filePath,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getEasedExpression(expr: string, easing: "linear" | "easeIn" | "easeOut" | "easeInOut"): string;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEasedExpression = getEasedExpression;
|
|
4
|
-
function getEasedExpression(expr, easing) {
|
|
5
|
-
switch (easing) {
|
|
6
|
-
case "easeIn":
|
|
7
|
-
return `${expr}*${expr}`;
|
|
8
|
-
case "easeOut":
|
|
9
|
-
return `1-(1-${expr})*(1-${expr})`;
|
|
10
|
-
case "easeInOut":
|
|
11
|
-
return `(1-cos(PI*${expr}))/2`;
|
|
12
|
-
default:
|
|
13
|
-
return expr;
|
|
14
|
-
}
|
|
15
|
-
}
|
package/dist/utils/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./font-config";
|
package/dist/utils/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./font-config"), exports);
|