@designcombo/video 0.1.9 → 0.1.11

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.
Files changed (40) hide show
  1. package/dist/{SharedSystems-j_zPWvy9.js → SharedSystems-D0OoaJby.js} +1 -1
  2. package/dist/{WebGLRenderer-CWO7EcYW.js → WebGLRenderer-CaF4ncl9.js} +2 -2
  3. package/dist/{WebGPURenderer-EnfWRJnb.js → WebGPURenderer-CltimhzK.js} +2 -2
  4. package/dist/{browserAll-C1JdPbX8.js → browserAll-tgth3L-L.js} +2 -2
  5. package/dist/clips/audio-clip.d.ts +0 -1
  6. package/dist/clips/base-clip.d.ts +19 -0
  7. package/dist/clips/caption-clip.d.ts +41 -0
  8. package/dist/clips/iclip.d.ts +16 -2
  9. package/dist/clips/image-clip.d.ts +0 -22
  10. package/dist/clips/index.d.ts +1 -0
  11. package/dist/clips/placeholder-clip.d.ts +15 -0
  12. package/dist/clips/text-clip.d.ts +4 -0
  13. package/dist/clips/video-clip.d.ts +3 -13
  14. package/dist/compositor.d.ts +5 -9
  15. package/dist/event-emitter.d.ts +10 -2
  16. package/dist/{index-B0AsXir7.js → index-DWKp2xEE.js} +19027 -14754
  17. package/dist/index.d.ts +2 -2
  18. package/dist/index.es.js +17 -16
  19. package/dist/index.umd.js +203 -201
  20. package/dist/json-serialization.d.ts +7 -1
  21. package/dist/mp4-utils/index.d.ts +1 -1
  22. package/dist/mp4-utils/mp4box-utils.d.ts +15 -7
  23. package/dist/mp4-utils/sample-transform.d.ts +20 -17
  24. package/dist/sprite/base-sprite.d.ts +0 -1
  25. package/dist/studio/timeline-model.d.ts +26 -3
  26. package/dist/studio.d.ts +27 -4
  27. package/dist/utils/asset-manager.d.ts +6 -0
  28. package/dist/utils/log.d.ts +27 -0
  29. package/dist/utils/stream-utils.d.ts +9 -0
  30. package/dist/utils/video.d.ts +0 -2
  31. package/dist/utils/worker-timer.d.ts +1 -0
  32. package/dist/{webworkerAll-BtiyFllu.js → webworkerAll-CZg7nv2I.js} +1 -1
  33. package/package.json +5 -5
  34. package/dist/internal-utils/event-tool.d.ts +0 -50
  35. package/dist/internal-utils/index.d.ts +0 -14
  36. package/dist/internal-utils/log.d.ts +0 -34
  37. package/dist/internal-utils/meta-box.d.ts +0 -1
  38. package/dist/internal-utils/recodemux.d.ts +0 -65
  39. package/dist/internal-utils/stream-utils.d.ts +0 -43
  40. package/dist/internal-utils/worker-timer.d.ts +0 -8
@@ -1,4 +1,4 @@
1
- import { F as Ie, u as Ee, l as se, M as v, G as De, v as Oe, S as Fe, x as ae, E as u, e as D, y as S, z as Le, H as O, I as b, R as F, J as ne, K as He, t as m, b as f, i as B, w as L, L as K, N as We, c as Y, B as y, j as U, O as ze, Q as C, k as M, V as w, W as Ve, a as Ne, X as ie, Y as oe, Z as le, _ as ue, C as P, $ as je, a0 as A, a1 as J, D as H, a2 as $e, a3 as qe, P as Ke, d as Ye, T as X, a4 as Q, a5 as Je, a6 as Xe, a7 as Qe } from "./index-B0AsXir7.js";
1
+ import { F as Ie, u as Ee, l as se, M as v, G as De, v as Oe, S as Fe, x as ae, E as u, e as D, y as S, z as Le, H as O, I as b, R as F, J as ne, K as He, t as m, b as f, i as B, w as L, L as K, N as We, c as Y, B as y, j as U, O as ze, Q as C, k as M, V as w, W as Ve, a as Ne, X as ie, Y as oe, Z as le, _ as ue, C as P, $ as je, a0 as A, a1 as J, D as H, a2 as $e, a3 as qe, P as Ke, d as Ye, T as X, a4 as Q, a5 as Je, a6 as Xe, a7 as Qe } from "./index-DWKp2xEE.js";
2
2
  import { B as de, c as Ze } from "./colorToUniform-C2jGzNe1.js";
3
3
  var et = `in vec2 vMaskCoord;
4
4
  in vec2 vTextureCoord;
@@ -1,6 +1,6 @@
1
- import { S as G, E as d, B as v, w as m, D as S, L as j, v as ve, s as U, t as b, a8 as Be, k as K, a9 as Ae, b as p, V as L, j as B, i as A, l as F, M as $, aa as z, ab as Ne, ac as ye, ad as Y, ae as Ce, A as De, R as Ie, e as T } from "./index-B0AsXir7.js";
1
+ import { S as G, E as d, B as v, w as m, D as S, L as j, v as ve, s as U, t as b, a8 as Be, k as K, a9 as Ae, b as p, V as L, j as B, i as A, l as F, M as $, aa as z, ab as Ne, ac as ye, ad as Y, ae as Ce, A as De, R as Ie, e as T } from "./index-DWKp2xEE.js";
2
2
  import { b as q } from "./colorToUniform-C2jGzNe1.js";
3
- import { e as Ge, G as Ue, c as Fe, b as Oe, U as Pe, R as Me, B as Z, d as N, f as Le, S as He, a as we } from "./SharedSystems-j_zPWvy9.js";
3
+ import { e as Ge, G as Ue, c as Fe, b as Oe, U as Pe, R as Me, B as Z, d as N, f as Le, S as He, a as we } from "./SharedSystems-D0OoaJby.js";
4
4
  class Q {
5
5
  constructor() {
6
6
  this._tempState = G.for2d(), this._didUploadHash = {};
@@ -1,6 +1,6 @@
1
- import { S as E, g as A, E as p, f as ae, D as S, b as C, B as T, c as ue, d as L, h as M, w as v, i as x, j as ce, k as de, l as k, m as w, M as D, n as H, o as he, p as pe, q as z, s as F, t as R, A as le, R as fe, e as B } from "./index-B0AsXir7.js";
1
+ import { S as E, g as A, E as p, f as ae, D as S, b as C, B as T, c as ue, d as L, h as M, w as v, i as x, j as ce, k as de, l as k, m as w, M as D, n as H, o as he, p as pe, q as z, s as F, t as R, A as le, R as fe, e as B } from "./index-DWKp2xEE.js";
2
2
  import { l as ge, a as me } from "./colorToUniform-C2jGzNe1.js";
3
- import { c as _e, u as be, U as xe, B as ye, G as Ge, e as Se, R as Be, t as Pe, S as Te, a as Ce } from "./SharedSystems-j_zPWvy9.js";
3
+ import { c as _e, u as be, U as xe, B as ye, G as Ge, e as Se, R as Be, t as Pe, S as Te, a as Ce } from "./SharedSystems-D0OoaJby.js";
4
4
  const y = E.for2d();
5
5
  class O {
6
6
  start(e, t, r) {
@@ -1,5 +1,5 @@
1
- import { T as M, U as Z, P as m, r as te, E as y, a as ie, w as g, e as P, C as V } from "./index-B0AsXir7.js";
2
- import "./webworkerAll-BtiyFllu.js";
1
+ import { T as M, U as Z, P as m, r as te, E as y, a as ie, w as g, e as P, C as V } from "./index-DWKp2xEE.js";
2
+ import "./webworkerAll-CZg7nv2I.js";
3
3
  class q {
4
4
  constructor(e) {
5
5
  this._lastTransform = "", this._observer = null, this._tickerAttached = !1, this.updateTranslation = () => {
@@ -79,7 +79,6 @@ export declare class AudioClip extends BaseClip implements IPlaybackCapable {
79
79
  * @param time Time when tick was called
80
80
  * @param tickRet Data returned by tick
81
81
  *
82
- * @see [Remove video green screen background](https://webav-tech.github.io/WebAV/demo/3_2-chromakey-video)
83
82
  */
84
83
  tickInterceptor: <T extends Awaited<ReturnType<AudioClip['tick']>>>(time: number, tickRet: T) => Promise<T>;
85
84
  private timestamp;
@@ -93,5 +93,24 @@ export declare abstract class BaseClip extends BaseSprite implements IClip {
93
93
  * Override in subclasses to customize handle visibility (e.g., TextClip)
94
94
  */
95
95
  getVisibleHandles(): Array<'tl' | 'tr' | 'bl' | 'br' | 'ml' | 'mr' | 'mt' | 'mb' | 'rot'>;
96
+ /**
97
+ * Scale clip to fit within the scene dimensions while maintaining aspect ratio
98
+ * @param sceneWidth Scene width
99
+ * @param sceneHeight Scene height
100
+ */
101
+ scaleToFit(sceneWidth: number, sceneHeight: number): Promise<void>;
102
+ /**
103
+ * Scale clip to fill the scene dimensions while maintaining aspect ratio
104
+ * May crop parts of the clip.
105
+ * @param sceneWidth Scene width
106
+ * @param sceneHeight Scene height
107
+ */
108
+ scaleToFill(sceneWidth: number, sceneHeight: number): Promise<void>;
109
+ /**
110
+ * Center the clip within the scene dimensions
111
+ * @param sceneWidth Scene width
112
+ * @param sceneHeight Scene height
113
+ */
114
+ centerInScene(sceneWidth: number, sceneHeight: number): void;
96
115
  destroy(): void;
97
116
  }
@@ -48,6 +48,7 @@ export interface ICaptionClipOpts {
48
48
  from: number;
49
49
  to: number;
50
50
  isKeyWord: boolean;
51
+ paragraphIndex?: number;
51
52
  }>;
52
53
  colors?: {
53
54
  appeared?: string;
@@ -71,6 +72,7 @@ export interface ICaptionClipOpts {
71
72
  from: number;
72
73
  to: number;
73
74
  isKeyWord: boolean;
75
+ paragraphIndex?: number;
74
76
  }>;
75
77
  /**
76
78
  * @deprecated Use caption.colors instead
@@ -151,6 +153,10 @@ export interface ICaptionClipOpts {
151
153
  * @default 'none'
152
154
  */
153
155
  textCase?: 'none' | 'uppercase' | 'lowercase' | 'title';
156
+ /**
157
+ * Media ID to which the captions were applied
158
+ */
159
+ mediaId?: string;
154
160
  }
155
161
  /**
156
162
  * Caption clip using Canvas 2D for rendering
@@ -182,6 +188,28 @@ export declare class CaptionClip extends BaseClip implements IClip {
182
188
  text: string;
183
189
  get style(): any;
184
190
  set style(v: any);
191
+ get fontFamily(): string;
192
+ set fontFamily(v: string);
193
+ get fontUrl(): string;
194
+ set fontUrl(v: string);
195
+ get fontSize(): number;
196
+ set fontSize(v: number);
197
+ get fontWeight(): string;
198
+ set fontWeight(v: string);
199
+ get fontStyle(): string;
200
+ set fontStyle(v: string);
201
+ get fill(): any;
202
+ set fill(v: any);
203
+ get align(): 'left' | 'center' | 'right';
204
+ set align(v: 'left' | 'center' | 'right');
205
+ get stroke(): any;
206
+ set stroke(v: any);
207
+ get strokeWidth(): number;
208
+ set strokeWidth(v: number);
209
+ get dropShadow(): any;
210
+ set dropShadow(v: any);
211
+ get caption(): any;
212
+ set caption(v: any);
185
213
  /**
186
214
  * Bottom offset from video bottom (hybrid JSON structure)
187
215
  */
@@ -195,6 +223,11 @@ export declare class CaptionClip extends BaseClip implements IClip {
195
223
  * Unique identifier for this clip instance
196
224
  */
197
225
  id: string;
226
+ /**
227
+ * Media ID of the source clip
228
+ */
229
+ get mediaId(): string | undefined;
230
+ set mediaId(v: string | undefined);
198
231
  /**
199
232
  * Array of effects to be applied to this clip
200
233
  * Each effect specifies key, startTime, duration, and optional targets
@@ -205,6 +238,14 @@ export declare class CaptionClip extends BaseClip implements IClip {
205
238
  startTime: number;
206
239
  duration: number;
207
240
  }>;
241
+ /**
242
+ * Words getter for the clip
243
+ */
244
+ get words(): any[];
245
+ /**
246
+ * Words setter that triggers re-render and ensures consistency
247
+ */
248
+ set words(v: any[]);
208
249
  private opts;
209
250
  private pixiTextContainer;
210
251
  private renderTexture;
@@ -19,10 +19,8 @@ export interface ITransitionInfo {
19
19
  *
20
20
  * Clips are abstractions of different data types, providing data to other modules
21
21
  *
22
- * WebAV provides built-in {@link VideoClip}, {@link AudioClip}, {@link ImageClip} and other common clips for providing data to {@link Compositor} and {@link AVCanvas}
23
22
  *
24
23
  * You only need to implement this interface to create custom clips, giving you maximum flexibility to generate video content such as animations and transition effects
25
- * @see [Custom Clip](https://webav-tech.github.io/WebAV/demo/2_6-custom-clip)
26
24
  *
27
25
  */
28
26
  export interface IClip extends Omit<BaseSprite, 'destroy' | 'ready'> {
@@ -32,6 +30,10 @@ export interface IClip extends Omit<BaseSprite, 'destroy' | 'ready'> {
32
30
  * Clip type (e.g., 'video', 'image', 'text', 'audio')
33
31
  */
34
32
  readonly type: string;
33
+ /**
34
+ * Source URL or identifier for this clip
35
+ */
36
+ src: string;
35
37
  /**
36
38
  * Extract data from clip at specified time
37
39
  * @param time Time in microseconds
@@ -97,6 +99,18 @@ export interface IClip extends Omit<BaseSprite, 'destroy' | 'ready'> {
97
99
  * @returns Array of handle kinds that should be visible
98
100
  */
99
101
  getVisibleHandles?: () => Array<'tl' | 'tr' | 'bl' | 'br' | 'ml' | 'mr' | 'mt' | 'mb' | 'rot'>;
102
+ /**
103
+ * Scale clip to fit within the scene dimensions while maintaining aspect ratio
104
+ */
105
+ scaleToFit(sceneWidth: number, sceneHeight: number): Promise<void>;
106
+ /**
107
+ * Scale clip to fill the scene dimensions while maintaining aspect ratio
108
+ */
109
+ scaleToFill(sceneWidth: number, sceneHeight: number): Promise<void>;
110
+ /**
111
+ * Center the clip within the scene dimensions
112
+ */
113
+ centerInScene(sceneWidth: number, sceneHeight: number): void;
100
114
  }
101
115
  /**
102
116
  * Optional interface for clips that support HTML media element playback
@@ -24,7 +24,6 @@ type AnimateImgType = 'avif' | 'webp' | 'png' | 'gif';
24
24
  * )
25
25
  * )
26
26
  *
27
- * @see [Video composition](https://webav-tech.github.io/WebAV/demo/2_1-concat-video)
28
27
  */
29
28
  export declare class ImageClip extends BaseClip implements IClip {
30
29
  readonly type = "Image";
@@ -112,26 +111,5 @@ export declare class ImageClip extends BaseClip implements IClip {
112
111
  * @returns Promise that resolves to an ImageClip instance
113
112
  */
114
113
  static fromObject(json: ClipJSON): Promise<ImageClip>;
115
- /**
116
- * Scale clip to fit within the scene dimensions while maintaining aspect ratio
117
- * Similar to fabric.js scaleToFit
118
- * @param sceneWidth Scene width
119
- * @param sceneHeight Scene height
120
- */
121
- scaleToFit(sceneWidth: number, sceneHeight: number): Promise<void>;
122
- /**
123
- * Scale clip to fill the scene dimensions while maintaining aspect ratio
124
- * May crop parts of the clip. Similar to fabric.js scaleToFill
125
- * @param sceneWidth Scene width
126
- * @param sceneHeight Scene height
127
- */
128
- scaleToFill(sceneWidth: number, sceneHeight: number): Promise<void>;
129
- /**
130
- * Center the clip within the scene dimensions
131
- * Similar to fabric.js center
132
- * @param sceneWidth Scene width
133
- * @param sceneHeight Scene height
134
- */
135
- centerInScene(sceneWidth: number, sceneHeight: number): void;
136
114
  }
137
115
  export {};
@@ -7,4 +7,5 @@ export { VideoClip } from './video-clip';
7
7
  export type { IMP4ClipOpts } from './video-clip';
8
8
  export * from './text-clip';
9
9
  export * from './effect-clip';
10
+ export * from './placeholder-clip';
10
11
  export * from './transition-clip';
@@ -0,0 +1,15 @@
1
+ import { BaseClip } from './base-clip';
2
+ import { IClipMeta } from './iclip';
3
+ export declare class PlaceholderClip extends BaseClip {
4
+ type: string;
5
+ meta: IClipMeta;
6
+ constructor(src: string, meta?: Partial<IClipMeta>, type?: string);
7
+ private placeholderFrame;
8
+ tick(time: number): Promise<{
9
+ video?: ImageBitmap | null;
10
+ audio?: Float32Array[];
11
+ state: 'done' | 'success';
12
+ }>;
13
+ clone(): Promise<this>;
14
+ split(time: number): Promise<[this, this]>;
15
+ }
@@ -23,6 +23,10 @@ export interface ITextClipOpts {
23
23
  * @default 'normal'
24
24
  */
25
25
  fontStyle?: string;
26
+ /**
27
+ * Font URL for custom fonts
28
+ */
29
+ fontUrl?: string;
26
30
  /**
27
31
  * Text color (hex string, color name, or gradient object)
28
32
  * @default '#ffffff'
@@ -1,4 +1,4 @@
1
- import { MP4Sample } from '@webav/mp4box.js';
1
+ import { MP4Sample } from 'wrapbox';
2
2
  import { file } from 'opfs-tools';
3
3
  import { BaseClip } from './base-clip';
4
4
  import { IClip, IPlaybackCapable } from './iclip';
@@ -16,7 +16,7 @@ export interface IMP4ClipOpts {
16
16
  volume: number;
17
17
  };
18
18
  /**
19
- * 不安全,随时可能废弃
19
+ * Unsafe, may be deprecated at any time
20
20
  */
21
21
  __unsafe_hardwareAcceleration__?: HardwarePreference;
22
22
  }
@@ -47,15 +47,6 @@ type ExtMP4Sample = Omit<MP4Sample, 'data'> & {
47
47
  * },
48
48
  * });
49
49
  *
50
- * @example
51
- * // Direct constructor (for advanced use)
52
- * new VideoClip((await fetch('<mp4 url>')).body)
53
- * new VideoClip(mp4File.stream())
54
- *
55
- * @see {@link Compositor}
56
- * @see [AVCanvas](../../av-canvas/classes/AVCanvas.html)
57
- *
58
- * @see [Decode and play video](https://webav-tech.github.io/WebAV/demo/1_1-decode-video)
59
50
  */
60
51
  export declare class VideoClip extends BaseClip implements IPlaybackCapable {
61
52
  readonly type = "Video";
@@ -132,8 +123,7 @@ export declare class VideoClip extends BaseClip implements IPlaybackCapable {
132
123
  * @param time Time when tick was called
133
124
  * @param tickRet Data returned by tick
134
125
  *
135
- * @see [Remove video green screen background](https://webav-tech.github.io/WebAV/demo/3_2-chromakey-video)
136
- */
126
+ * */
137
127
  tickInterceptor: <T extends Awaited<ReturnType<VideoClip['tick']>>>(time: number, tickRet: T) => Promise<T>;
138
128
  /**
139
129
  * Get image frame and audio data at specified time
@@ -1,4 +1,5 @@
1
1
  import { IClip } from './clips';
2
+ import { default as EventEmitter } from './event-emitter';
2
3
  import { ProjectJSON } from './json-serialization';
3
4
  export interface ICompositorOpts {
4
5
  width?: number;
@@ -22,9 +23,6 @@ export interface ICompositorOpts {
22
23
  }
23
24
  /**
24
25
  * Video compositor that can add multiple {@link OffscreenSprite} instances,
25
- * compositing them based on position, z-index, time offset, etc., into an output video file
26
- * @see [Video Composition](https://webav-tech.github.io/WebAV/demo/2_1-concat-video)
27
- * @see [Video Audio Mixing](https://webav-tech.github.io/WebAV/demo/2_2-video-add-audio)
28
26
  * @example
29
27
  * const spr1 = new OffscreenSprite(
30
28
  * new VideoClip((await fetch('<mp4 url>')).body),
@@ -40,7 +38,10 @@ export interface ICompositorOpts {
40
38
  * com.output(); // => ReadableStream
41
39
  *
42
40
  */
43
- export declare class Compositor {
41
+ export declare class Compositor extends EventEmitter<{
42
+ OutputProgress: number;
43
+ error: Error;
44
+ }> {
44
45
  /**
45
46
  * Check compatibility with the current environment
46
47
  * @param args.videoCodec Specify video codec, default avc1.42E032
@@ -62,11 +63,6 @@ export declare class Compositor {
62
63
  private stopOutput;
63
64
  private opts;
64
65
  private hasVideoTrack;
65
- private evtTool;
66
- on: <Type extends "error" | "OutputProgress">(type: Type, listener: {
67
- OutputProgress: (progress: number) => void;
68
- error: (err: Error) => void;
69
- }[Type]) => (() => void);
70
66
  /**
71
67
  * Create a compositor instance based on configuration
72
68
  * @param opts ICompositorOpts
@@ -22,9 +22,17 @@ export default class EventEmitter<Events extends Record<EventType, unknown>> imp
22
22
  * Register an event handler for the given type.
23
23
  * @param {string|symbol} type Type of event to listen for, or `'*'` for all events
24
24
  * @param {Function} handler Function to call in response to given event
25
+ * @returns {Function} A function to unregister the handler
25
26
  */
26
- on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void;
27
- on(type: '*', handler: WildcardHandler<Events>): void;
27
+ on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): () => void;
28
+ on(type: '*', handler: WildcardHandler<Events>): () => void;
29
+ /**
30
+ * Register a one-time event handler for the given type.
31
+ * @param {string|symbol} type Type of event to listen for
32
+ * @param {Function} handler Function to call in response to given event
33
+ * @returns {Function} A function to unregister the handler
34
+ */
35
+ once<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): () => void;
28
36
  /**
29
37
  * Remove an event handler for the given type.
30
38
  * If `handler` is omitted, all handlers of the given type are removed.