@agrhub/engine-pixi 0.0.0-stage → 1.3.3
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 +47 -0
- package/NOTICE.md +19 -0
- package/README.md +6 -2
- package/dist/animation/block-reveal-animation.d.ts +33 -0
- package/dist/animation/easings.d.ts +4 -0
- package/dist/animation/gsap-animation.d.ts +32 -0
- package/dist/animation/index.d.ts +9 -0
- package/dist/animation/keyframe-animation.d.ts +11 -0
- package/dist/animation/mask-animation.d.ts +145 -0
- package/dist/animation/pixi-animation-utils.d.ts +10 -0
- package/dist/animation/registry.d.ts +11 -0
- package/dist/animation/types.d.ts +205 -0
- package/dist/animation/wipe-animation.d.ts +53 -0
- package/dist/clips/audio-clip.d.ts +122 -0
- package/dist/clips/backdrop-clip.d.ts +56 -0
- package/dist/clips/base-clip.d.ts +150 -0
- package/dist/clips/base-text-clip.d.ts +228 -0
- package/dist/clips/caption-clip.d.ts +129 -0
- package/dist/clips/clip-registry.d.ts +56 -0
- package/dist/clips/effect-clip.d.ts +37 -0
- package/dist/clips/iclip.d.ts +231 -0
- package/dist/clips/image-clip.d.ts +116 -0
- package/dist/clips/index.d.ts +20 -0
- package/dist/clips/placeholder-clip.d.ts +22 -0
- package/dist/clips/shape-clip.d.ts +59 -0
- package/dist/clips/text-clip.d.ts +148 -0
- package/dist/clips/transition-clip.d.ts +41 -0
- package/dist/clips/video-clip.d.ts +215 -0
- package/dist/compositor/audio-mixer.d.ts +8 -0
- package/dist/compositor/av-encoder.d.ts +17 -0
- package/dist/compositor/clip-style-renderer.d.ts +23 -0
- package/dist/compositor/compositor-renderer.d.ts +29 -0
- package/dist/compositor/effect-manager.d.ts +28 -0
- package/dist/compositor/scheduler.d.ts +8 -0
- package/dist/compositor/transition-manager.d.ts +45 -0
- package/dist/compositor.d.ts +157 -0
- package/dist/effect/constant/index.d.ts +566 -0
- package/dist/effect/effect.d.ts +9 -0
- package/dist/effect/glsl/custom-glsl.d.ts +1043 -0
- package/dist/effect/glsl/gl-effect.d.ts +38 -0
- package/dist/effect/interface/index.d.ts +25 -0
- package/dist/effect/types.d.ts +26 -0
- package/dist/effect/vertex.d.ts +1 -0
- package/dist/event-emitter.d.ts +55 -0
- package/dist/filters/outline-filter.d.ts +28 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.es.js +16038 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.cjs +3335 -0
- package/dist/index.umd.cjs.map +1 -0
- package/dist/json-serialization.d.ts +310 -0
- package/dist/mp4-utils/index.d.ts +31 -0
- package/dist/mp4-utils/mp4box-utils.d.ts +44 -0
- package/dist/mp4-utils/sample-transform.d.ts +26 -0
- package/dist/sprite/base-sprite.d.ts +255 -0
- package/dist/sprite/pixi-sprite-renderer.d.ts +68 -0
- package/dist/standalone/index.es.js +94023 -0
- package/dist/standalone/index.es.js.map +1 -0
- package/dist/studio/history-manager.d.ts +46 -0
- package/dist/studio/resource-manager.d.ts +53 -0
- package/dist/studio/selection-manager.d.ts +66 -0
- package/dist/studio/timeline-model.d.ts +117 -0
- package/dist/studio/transport.d.ts +44 -0
- package/dist/studio-bridge.d.ts +50 -0
- package/dist/studio.d.ts +527 -0
- package/dist/transformer/handle.d.ts +17 -0
- package/dist/transformer/snapping.d.ts +45 -0
- package/dist/transformer/transformer.d.ts +38 -0
- package/dist/transformer/wireframe.d.ts +5 -0
- package/dist/transition/fragment.d.ts +1 -0
- package/dist/transition/glsl/custom-glsl.d.ts +231 -0
- package/dist/transition/glsl/gl-transition.d.ts +42 -0
- package/dist/transition/transition.d.ts +6 -0
- package/dist/transition/types.d.ts +29 -0
- package/dist/transition/uniforms.d.ts +35 -0
- package/dist/transition/vertex.d.ts +1 -0
- package/dist/utils/asset-manager.d.ts +15 -0
- package/dist/utils/audio-codec-detector.d.ts +39 -0
- package/dist/utils/audio.d.ts +81 -0
- package/dist/utils/chromakey.d.ts +24 -0
- package/dist/utils/color-adjustment.d.ts +53 -0
- package/dist/utils/color.d.ts +17 -0
- package/dist/utils/common.d.ts +7 -0
- package/dist/utils/dom.d.ts +48 -0
- package/dist/utils/effect.d.ts +1 -0
- package/dist/utils/fonts.d.ts +21 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/log.d.ts +27 -0
- package/dist/utils/media-cache.d.ts +45 -0
- package/dist/utils/stream-utils.d.ts +4 -0
- package/dist/utils/video.d.ts +16 -0
- package/dist/utils/worker-timer.d.ts +1 -0
- package/package.json +63 -3
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { IClip, ITransitionInfo, ClipContext, IChromaKeyOpts } from './clips';
|
|
2
|
+
import { ColorAdjustment } from './utils/color-adjustment';
|
|
3
|
+
import { ShapeType } from '@agrhub/core';
|
|
4
|
+
export interface ClipTimingJSON {
|
|
5
|
+
display: {
|
|
6
|
+
from: number;
|
|
7
|
+
to: number;
|
|
8
|
+
};
|
|
9
|
+
trim?: {
|
|
10
|
+
from: number;
|
|
11
|
+
to: number;
|
|
12
|
+
};
|
|
13
|
+
duration: number;
|
|
14
|
+
playbackRate: number;
|
|
15
|
+
fadeIn?: {
|
|
16
|
+
duration: number;
|
|
17
|
+
curve?: "linear" | "ease-in" | "ease-out" | "ease-in-out";
|
|
18
|
+
};
|
|
19
|
+
fadeOut?: {
|
|
20
|
+
duration: number;
|
|
21
|
+
curve?: "linear" | "ease-in" | "ease-out" | "ease-in-out";
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface ClipTransformJSON {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
angle: number;
|
|
30
|
+
opacity: number;
|
|
31
|
+
zIndex: number;
|
|
32
|
+
flip?: {
|
|
33
|
+
x: boolean;
|
|
34
|
+
y: boolean;
|
|
35
|
+
} | null;
|
|
36
|
+
}
|
|
37
|
+
interface BaseClipJSON {
|
|
38
|
+
id?: string;
|
|
39
|
+
name?: string;
|
|
40
|
+
metadata?: Record<string, any>;
|
|
41
|
+
effects?: Array<{
|
|
42
|
+
id: string;
|
|
43
|
+
key: string;
|
|
44
|
+
startTime: number;
|
|
45
|
+
duration: number;
|
|
46
|
+
targets?: number[];
|
|
47
|
+
}>;
|
|
48
|
+
src?: string;
|
|
49
|
+
timing?: ClipTimingJSON;
|
|
50
|
+
transform?: ClipTransformJSON;
|
|
51
|
+
display?: {
|
|
52
|
+
from: number;
|
|
53
|
+
to: number;
|
|
54
|
+
};
|
|
55
|
+
playbackRate?: number;
|
|
56
|
+
duration?: number;
|
|
57
|
+
trim?: {
|
|
58
|
+
from: number;
|
|
59
|
+
to: number;
|
|
60
|
+
};
|
|
61
|
+
transition?: ITransitionInfo;
|
|
62
|
+
style?: any;
|
|
63
|
+
locked?: boolean;
|
|
64
|
+
colorAdjustment?: ColorAdjustment;
|
|
65
|
+
chromaKey?: IChromaKeyOpts;
|
|
66
|
+
animation?: {
|
|
67
|
+
keyFrames: Record<string, Partial<{
|
|
68
|
+
x: number;
|
|
69
|
+
y: number;
|
|
70
|
+
w: number;
|
|
71
|
+
h: number;
|
|
72
|
+
angle: number;
|
|
73
|
+
opacity: number;
|
|
74
|
+
}>>;
|
|
75
|
+
options: {
|
|
76
|
+
duration: number;
|
|
77
|
+
delay?: number;
|
|
78
|
+
iterCount?: number;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
animations?: Array<{
|
|
82
|
+
type: string;
|
|
83
|
+
options: any;
|
|
84
|
+
params?: any;
|
|
85
|
+
}>;
|
|
86
|
+
main?: boolean;
|
|
87
|
+
}
|
|
88
|
+
export interface ClipVisualStyleJSON {
|
|
89
|
+
borderRadius?: number;
|
|
90
|
+
stroke?: {
|
|
91
|
+
color: string;
|
|
92
|
+
width: number;
|
|
93
|
+
};
|
|
94
|
+
shadow?: {
|
|
95
|
+
color?: string;
|
|
96
|
+
alpha?: number;
|
|
97
|
+
blur?: number;
|
|
98
|
+
offsetX?: number;
|
|
99
|
+
offsetY?: number;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export interface VideoJSON extends BaseClipJSON {
|
|
103
|
+
type: "Video";
|
|
104
|
+
audio?: boolean;
|
|
105
|
+
volume?: number;
|
|
106
|
+
style?: ClipVisualStyleJSON;
|
|
107
|
+
}
|
|
108
|
+
export interface AudioJSON extends BaseClipJSON {
|
|
109
|
+
type: "Audio";
|
|
110
|
+
loop?: boolean;
|
|
111
|
+
volume?: number;
|
|
112
|
+
style?: ClipVisualStyleJSON;
|
|
113
|
+
}
|
|
114
|
+
export interface ImageJSON extends BaseClipJSON {
|
|
115
|
+
type: "Image";
|
|
116
|
+
style?: ClipVisualStyleJSON;
|
|
117
|
+
}
|
|
118
|
+
export interface TextStyleJSON {
|
|
119
|
+
fontSize?: number;
|
|
120
|
+
fontFamily?: string;
|
|
121
|
+
fontWeight?: string | number;
|
|
122
|
+
fontStyle?: string;
|
|
123
|
+
color?: string | number | {
|
|
124
|
+
type: "gradient";
|
|
125
|
+
x0: number;
|
|
126
|
+
y0: number;
|
|
127
|
+
x1: number;
|
|
128
|
+
y1: number;
|
|
129
|
+
colors: Array<{
|
|
130
|
+
ratio: number;
|
|
131
|
+
color: string | number;
|
|
132
|
+
}>;
|
|
133
|
+
};
|
|
134
|
+
align?: "left" | "center" | "right";
|
|
135
|
+
fontUrl?: string;
|
|
136
|
+
stroke?: {
|
|
137
|
+
color: string | number;
|
|
138
|
+
width: number;
|
|
139
|
+
join?: "miter" | "round" | "bevel";
|
|
140
|
+
cap?: "butt" | "round" | "square";
|
|
141
|
+
miterLimit?: number;
|
|
142
|
+
};
|
|
143
|
+
shadow?: {
|
|
144
|
+
color?: string | number;
|
|
145
|
+
alpha?: number;
|
|
146
|
+
blur?: number;
|
|
147
|
+
offsetX?: number;
|
|
148
|
+
offsetY?: number;
|
|
149
|
+
};
|
|
150
|
+
wordWrap?: boolean;
|
|
151
|
+
wordWrapWidth?: number;
|
|
152
|
+
lineHeight?: number;
|
|
153
|
+
letterSpacing?: number;
|
|
154
|
+
textCase?: "none" | "uppercase" | "lowercase" | "title";
|
|
155
|
+
wordsPerLine?: "single" | "multiple";
|
|
156
|
+
verticalAlign?: "top" | "center" | "bottom";
|
|
157
|
+
wordAnimation?: ICaptionWordAnimation;
|
|
158
|
+
textBoxStyle?: TextBoxStyleJSON;
|
|
159
|
+
appeared?: string;
|
|
160
|
+
active?: string;
|
|
161
|
+
activeFill?: string;
|
|
162
|
+
captionBackground?: string;
|
|
163
|
+
keyword?: string;
|
|
164
|
+
background?: {
|
|
165
|
+
color?: string;
|
|
166
|
+
opacity?: number;
|
|
167
|
+
borderRadius?: number;
|
|
168
|
+
paddingX?: number;
|
|
169
|
+
paddingY?: number;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
export interface ICaptionWordAnimation {
|
|
173
|
+
type: "scale" | "opacity";
|
|
174
|
+
application: "active" | "keyword" | "none";
|
|
175
|
+
value: number;
|
|
176
|
+
mode?: "static" | "dynamic";
|
|
177
|
+
}
|
|
178
|
+
export interface TextBoxStyleJSON {
|
|
179
|
+
style?: "tiktok" | "none";
|
|
180
|
+
textAlign?: "left" | "center" | "right" | "";
|
|
181
|
+
maxLines?: number;
|
|
182
|
+
borderRadius?: number;
|
|
183
|
+
horizontalPadding?: number;
|
|
184
|
+
verticalPadding?: number;
|
|
185
|
+
}
|
|
186
|
+
export interface TextJSON extends BaseClipJSON {
|
|
187
|
+
type: "Text";
|
|
188
|
+
text: string;
|
|
189
|
+
style?: TextStyleJSON;
|
|
190
|
+
}
|
|
191
|
+
export interface CaptionWordStyleJSON {
|
|
192
|
+
color?: string;
|
|
193
|
+
border?: {
|
|
194
|
+
color?: string;
|
|
195
|
+
width?: number;
|
|
196
|
+
};
|
|
197
|
+
background?: string;
|
|
198
|
+
}
|
|
199
|
+
export interface CaptionColorsJSON {
|
|
200
|
+
/** Currently spoken word */
|
|
201
|
+
active?: CaptionWordStyleJSON;
|
|
202
|
+
/** Upcoming / future words */
|
|
203
|
+
future?: CaptionWordStyleJSON;
|
|
204
|
+
/** Keyword words */
|
|
205
|
+
keyword?: {
|
|
206
|
+
color?: string;
|
|
207
|
+
preserveAfterSpoken?: boolean;
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
export interface CaptionPositioningJSON {
|
|
211
|
+
bottomOffset?: number;
|
|
212
|
+
videoWidth?: number;
|
|
213
|
+
videoHeight?: number;
|
|
214
|
+
}
|
|
215
|
+
export interface CaptionDataJSON {
|
|
216
|
+
words?: Array<{
|
|
217
|
+
text: string;
|
|
218
|
+
from: number;
|
|
219
|
+
to: number;
|
|
220
|
+
isKeyWord?: boolean;
|
|
221
|
+
paragraphIndex?: number;
|
|
222
|
+
}>;
|
|
223
|
+
colors?: CaptionColorsJSON;
|
|
224
|
+
positioning?: CaptionPositioningJSON;
|
|
225
|
+
wordAnimation?: ICaptionWordAnimation;
|
|
226
|
+
textBoxStyle?: TextBoxStyleJSON;
|
|
227
|
+
}
|
|
228
|
+
export interface CaptionJSON extends BaseClipJSON {
|
|
229
|
+
type: "Caption";
|
|
230
|
+
text: string;
|
|
231
|
+
style?: TextStyleJSON;
|
|
232
|
+
caption?: CaptionDataJSON;
|
|
233
|
+
fontUrl?: string;
|
|
234
|
+
mediaId?: string;
|
|
235
|
+
wordsPerLine?: "single" | "multiple";
|
|
236
|
+
textBoxStyle?: TextBoxStyleJSON;
|
|
237
|
+
}
|
|
238
|
+
export interface EffectJSON extends BaseClipJSON {
|
|
239
|
+
type: "Effect";
|
|
240
|
+
effectKey: string;
|
|
241
|
+
values?: Record<string, any>;
|
|
242
|
+
}
|
|
243
|
+
export interface TransitionJSON extends BaseClipJSON {
|
|
244
|
+
type: "Transition";
|
|
245
|
+
transitionKey: string;
|
|
246
|
+
fromClipId?: string | null;
|
|
247
|
+
toClipId?: string | null;
|
|
248
|
+
}
|
|
249
|
+
export interface PlaceholderJSON extends BaseClipJSON {
|
|
250
|
+
type: "Placeholder";
|
|
251
|
+
}
|
|
252
|
+
export interface ShapeJSON extends BaseClipJSON {
|
|
253
|
+
type: "Shape";
|
|
254
|
+
shapeType: ShapeType;
|
|
255
|
+
}
|
|
256
|
+
export interface GlobalTransitionJSON {
|
|
257
|
+
key: string;
|
|
258
|
+
duration: number;
|
|
259
|
+
clips: string[];
|
|
260
|
+
}
|
|
261
|
+
export type ClipJSON = VideoJSON | AudioJSON | ImageJSON | TextJSON | CaptionJSON | EffectJSON | TransitionJSON | PlaceholderJSON | ShapeJSON;
|
|
262
|
+
export interface StudioTrackJSON {
|
|
263
|
+
id: string;
|
|
264
|
+
name: string;
|
|
265
|
+
type: string;
|
|
266
|
+
clipIds: string[];
|
|
267
|
+
}
|
|
268
|
+
export interface ProjectJSON {
|
|
269
|
+
tracks?: StudioTrackJSON[];
|
|
270
|
+
clips: Record<string, ClipJSON>;
|
|
271
|
+
transition?: GlobalTransitionJSON[];
|
|
272
|
+
transitions?: GlobalTransitionJSON[];
|
|
273
|
+
globalEffects?: Array<{
|
|
274
|
+
id: string;
|
|
275
|
+
key: string;
|
|
276
|
+
startTime: number;
|
|
277
|
+
duration: number;
|
|
278
|
+
}>;
|
|
279
|
+
settings?: {
|
|
280
|
+
width?: number;
|
|
281
|
+
height?: number;
|
|
282
|
+
fps?: number;
|
|
283
|
+
duration?: number;
|
|
284
|
+
backgroundColor?: string;
|
|
285
|
+
format?: string;
|
|
286
|
+
videoCodec?: string;
|
|
287
|
+
bitrate?: number;
|
|
288
|
+
audio?: boolean;
|
|
289
|
+
audioCodec?: string;
|
|
290
|
+
audioSampleRate?: number;
|
|
291
|
+
metaDataTags?: Record<string, string>;
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Normalize a clip's JSON structure to ensure compatibility and migrate old property structures
|
|
296
|
+
*/
|
|
297
|
+
export declare function normalizeClipJSON(json: ClipJSON): ClipJSON;
|
|
298
|
+
export declare function normalizeClipStyleJSON(style: any, type: string): any;
|
|
299
|
+
/**
|
|
300
|
+
* Serialize a clip to JSON format
|
|
301
|
+
* @param clip The clip to serialize
|
|
302
|
+
* @param main Whether this is the main clip (for Compositor)
|
|
303
|
+
*/
|
|
304
|
+
export declare function clipToJSON(clip: IClip, main?: boolean): ClipJSON;
|
|
305
|
+
/**
|
|
306
|
+
* Deserialize JSON to a clip instance
|
|
307
|
+
* Uses fromObject static method if available (fabric.js pattern), otherwise falls back to manual construction
|
|
308
|
+
*/
|
|
309
|
+
export declare function jsonToClip(json: ClipJSON, context?: ClipContext): Promise<IClip>;
|
|
310
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quick concatenate multiple MP4 file streams, requires all MP4s to have consistent properties,
|
|
3
|
+
* properties include (but not limited to): audio/video codec format, resolution, sample rate
|
|
4
|
+
*
|
|
5
|
+
* @param streams An array of readable streams containing Uint8Array.
|
|
6
|
+
* @returns Returns a Promise that resolves to a readable stream containing merged MP4 data.
|
|
7
|
+
* @throws Will throw error if unable to generate file from streams.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const streams = [stream1, stream2, stream3];
|
|
11
|
+
* const resultStream = await fastConcatMP4(streams);
|
|
12
|
+
*/
|
|
13
|
+
export declare function fastConcatMP4(streams: ReadableStream<Uint8Array>[]): Promise<ReadableStream<Uint8Array>>;
|
|
14
|
+
/**
|
|
15
|
+
* Set correct duration value for fMP4 files generated
|
|
16
|
+
*/
|
|
17
|
+
export declare function fixFMP4Duration(stream: ReadableStream<Uint8Array>): Promise<ReadableStream<Uint8Array>>;
|
|
18
|
+
/**
|
|
19
|
+
* Video dubbing; mix MP4 with audio file, only re-encode audio, video track unchanged
|
|
20
|
+
* @param mp4Stream - MP4 stream
|
|
21
|
+
* @param audio - Audio information
|
|
22
|
+
* @param audio.stream - Audio data stream
|
|
23
|
+
* @param audio.volume - Audio volume
|
|
24
|
+
* @param audio.loop - When audio duration is less than video, whether to loop audio stream
|
|
25
|
+
* @returns Output mixed audio stream
|
|
26
|
+
*/
|
|
27
|
+
export declare function mixinMP4AndAudio(mp4Stream: ReadableStream<Uint8Array>, audio: {
|
|
28
|
+
stream: ReadableStream<Uint8Array>;
|
|
29
|
+
volume: number;
|
|
30
|
+
loop: boolean;
|
|
31
|
+
}): ReadableStream<Uint8Array<ArrayBufferLike>>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AudioTrackOpts, MP4File, MP4Info, MP4Sample, VideoTrackOpts } from 'wrapbox';
|
|
2
|
+
import { file } from 'opfs-tools';
|
|
3
|
+
interface ExtractedConfig {
|
|
4
|
+
videoTrackConf?: VideoTrackOpts;
|
|
5
|
+
videoDecoderConf?: VideoDecoderConfig;
|
|
6
|
+
audioTrackConf?: AudioTrackOpts;
|
|
7
|
+
audioDecoderConf?: AudioDecoderConfig;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Extracts video and audio configurations from an MP4 file.
|
|
11
|
+
*/
|
|
12
|
+
export declare function extractFileConfig(file: MP4File, info: MP4Info): ExtractedConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Quick parse mp4 file, prioritizing header parsing to save memory.
|
|
15
|
+
*/
|
|
16
|
+
export declare function quickParseMP4File(reader: Awaited<ReturnType<ReturnType<typeof file>["createReader"]>>, onReady: (data: {
|
|
17
|
+
mp4boxFile: MP4File;
|
|
18
|
+
info: MP4Info;
|
|
19
|
+
}) => void, onSamples: (id: number, sampleType: "video" | "audio", samples: MP4Sample[]) => void): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Parses transformation matrix to extract scale, rotation, and translation.
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseMatrix(matrix?: Int32Array): {
|
|
24
|
+
scaleX?: undefined;
|
|
25
|
+
scaleY?: undefined;
|
|
26
|
+
rotationRad?: undefined;
|
|
27
|
+
rotationDeg?: undefined;
|
|
28
|
+
translateX?: undefined;
|
|
29
|
+
translateY?: undefined;
|
|
30
|
+
perspective?: undefined;
|
|
31
|
+
} | {
|
|
32
|
+
scaleX: number;
|
|
33
|
+
scaleY: number;
|
|
34
|
+
rotationRad: number;
|
|
35
|
+
rotationDeg: number;
|
|
36
|
+
translateX: number;
|
|
37
|
+
translateY: number;
|
|
38
|
+
perspective: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Creates a function to rotate VideoFrames using Canvas.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createVFRotater(width: number, height: number, rotationDeg: number): (vf: VideoFrame | null) => VideoFrame | null;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { MP4File, MP4Info, MP4Sample } from 'wrapbox';
|
|
2
|
+
export type TransformChunk = {
|
|
3
|
+
chunkType: "ready";
|
|
4
|
+
data: {
|
|
5
|
+
info: MP4Info;
|
|
6
|
+
file: MP4File;
|
|
7
|
+
};
|
|
8
|
+
} | {
|
|
9
|
+
chunkType: "samples";
|
|
10
|
+
data: {
|
|
11
|
+
id: number;
|
|
12
|
+
type: "video" | "audio";
|
|
13
|
+
samples: MP4Sample[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Transforms a raw byte stream into an MP4Sample stream using mp4box.js.
|
|
18
|
+
*/
|
|
19
|
+
export declare class SampleTransform {
|
|
20
|
+
readonly readable: ReadableStream<TransformChunk>;
|
|
21
|
+
readonly writable: WritableStream<Uint8Array>;
|
|
22
|
+
private inputBufOffset;
|
|
23
|
+
private isStreamCancelled;
|
|
24
|
+
constructor();
|
|
25
|
+
private initMP4Box;
|
|
26
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { default as EventEmitter } from '../event-emitter';
|
|
2
|
+
import { IAnimation, AnimationTransform } from '../animation';
|
|
3
|
+
import { IChromaKeyOpts } from '../clips/iclip';
|
|
4
|
+
import { ColorAdjustment } from '../utils/color-adjustment';
|
|
5
|
+
import { IClipTiming } from '@agrhub/core';
|
|
6
|
+
type IRectBaseProps = any;
|
|
7
|
+
interface IAnimationOptions {
|
|
8
|
+
duration: number;
|
|
9
|
+
delay?: number;
|
|
10
|
+
iterCount?: number;
|
|
11
|
+
}
|
|
12
|
+
type TAnimateProps = IRectBaseProps & {
|
|
13
|
+
opacity: number;
|
|
14
|
+
};
|
|
15
|
+
export type TAnimationKeyFrame = Array<[number, Partial<TAnimateProps>]>;
|
|
16
|
+
type TKeyFrameOptions = Partial<Record<`${number}%` | "from" | "to", Partial<TAnimateProps>>>;
|
|
17
|
+
export interface BaseSpriteEvents {
|
|
18
|
+
propsChange: Partial<{
|
|
19
|
+
left: number;
|
|
20
|
+
top: number;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
angle: number;
|
|
24
|
+
zIndex: number;
|
|
25
|
+
opacity: number;
|
|
26
|
+
volume: number;
|
|
27
|
+
animations: IAnimation[];
|
|
28
|
+
locked: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
[key: symbol]: any;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Sprite base class
|
|
35
|
+
*
|
|
36
|
+
* @see {@link OffscreenSprite}
|
|
37
|
+
*/
|
|
38
|
+
export declare abstract class BaseSprite<T extends BaseSpriteEvents = BaseSpriteEvents> extends EventEmitter<T> {
|
|
39
|
+
/**
|
|
40
|
+
* Unique identifier for the sprite/clip
|
|
41
|
+
*/
|
|
42
|
+
id: string;
|
|
43
|
+
/**
|
|
44
|
+
* Name of the sprite/clip
|
|
45
|
+
*/
|
|
46
|
+
name: string;
|
|
47
|
+
/**
|
|
48
|
+
* Nested timing property group (Phase 1 Refactoring)
|
|
49
|
+
*/
|
|
50
|
+
timing: IClipTiming;
|
|
51
|
+
/**
|
|
52
|
+
* Control display time range of clips, commonly used in editing scenario timeline (track) module
|
|
53
|
+
* from: start time offset in microseconds
|
|
54
|
+
* to: end time (from + duration) in microseconds
|
|
55
|
+
*/
|
|
56
|
+
get display(): {
|
|
57
|
+
from: number;
|
|
58
|
+
to: number;
|
|
59
|
+
};
|
|
60
|
+
set display(v: {
|
|
61
|
+
from: number;
|
|
62
|
+
to: number;
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Duration of the clip in microseconds
|
|
66
|
+
* Cannot exceed the duration of the referenced {@link IClip}
|
|
67
|
+
*/
|
|
68
|
+
get duration(): number;
|
|
69
|
+
set duration(v: number);
|
|
70
|
+
/**
|
|
71
|
+
* Playback rate of current clip, 1 means normal playback
|
|
72
|
+
* **Note**
|
|
73
|
+
* 1. When setting playbackRate, duration must be actively corrected
|
|
74
|
+
* 2. Audio uses the simplest interpolation algorithm to change rate, so changing rate will cause pitch variation, for custom algorithm please use {@link Video.tickInterceptor} to implement
|
|
75
|
+
*/
|
|
76
|
+
get playbackRate(): number;
|
|
77
|
+
set playbackRate(v: number);
|
|
78
|
+
/**
|
|
79
|
+
* Trim range of the source media in microseconds
|
|
80
|
+
* from: start time in microseconds
|
|
81
|
+
* to: end time in microseconds
|
|
82
|
+
*/
|
|
83
|
+
get trim(): {
|
|
84
|
+
from: number;
|
|
85
|
+
to: number;
|
|
86
|
+
};
|
|
87
|
+
set trim(v: {
|
|
88
|
+
from: number;
|
|
89
|
+
to: number;
|
|
90
|
+
});
|
|
91
|
+
constructor();
|
|
92
|
+
protected _left: number;
|
|
93
|
+
/**
|
|
94
|
+
* Left position (x coordinate)
|
|
95
|
+
*/
|
|
96
|
+
get left(): number;
|
|
97
|
+
set left(v: number);
|
|
98
|
+
protected _top: number;
|
|
99
|
+
/**
|
|
100
|
+
* Top position (y coordinate)
|
|
101
|
+
*/
|
|
102
|
+
get top(): number;
|
|
103
|
+
set top(v: number);
|
|
104
|
+
protected _width: number;
|
|
105
|
+
/**
|
|
106
|
+
* Width
|
|
107
|
+
*/
|
|
108
|
+
get width(): number;
|
|
109
|
+
set width(v: number);
|
|
110
|
+
protected _height: number;
|
|
111
|
+
/**
|
|
112
|
+
* Height
|
|
113
|
+
*/
|
|
114
|
+
get height(): number;
|
|
115
|
+
set height(v: number);
|
|
116
|
+
private _angle;
|
|
117
|
+
/**
|
|
118
|
+
* Rotation angle in degrees
|
|
119
|
+
*/
|
|
120
|
+
get angle(): number;
|
|
121
|
+
set angle(v: number);
|
|
122
|
+
/**
|
|
123
|
+
* Center point calculated from position and dimensions
|
|
124
|
+
*/
|
|
125
|
+
get center(): {
|
|
126
|
+
x: number;
|
|
127
|
+
y: number;
|
|
128
|
+
};
|
|
129
|
+
private _zIndex;
|
|
130
|
+
get zIndex(): number;
|
|
131
|
+
/**
|
|
132
|
+
* Control layering relationship between clips, clips with smaller zIndex will be occluded
|
|
133
|
+
*/
|
|
134
|
+
set zIndex(v: number);
|
|
135
|
+
private _opacity;
|
|
136
|
+
/**
|
|
137
|
+
* Opacity (0.0 to 1.0)
|
|
138
|
+
*/
|
|
139
|
+
get opacity(): number;
|
|
140
|
+
set opacity(v: number);
|
|
141
|
+
private _volume;
|
|
142
|
+
/**
|
|
143
|
+
* Audio volume level (0.0 to 1.0)
|
|
144
|
+
*/
|
|
145
|
+
get volume(): number;
|
|
146
|
+
set volume(v: number);
|
|
147
|
+
private _locked;
|
|
148
|
+
/**
|
|
149
|
+
* Whether the sprite is locked (preventing interactions)
|
|
150
|
+
*/
|
|
151
|
+
get locked(): boolean;
|
|
152
|
+
set locked(v: boolean);
|
|
153
|
+
/**
|
|
154
|
+
* Flip clip horizontally or vertically
|
|
155
|
+
*/
|
|
156
|
+
flip: {
|
|
157
|
+
x: boolean;
|
|
158
|
+
y: boolean;
|
|
159
|
+
} | null;
|
|
160
|
+
effects: Array<{
|
|
161
|
+
id: string;
|
|
162
|
+
key: string;
|
|
163
|
+
startTime: number;
|
|
164
|
+
duration: number;
|
|
165
|
+
targets?: number[];
|
|
166
|
+
}>;
|
|
167
|
+
/**
|
|
168
|
+
* Chroma key settings (green screen removal)
|
|
169
|
+
*/
|
|
170
|
+
chromaKey?: IChromaKeyOpts;
|
|
171
|
+
colorAdjustment?: ColorAdjustment;
|
|
172
|
+
/**
|
|
173
|
+
* Styling properties (e.g., stroke, dropShadow, borderRadius)
|
|
174
|
+
* This is a generic object to hold visual styles across different clip types
|
|
175
|
+
*/
|
|
176
|
+
protected _style: any;
|
|
177
|
+
get style(): any;
|
|
178
|
+
set style(v: any);
|
|
179
|
+
private animatKeyFrame;
|
|
180
|
+
private animatOptions;
|
|
181
|
+
private _animations;
|
|
182
|
+
/**
|
|
183
|
+
* List of active animations.
|
|
184
|
+
* When setting this property, raw objects are automatically converted to IAnimation instances.
|
|
185
|
+
*/
|
|
186
|
+
get animations(): IAnimation[];
|
|
187
|
+
set animations(v: IAnimation[]);
|
|
188
|
+
/**
|
|
189
|
+
* Current transform offsets/multipliers from animations
|
|
190
|
+
* Resets every frame in animate()
|
|
191
|
+
*/
|
|
192
|
+
renderTransform: AnimationTransform;
|
|
193
|
+
/**
|
|
194
|
+
* @see {@link IClip.ready}
|
|
195
|
+
* For clips, this should be Promise<IClipMeta>, but for BaseSprite it's just Promise<void>
|
|
196
|
+
*/
|
|
197
|
+
protected _render(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
198
|
+
/**
|
|
199
|
+
* Add animation to clip, usage reference CSS animation
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* sprite.setAnimation(
|
|
203
|
+
* {
|
|
204
|
+
* '0%': { x: 0, y: 0 },
|
|
205
|
+
* '25%': { x: 1200, y: 680 },
|
|
206
|
+
* '50%': { x: 1200, y: 0 },
|
|
207
|
+
* '75%': { x: 0, y: 680 },
|
|
208
|
+
* '100%': { x: 0, y: 0 },
|
|
209
|
+
* },
|
|
210
|
+
* { duration: 4e6, iterCount: 1 },
|
|
211
|
+
* );
|
|
212
|
+
*
|
|
213
|
+
*/
|
|
214
|
+
setAnimation(keyFrame: TKeyFrameOptions, options: IAnimationOptions): void;
|
|
215
|
+
/**
|
|
216
|
+
* If current sprite has animation set, set sprite's animation properties to state at specified time
|
|
217
|
+
*/
|
|
218
|
+
animate(time: number, target?: any): void;
|
|
219
|
+
/**
|
|
220
|
+
* Add a modular animation to the clip
|
|
221
|
+
* @param name Preset name or 'keyframes'
|
|
222
|
+
* @param opts Animation options (duration, delay, etc.)
|
|
223
|
+
* @param params Preset-specific parameters or KeyframeData
|
|
224
|
+
*/
|
|
225
|
+
addAnimation(name: string, options: any, params?: any): string;
|
|
226
|
+
/**
|
|
227
|
+
* Remove an animation by ID
|
|
228
|
+
*/
|
|
229
|
+
removeAnimation(id: string): void;
|
|
230
|
+
/**
|
|
231
|
+
* Clear all modular animations
|
|
232
|
+
*/
|
|
233
|
+
clearAnimations(): void;
|
|
234
|
+
/**
|
|
235
|
+
* Update an existing animation by ID
|
|
236
|
+
* @param id Animation ID to update
|
|
237
|
+
* @param type Animation type (preset name or 'keyframes')
|
|
238
|
+
* @param opts Animation options
|
|
239
|
+
* @param params Preset-specific parameters or KeyframeData
|
|
240
|
+
*/
|
|
241
|
+
updateAnimation(id: string, type: string, options: any, params?: any): void;
|
|
242
|
+
/**
|
|
243
|
+
* Copy current sprite's properties to target
|
|
244
|
+
*
|
|
245
|
+
* Used for cloning or copying state between {@link OffscreenSprite} instances
|
|
246
|
+
*/
|
|
247
|
+
copyStateTo<T extends BaseSprite>(target: T): void;
|
|
248
|
+
/**
|
|
249
|
+
* Update multiple properties at once
|
|
250
|
+
*/
|
|
251
|
+
update(updates: Partial<this>): void;
|
|
252
|
+
protected destroy(): void;
|
|
253
|
+
}
|
|
254
|
+
export declare function linearTimeFn(time: number, keyFrame: TAnimationKeyFrame, options: Required<IAnimationOptions>): Partial<TAnimateProps>;
|
|
255
|
+
export {};
|