@marcuth/movie.js 0.2.1 → 0.3.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.
|
@@ -1,18 +1,20 @@
|
|
|
1
|
+
import { Property } from "../utils/resolve-property";
|
|
1
2
|
import { Path } from "../utils/resolve-path";
|
|
2
3
|
import { RenderContext } from "../render-context";
|
|
3
4
|
import { FFmpegInput } from "../ffmpeg-input";
|
|
4
5
|
import { Clip } from "./clip";
|
|
6
|
+
export type SubClip<RenderData> = Property<RenderData, [number, number]>;
|
|
5
7
|
export type VideoClipOptions<RenderData> = {
|
|
6
8
|
path: Path<RenderData>;
|
|
7
9
|
fadeIn?: number;
|
|
8
10
|
fadeOut?: number;
|
|
9
|
-
subClip?:
|
|
11
|
+
subClip?: SubClip<RenderData>;
|
|
10
12
|
};
|
|
11
13
|
export declare class VideoClip<RenderData> extends Clip<RenderData> {
|
|
12
14
|
readonly path: Path<RenderData>;
|
|
13
15
|
readonly fadeIn?: number;
|
|
14
16
|
readonly fadeOut?: number;
|
|
15
|
-
readonly subClip?:
|
|
17
|
+
readonly subClip?: SubClip<RenderData>;
|
|
16
18
|
constructor({ path, fadeIn, fadeOut, subClip }: VideoClipOptions<RenderData>);
|
|
17
19
|
protected getInput(path: string, inputIndex: number): FFmpegInput;
|
|
18
20
|
getDuration(path: string): Promise<number>;
|
package/dist/clips/video-clip.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VideoClip = void 0;
|
|
4
4
|
const fluent_ffmpeg_1 = require("fluent-ffmpeg");
|
|
5
|
+
const resolve_property_1 = require("../utils/resolve-property");
|
|
5
6
|
const resolve_path_1 = require("../utils/resolve-path");
|
|
6
7
|
const clip_1 = require("./clip");
|
|
7
8
|
class VideoClip extends clip_1.Clip {
|
|
@@ -41,7 +42,8 @@ class VideoClip extends clip_1.Clip {
|
|
|
41
42
|
let duration = await this.getDuration(path);
|
|
42
43
|
context.command.input(path);
|
|
43
44
|
if (this.subClip) {
|
|
44
|
-
const
|
|
45
|
+
const subClip = (0, resolve_property_1.resolveProperty)({ property: this.subClip, data, index: context.clipIndex });
|
|
46
|
+
const [start, subDuration] = subClip;
|
|
45
47
|
context.command.inputOptions([`-ss ${start}`, `-t ${subDuration}`]);
|
|
46
48
|
duration = subDuration;
|
|
47
49
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type ComputePropertyOptions<RenderData> = {
|
|
2
|
+
data: RenderData;
|
|
3
|
+
index: number;
|
|
4
|
+
};
|
|
5
|
+
export type ComputeProperty<RenderData, T> = (options: ComputePropertyOptions<RenderData>) => T;
|
|
6
|
+
export type Property<RenderData, T> = ComputeProperty<RenderData, T> | T;
|
|
7
|
+
export type ResolvePropertyOptions<RenderData, T> = {
|
|
8
|
+
property: Property<RenderData, T>;
|
|
9
|
+
data: RenderData;
|
|
10
|
+
index: number;
|
|
11
|
+
};
|
|
12
|
+
export declare function resolveProperty<RenderData, T>({ property, ...params }: ResolvePropertyOptions<RenderData, T>): T;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveProperty = resolveProperty;
|
|
4
|
+
function resolveProperty({ property, ...params }) {
|
|
5
|
+
if (typeof property === "function") {
|
|
6
|
+
return property(params);
|
|
7
|
+
}
|
|
8
|
+
return property;
|
|
9
|
+
}
|