@designcombo/video 0.0.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.
- package/LICENSE +63 -0
- package/dist/SharedSystems-BSw9neqH.js +2691 -0
- package/dist/WebGLRenderer-BrabW-VK.js +2639 -0
- package/dist/WebGPURenderer-BKwBKkzk.js +1655 -0
- package/dist/browserAll-C7HVZtqZ.js +1876 -0
- package/dist/clips/audio-clip.d.ts +132 -0
- package/dist/clips/base-clip.d.ts +86 -0
- package/dist/clips/caption-clip.d.ts +257 -0
- package/dist/clips/iclip.d.ts +120 -0
- package/dist/clips/image-clip.d.ts +110 -0
- package/dist/clips/index.d.ts +8 -0
- package/dist/clips/text-clip.d.ts +192 -0
- package/dist/clips/video-clip.d.ts +200 -0
- package/dist/colorToUniform-Du0ROyNd.js +274 -0
- package/dist/compositor.d.ts +111 -0
- package/dist/index-CjzowIhV.js +28270 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.es.js +20 -0
- package/dist/index.umd.js +1295 -0
- package/dist/internal-utils/event-tool.d.ts +50 -0
- package/dist/internal-utils/index.d.ts +14 -0
- package/dist/internal-utils/log.d.ts +34 -0
- package/dist/internal-utils/meta-box.d.ts +1 -0
- package/dist/internal-utils/recodemux.d.ts +65 -0
- package/dist/internal-utils/stream-utils.d.ts +43 -0
- package/dist/internal-utils/worker-timer.d.ts +8 -0
- package/dist/json-serialization.d.ts +142 -0
- package/dist/mp4-utils/index.d.ts +31 -0
- package/dist/mp4-utils/mp4box-utils.d.ts +36 -0
- package/dist/mp4-utils/sample-transform.d.ts +23 -0
- package/dist/sprite/base-sprite.d.ts +147 -0
- package/dist/sprite/pixi-sprite-renderer.d.ts +48 -0
- package/dist/studio.d.ts +142 -0
- package/dist/transfomer/parts/handle.d.ts +17 -0
- package/dist/transfomer/parts/wireframe.d.ts +5 -0
- package/dist/transfomer/transformer.d.ts +21 -0
- package/dist/utils/audio.d.ts +82 -0
- package/dist/utils/chromakey.d.ts +24 -0
- package/dist/utils/color.d.ts +4 -0
- package/dist/utils/common.d.ts +7 -0
- package/dist/utils/dom.d.ts +48 -0
- package/dist/utils/fonts.d.ts +16 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/srt-parser.d.ts +15 -0
- package/dist/utils/video.d.ts +18 -0
- package/dist/webworkerAll-DsE6HIYE.js +2497 -0
- package/package.json +53 -0
package/dist/studio.d.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { IClip } from './clips/iclip';
|
|
2
|
+
import { ProjectJSON } from './json-serialization';
|
|
3
|
+
export interface IStudioOpts {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
fps?: number;
|
|
7
|
+
bgColor?: string;
|
|
8
|
+
canvas?: HTMLCanvasElement;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Interactive preview studio for clips with playback controls
|
|
12
|
+
* Useful for previewing clips before rendering with Compositor
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const studio = new Studio({
|
|
16
|
+
* width: 1280,
|
|
17
|
+
* height: 720,
|
|
18
|
+
* fps: 30,
|
|
19
|
+
* bgColor: '#000'
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* await studio.addClip(spr1);
|
|
23
|
+
* await studio.addClip(spr2);
|
|
24
|
+
* studio.play();
|
|
25
|
+
*/
|
|
26
|
+
export declare class Studio {
|
|
27
|
+
private pixiApp;
|
|
28
|
+
private clips;
|
|
29
|
+
private spriteRenderers;
|
|
30
|
+
private activeTransformer;
|
|
31
|
+
private selectedClips;
|
|
32
|
+
private interactiveClips;
|
|
33
|
+
private playbackElements;
|
|
34
|
+
private videoSprites;
|
|
35
|
+
private isPlaying;
|
|
36
|
+
private currentTime;
|
|
37
|
+
private playStartTime;
|
|
38
|
+
private playStartTimestamp;
|
|
39
|
+
private rafId;
|
|
40
|
+
private maxDuration;
|
|
41
|
+
private opts;
|
|
42
|
+
private destroyed;
|
|
43
|
+
/**
|
|
44
|
+
* Convert hex color string to number
|
|
45
|
+
*/
|
|
46
|
+
private hexToNumber;
|
|
47
|
+
/**
|
|
48
|
+
* Create a new Studio instance
|
|
49
|
+
*/
|
|
50
|
+
constructor(opts: IStudioOpts);
|
|
51
|
+
private initPixiApp;
|
|
52
|
+
/**
|
|
53
|
+
* Get the canvas element (creates one if not provided)
|
|
54
|
+
*/
|
|
55
|
+
getCanvas(): HTMLCanvasElement;
|
|
56
|
+
/**
|
|
57
|
+
* Add a clip to the studio
|
|
58
|
+
* @param clip The clip to add
|
|
59
|
+
* @param audioSource Optional audio source (URL, File, or Blob) for AudioClip playback
|
|
60
|
+
*/
|
|
61
|
+
addClip(clip: IClip, audioSource?: string | File | Blob): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Setup sprite interactivity for click selection
|
|
64
|
+
*/
|
|
65
|
+
private setupSpriteInteractivity;
|
|
66
|
+
/**
|
|
67
|
+
* Setup playback element for a clip (if it supports playback)
|
|
68
|
+
*/
|
|
69
|
+
private setupPlaybackForClip;
|
|
70
|
+
private isPlaybackCapable;
|
|
71
|
+
/**
|
|
72
|
+
* Remove a clip from the studio
|
|
73
|
+
*/
|
|
74
|
+
removeClip(clip: IClip): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Clear all clips from the studio
|
|
77
|
+
*/
|
|
78
|
+
clear(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Start playback
|
|
81
|
+
*/
|
|
82
|
+
play(): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Pause playback
|
|
85
|
+
*/
|
|
86
|
+
pause(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Stop playback and reset to start
|
|
89
|
+
*/
|
|
90
|
+
stop(): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Seek to a specific time (in microseconds)
|
|
93
|
+
*/
|
|
94
|
+
seek(time: number): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Get current playback time (in microseconds)
|
|
97
|
+
*/
|
|
98
|
+
getCurrentTime(): number;
|
|
99
|
+
/**
|
|
100
|
+
* Get maximum duration (in microseconds)
|
|
101
|
+
* Returns 0 if duration is invalid (Infinity, NaN, or <= 0)
|
|
102
|
+
*/
|
|
103
|
+
getMaxDuration(): number;
|
|
104
|
+
/**
|
|
105
|
+
* Check if currently playing
|
|
106
|
+
*/
|
|
107
|
+
getIsPlaying(): boolean;
|
|
108
|
+
private renderLoop;
|
|
109
|
+
private updateFrame;
|
|
110
|
+
private recalculateMaxDuration;
|
|
111
|
+
/**
|
|
112
|
+
* Destroy the studio and clean up resources
|
|
113
|
+
*/
|
|
114
|
+
destroy(): void;
|
|
115
|
+
/**
|
|
116
|
+
* Select a clip and show transform controls
|
|
117
|
+
*/
|
|
118
|
+
selectClip(clip: IClip, addToSelection?: boolean): void;
|
|
119
|
+
/**
|
|
120
|
+
* Create transformer for currently selected clips
|
|
121
|
+
*/
|
|
122
|
+
private createTransformer;
|
|
123
|
+
/**
|
|
124
|
+
* Sync sprite transforms back to clip properties for all selected clips
|
|
125
|
+
* This ensures clip properties are always up-to-date during transformations
|
|
126
|
+
*/
|
|
127
|
+
private syncSelectedClipsTransforms;
|
|
128
|
+
/**
|
|
129
|
+
* Deselect the current clip and hide transform controls
|
|
130
|
+
*/
|
|
131
|
+
deselectClip(): void;
|
|
132
|
+
/**
|
|
133
|
+
* Export current studio state to JSON
|
|
134
|
+
* @param sourceUrlMap Optional map of clips to their source URLs (required for proper serialization)
|
|
135
|
+
*/
|
|
136
|
+
exportToJSON(): ProjectJSON;
|
|
137
|
+
/**
|
|
138
|
+
* Load clips from JSON
|
|
139
|
+
* @param json The JSON project data
|
|
140
|
+
*/
|
|
141
|
+
loadFromJSON(json: ProjectJSON): Promise<void>;
|
|
142
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Graphics, Point } from 'pixi.js';
|
|
2
|
+
export type Side = 'ml' | 'mr' | 'mt' | 'mb';
|
|
3
|
+
type Corner = 'tl' | 'tr' | 'bl' | 'br' | 'rot';
|
|
4
|
+
export type HandleKind = Corner | Side;
|
|
5
|
+
interface Callbacks {
|
|
6
|
+
beginDrag: (handle: HandleKind, start: Point) => void;
|
|
7
|
+
updateDrag: (handle: HandleKind, pos: Point) => void;
|
|
8
|
+
endDrag: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare class Handle extends Graphics {
|
|
11
|
+
#private;
|
|
12
|
+
private handle;
|
|
13
|
+
cursor: string;
|
|
14
|
+
private callbacks;
|
|
15
|
+
constructor(handle: HandleKind, cursor: string, callbacks: Callbacks);
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Container, Point } from 'pixi.js';
|
|
2
|
+
import { Wireframe } from './parts/wireframe';
|
|
3
|
+
import { HandleKind } from './parts/handle';
|
|
4
|
+
export declare class Transformer extends Container {
|
|
5
|
+
#private;
|
|
6
|
+
group: Container[];
|
|
7
|
+
wireframe: Wireframe;
|
|
8
|
+
isDragging: boolean;
|
|
9
|
+
lastPointer: Point;
|
|
10
|
+
activeHandle: HandleKind | null;
|
|
11
|
+
opts: {
|
|
12
|
+
group: Container[];
|
|
13
|
+
centeredScaling?: boolean;
|
|
14
|
+
clip?: any;
|
|
15
|
+
};
|
|
16
|
+
constructor(opts: {
|
|
17
|
+
group: Container[];
|
|
18
|
+
centeredScaling?: boolean;
|
|
19
|
+
clip?: any;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Concatenate multiple Float32Arrays, commonly used for merging PCM data
|
|
3
|
+
*/
|
|
4
|
+
export declare function concatFloat32Array(buffers: Float32Array[]): Float32Array;
|
|
5
|
+
/**
|
|
6
|
+
* Merge small PCM fragments into a large fragment
|
|
7
|
+
* @param fragments Small PCM fragments, where each element is raw PCM data from different channels
|
|
8
|
+
*/
|
|
9
|
+
export declare function concatPCMFragments(fragments: Float32Array[][]): Float32Array[];
|
|
10
|
+
/**
|
|
11
|
+
* Utility function to extract PCM data from AudioData
|
|
12
|
+
*/
|
|
13
|
+
export declare function extractPCM4AudioData(audioData: AudioData): Float32Array[];
|
|
14
|
+
/**
|
|
15
|
+
* Extract PCM from AudioBuffer
|
|
16
|
+
*/
|
|
17
|
+
export declare function extractPCM4AudioBuffer(audioBuffer: AudioBuffer): Float32Array[];
|
|
18
|
+
/**
|
|
19
|
+
* Adjust audio data volume
|
|
20
|
+
* @param audioData - Audio object to adjust
|
|
21
|
+
* @param volume - Volume adjustment coefficient (0.0 - 1.0)
|
|
22
|
+
* @returns New audio data with adjusted volume
|
|
23
|
+
*/
|
|
24
|
+
export declare function adjustAudioDataVolume(audioData: AudioData, volume: number): AudioData;
|
|
25
|
+
/**
|
|
26
|
+
* Mix PCM data from dual-channel audio tracks and interleave multiple channels into a single Float32Array output
|
|
27
|
+
* @param audios - A 2D array where each element is a Float32Array array representing PCM data from an audio stream.
|
|
28
|
+
* The first element of each Float32Array array is left channel data, and the second element (if present) is right channel data.
|
|
29
|
+
* If only left channel data exists, the right channel will reuse the left channel data.
|
|
30
|
+
*
|
|
31
|
+
* @returns Returns a Float32Array with left and right channels interleaved.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
*
|
|
35
|
+
* const audios = [
|
|
36
|
+
* [new Float32Array([0.1, 0.2, 0.3]), new Float32Array([0.4, 0.5, 0.6])],
|
|
37
|
+
* [new Float32Array([0.7, 0.8, 0.9])],
|
|
38
|
+
* ];
|
|
39
|
+
* const mixed = mixinPCM(audios);
|
|
40
|
+
*/
|
|
41
|
+
export declare function mixinPCM(audios: Float32Array[][]): Float32Array;
|
|
42
|
+
/**
|
|
43
|
+
* Resample PCM audio data.
|
|
44
|
+
*
|
|
45
|
+
* @param pcmData - A Float32Array array where each element represents PCM data from one channel.
|
|
46
|
+
* @param curRate - Current sample rate.
|
|
47
|
+
* @param target - Target parameters object.
|
|
48
|
+
* @param target.rate - Target sample rate.
|
|
49
|
+
* @param target.chanCount - Target channel count.
|
|
50
|
+
*
|
|
51
|
+
* @returns Returns a Promise that resolves to a Float32Array array where each element represents PCM data from one channel after resampling.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
*
|
|
55
|
+
* const pcmData = [new Float32Array([0.1, 0.2, 0.3]), new Float32Array([0.4, 0.5, 0.6])];
|
|
56
|
+
* const curRate = 44100;
|
|
57
|
+
* const target = { rate: 48000, chanCount: 2 };
|
|
58
|
+
* const resampled = await audioResample(pcmData, curRate, target);
|
|
59
|
+
*/
|
|
60
|
+
export declare function audioResample(pcmData: Float32Array[], curRate: number, target: {
|
|
61
|
+
rate: number;
|
|
62
|
+
chanCount: number;
|
|
63
|
+
}): Promise<Float32Array[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Extract a circular slice from the given Float32Array, looping from 0 when exceeding boundaries
|
|
66
|
+
*
|
|
67
|
+
* Mainly used for slicing PCM data to implement looped playback
|
|
68
|
+
*
|
|
69
|
+
* @param data - Input Float32Array.
|
|
70
|
+
* @param start - Start index of the slice.
|
|
71
|
+
* @param end - End index of the slice.
|
|
72
|
+
* @returns Returns a new Float32Array containing data from start to end.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* const data = new Float32Array([0, 1, 2, 3, 4, 5]);
|
|
76
|
+
* ringSliceFloat32Array(data, 4, 6); // => Float32Array [4, 5, 0]
|
|
77
|
+
*/
|
|
78
|
+
export declare function ringSliceFloat32Array(data: Float32Array, start: number, end: number): Float32Array;
|
|
79
|
+
/**
|
|
80
|
+
* Change PCM data playback rate, where 1 means normal playback, 0.5 means half speed, and 2 means double speed
|
|
81
|
+
*/
|
|
82
|
+
export declare function changePCMPlaybackRate(pcmData: Float32Array, playbackRate: number): Float32Array<ArrayBuffer>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface IChromakeyOpts {
|
|
2
|
+
keyColor: [number, number, number];
|
|
3
|
+
similarity: number;
|
|
4
|
+
smoothness: number;
|
|
5
|
+
spill: number;
|
|
6
|
+
}
|
|
7
|
+
type ImgSource = HTMLVideoElement | HTMLCanvasElement | HTMLImageElement | ImageBitmap | OffscreenCanvas | VideoFrame;
|
|
8
|
+
/**
|
|
9
|
+
* Green screen keying
|
|
10
|
+
* keyColor Background color to remove, if not provided will use first pixel
|
|
11
|
+
* similarity Background color similarity threshold, too small may retain background, too large may remove more non-background pixels
|
|
12
|
+
* smoothness Smoothness; too small may cause jagged edges, too large causes overall transparency
|
|
13
|
+
* spill Saturation; too small may retain green spill, too large causes image to become grayscale
|
|
14
|
+
* @param opts: {
|
|
15
|
+
* keyColor?: [r, g, b]
|
|
16
|
+
* similarity: number
|
|
17
|
+
* smoothness: number
|
|
18
|
+
* spill: number
|
|
19
|
+
* }
|
|
20
|
+
*/
|
|
21
|
+
export declare const createChromakey: (opts: Omit<IChromakeyOpts, "keyColor"> & {
|
|
22
|
+
keyColor?: [number, number, number];
|
|
23
|
+
}) => (imgSource: ImgSource) => Promise<ImageBitmap | VideoFrame>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new HTML element
|
|
3
|
+
* @param tagName - Tag name of the element to create
|
|
4
|
+
* @returns Newly created HTML element
|
|
5
|
+
*/
|
|
6
|
+
export declare function createEl(tagName: string): HTMLElement;
|
|
7
|
+
/**
|
|
8
|
+
* Render text as an image
|
|
9
|
+
* @param text - Text to render
|
|
10
|
+
* @param cssText - CSS styles to apply to the text
|
|
11
|
+
* @returns Rendered image element
|
|
12
|
+
*/
|
|
13
|
+
export declare function renderTxt2Img(text: string, cssText: string, opts?: {
|
|
14
|
+
font?: {
|
|
15
|
+
name: string;
|
|
16
|
+
url: string;
|
|
17
|
+
};
|
|
18
|
+
onCreated?: (el: HTMLElement) => void;
|
|
19
|
+
}): Promise<HTMLImageElement>;
|
|
20
|
+
/**
|
|
21
|
+
* Render text as {@link ImageBitmap} for creating {@link ImageClip}
|
|
22
|
+
* @param text - Text to render
|
|
23
|
+
* @param cssText - CSS styles to apply to the text
|
|
24
|
+
* @param opts - Options
|
|
25
|
+
* @param opts.font - Custom font
|
|
26
|
+
* @param opts.onCreated - Callback after creation
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* new ImageClip(
|
|
30
|
+
* await renderTxt2ImgBitmap(
|
|
31
|
+
* 'Watermark',
|
|
32
|
+
* `font-size:40px; color: white; text-shadow: 2px 2px 6px red; font-family: CustomFont;`,
|
|
33
|
+
* {
|
|
34
|
+
* font: {
|
|
35
|
+
* name: 'CustomFont',
|
|
36
|
+
* url: '/CustomFont.ttf',
|
|
37
|
+
* },
|
|
38
|
+
* },
|
|
39
|
+
* )
|
|
40
|
+
* )
|
|
41
|
+
*/
|
|
42
|
+
export declare function renderTxt2ImgBitmap(text: string, cssText: string, opts?: {
|
|
43
|
+
font?: {
|
|
44
|
+
name: string;
|
|
45
|
+
url: string;
|
|
46
|
+
};
|
|
47
|
+
onCreated?: (el: HTMLElement) => void;
|
|
48
|
+
}): Promise<ImageBitmap>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface IFont {
|
|
2
|
+
name: string;
|
|
3
|
+
url: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class FontManager {
|
|
6
|
+
private static instance;
|
|
7
|
+
private fonts;
|
|
8
|
+
private constructor();
|
|
9
|
+
static getInstance(): FontManager;
|
|
10
|
+
addFont(font: IFont): Promise<void>;
|
|
11
|
+
loadFonts(fonts: IFont[]): Promise<void>;
|
|
12
|
+
removeFont(fontName: string): void;
|
|
13
|
+
clear(): void;
|
|
14
|
+
getLoadedFonts(): string[];
|
|
15
|
+
}
|
|
16
|
+
export declare const fontManager: FontManager;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse SRT subtitle format
|
|
3
|
+
* Returns array of subtitle segments with start, end, and text
|
|
4
|
+
*/
|
|
5
|
+
export interface SubtitleSegment {
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
text: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Parse SRT subtitle content into segments
|
|
12
|
+
* @param srt SRT file content as string
|
|
13
|
+
* @returns Array of subtitle segments
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseSrt(srt: string): SubtitleSegment[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decode image stream, return an array of video frames.
|
|
3
|
+
*
|
|
4
|
+
* @param stream - Readable stream containing image data.
|
|
5
|
+
* @param type - MIME type of the image, e.g. 'image/jpeg'.
|
|
6
|
+
*
|
|
7
|
+
* @returns Returns a Promise that resolves to an array of {@link VideoFrame} after decoding completes.
|
|
8
|
+
*
|
|
9
|
+
* @see [Decode animated image](https://webav-tech.github.io/WebAV/demo/1_3-decode-image)
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
*
|
|
13
|
+
* const frames = await decodeImg(
|
|
14
|
+
* (await fetch('<gif url>')).body!,
|
|
15
|
+
* `image/gif`,
|
|
16
|
+
* );
|
|
17
|
+
*/
|
|
18
|
+
export declare function decodeImg(stream: ReadableStream<Uint8Array>, type: string): Promise<VideoFrame[]>;
|