@video-editor/renderer 0.0.1-beta.3 → 0.0.1-beta.31
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/README.md +32 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.js +1181 -242
- package/dist/index.js.map +1 -1
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -24,3 +24,35 @@ renderer.tick(16.7) // or rely on requestAnimationFrame loop
|
|
|
24
24
|
// mutate protocol reactively; the renderer will verify and update visuals
|
|
25
25
|
protocol.tracks.push(/* ... */)
|
|
26
26
|
```
|
|
27
|
+
|
|
28
|
+
## Video composition
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { composeProtocol } from '@video-editor/renderer'
|
|
32
|
+
|
|
33
|
+
const { stream, durationMs } = await composeProtocol(protocol, {
|
|
34
|
+
onProgress: (progress) => console.log('progress', progress),
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const blob = await new Response(stream).blob()
|
|
38
|
+
console.log('duration (ms)', durationMs, blob)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Concatenate videos
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { concatVideos } from '@video-editor/renderer'
|
|
45
|
+
|
|
46
|
+
const { stream, durationMs } = await concatVideos(
|
|
47
|
+
[
|
|
48
|
+
'https://example.com/intro.mp4',
|
|
49
|
+
'https://example.com/main.mp4',
|
|
50
|
+
],
|
|
51
|
+
{
|
|
52
|
+
onProgress: (progress) => console.log('progress', progress),
|
|
53
|
+
},
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
const blob = await new Response(stream).blob()
|
|
57
|
+
console.log('duration (ms)', durationMs, blob)
|
|
58
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,58 @@ import { Application } from 'pixi.js';
|
|
|
2
2
|
import { ApplicationOptions } from 'pixi.js';
|
|
3
3
|
import { ComputedRef } from '@vue/reactivity';
|
|
4
4
|
import { Container } from 'pixi.js';
|
|
5
|
+
import { file } from 'opfs-tools';
|
|
6
|
+
import { IClip } from '@webav/av-cliper';
|
|
7
|
+
import { ICombinatorOpts } from '@webav/av-cliper';
|
|
5
8
|
import { IVideoProtocol } from '@video-editor/shared';
|
|
9
|
+
import { OffscreenSprite } from '@webav/av-cliper';
|
|
6
10
|
import { Ref } from '@vue/reactivity';
|
|
7
11
|
|
|
12
|
+
declare interface ClipMeta {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
duration: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export declare function composeProtocol(protocol: IVideoProtocol, opts?: ComposeProtocolOptions): Promise<ComposeProtocolResult>;
|
|
19
|
+
|
|
20
|
+
export declare interface ComposeProtocolOptions extends Omit<ICombinatorOpts, 'width' | 'height' | 'fps'> {
|
|
21
|
+
width?: number;
|
|
22
|
+
height?: number;
|
|
23
|
+
fps?: number;
|
|
24
|
+
onProgress?: (progress: number) => void;
|
|
25
|
+
clipOptions?: ProtocolVideoClipOptions;
|
|
26
|
+
audioSprites?: (protocol: IVideoProtocol) => Promise<OffscreenSprite[]>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export declare interface ComposeProtocolResult {
|
|
30
|
+
stream: ReadableStream<Uint8Array>;
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
durationMs: number;
|
|
34
|
+
destroy: () => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export declare interface ConcatVideoOptions extends Omit<ICombinatorOpts, 'width' | 'height'> {
|
|
38
|
+
width?: number;
|
|
39
|
+
height?: number;
|
|
40
|
+
onProgress?: (progress: number) => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export declare interface ConcatVideoResult {
|
|
44
|
+
stream: ReadableStream<Uint8Array>;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
durationMs: number;
|
|
48
|
+
destroy: () => void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export declare function concatVideos(inputs: Array<ConcatVideoSource | VideoConcatSource>, opts?: ConcatVideoOptions): Promise<ConcatVideoResult>;
|
|
52
|
+
|
|
53
|
+
export declare interface ConcatVideoSource {
|
|
54
|
+
source: VideoConcatSource;
|
|
55
|
+
}
|
|
56
|
+
|
|
8
57
|
/**
|
|
9
58
|
* Create a renderer that reacts to protocol updates and drives playback state.
|
|
10
59
|
* - Pass a reactive `protocol` (Ref/readonly/normal object)
|
|
@@ -15,6 +64,33 @@ export declare function createRenderer(opts: RendererOptions): Promise<Renderer>
|
|
|
15
64
|
|
|
16
65
|
declare type MaybeRef<T> = T | Ref<T>;
|
|
17
66
|
|
|
67
|
+
export declare class ProtocolVideoClip implements IClip {
|
|
68
|
+
readonly ready: Promise<ClipMeta>;
|
|
69
|
+
meta: ClipMeta;
|
|
70
|
+
private readonly protocol;
|
|
71
|
+
private readonly options;
|
|
72
|
+
private renderer?;
|
|
73
|
+
private app?;
|
|
74
|
+
private destroyed;
|
|
75
|
+
constructor(protocol: IVideoProtocol, options?: ProtocolVideoClipOptions);
|
|
76
|
+
private init;
|
|
77
|
+
tick(time: number): Promise<{
|
|
78
|
+
video?: VideoFrame | ImageBitmap | null;
|
|
79
|
+
audio?: Float32Array[];
|
|
80
|
+
state: 'done' | 'success';
|
|
81
|
+
}>;
|
|
82
|
+
clone(): Promise<this>;
|
|
83
|
+
destroy(): void;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export declare interface ProtocolVideoClipOptions {
|
|
87
|
+
width?: number;
|
|
88
|
+
height?: number;
|
|
89
|
+
fps?: number;
|
|
90
|
+
appOptions?: Partial<ApplicationOptions>;
|
|
91
|
+
rendererOptions?: Partial<Omit<RendererOptions, 'protocol' | 'app' | 'appOptions'>>;
|
|
92
|
+
}
|
|
93
|
+
|
|
18
94
|
export declare interface Renderer {
|
|
19
95
|
app: Application;
|
|
20
96
|
layer: Container;
|
|
@@ -25,6 +101,7 @@ export declare interface Renderer {
|
|
|
25
101
|
pause: () => void;
|
|
26
102
|
tick: (deltaMs?: number) => void;
|
|
27
103
|
seek: (time: number) => void;
|
|
104
|
+
renderAt: (time: number) => Promise<void>;
|
|
28
105
|
destroy: () => void;
|
|
29
106
|
}
|
|
30
107
|
|
|
@@ -34,6 +111,12 @@ export declare interface RendererOptions {
|
|
|
34
111
|
appOptions?: Partial<ApplicationOptions>;
|
|
35
112
|
resourceDir?: string;
|
|
36
113
|
autoPlay?: boolean;
|
|
114
|
+
freezeOnPause?: boolean;
|
|
115
|
+
manualRender?: boolean;
|
|
116
|
+
videoSourceMode?: 'auto' | 'mp4clip' | 'element';
|
|
117
|
+
warmUpResources?: boolean;
|
|
37
118
|
}
|
|
38
119
|
|
|
120
|
+
export declare type VideoConcatSource = string | ReadableStream<Uint8Array> | Blob | ReturnType<typeof file>;
|
|
121
|
+
|
|
39
122
|
export { }
|