alpha2 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.
- package/README.md +6 -4
- package/dist/containers.d.ts +89 -0
- package/dist/containers.js +150 -0
- package/dist/effects.d.ts +16 -2
- package/dist/frame-supply.d.ts +8 -0
- package/dist/frame-supply.js +26 -4
- package/dist/generated/project-schema.d.ts +564 -100
- package/dist/generated/project-schema.js +36 -0
- package/dist/generated/project-shape.js +345 -55
- package/dist/geometry.d.ts +98 -0
- package/dist/geometry.js +71 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mediabunny.d.ts +54 -27
- package/dist/mediabunny.js +261 -46
- package/dist/player.d.ts +5 -0
- package/dist/presented-frames.d.ts +16 -0
- package/dist/presented-frames.js +31 -0
- package/dist/project.d.ts +26 -2
- package/dist/project.js +358 -55
- package/dist/worker.js +15 -1
- package/package.json +9 -1
- package/wasm/alpha2_audio_worklet.wasm +0 -0
- package/wasm/alpha2_extensions_bg.wasm +0 -0
- package/wasm/alpha2_wasm.d.ts +178 -8
- package/wasm/alpha2_wasm.js +506 -34
- package/wasm/alpha2_wasm_bg.wasm +0 -0
- package/wasm/alpha2_wasm_bg.wasm.d.ts +23 -4
- /package/wasm/snippets/{alpha2-wasm-6cb97e5ef34d0f09 → alpha2-wasm-7f557ec9a60cc69b}/inline0.js +0 -0
- /package/wasm/snippets/{alpha2-wasm-6cb97e5ef34d0f09 → alpha2-wasm-7f557ec9a60cc69b}/inline1.js +0 -0
- /package/wasm/snippets/{alpha2-wasm-6cb97e5ef34d0f09 → alpha2-wasm-7f557ec9a60cc69b}/inline2.js +0 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape geometry for editors, answered in wasm by the code the engine draws shapes with: where a
|
|
3
|
+
* shapes generator's items are, which paint is under a point, how long a path is, and paths cut,
|
|
4
|
+
* resampled, or converted. A hit test or a trim here agrees with what a frame shows.
|
|
5
|
+
*
|
|
6
|
+
* Positions are normalized as the project document's are, `(0, 0)` top-left to `(1, 1)`
|
|
7
|
+
* bottom-right of a `width` by `height` picture; lengths and distances are in its pixels. Times
|
|
8
|
+
* are ticks, as keyframe times are.
|
|
9
|
+
*
|
|
10
|
+
* Every function throws an `INVALID_INPUT` error for a picture outside 1 to 16384 pixels a side, a
|
|
11
|
+
* time that is not a whole number of ticks, or input the model rejects (a content tree or geometry
|
|
12
|
+
* that is not valid, a path point or tangent that is not finite).
|
|
13
|
+
*/
|
|
14
|
+
import type { AnimatedPoint, Path, ShapeGeometry, ShapeItem, Ticks, Vec2 } from "./project.js";
|
|
15
|
+
/** The part of `alpha2/wasm` these functions use. */
|
|
16
|
+
export interface GeometryBinding {
|
|
17
|
+
shapeBounds(itemsJson: string, time: number, width: number, height: number): string;
|
|
18
|
+
hitTest(itemsJson: string, time: number, width: number, height: number, x: number, y: number): string | undefined;
|
|
19
|
+
nearestPoint(pathJson: string, width: number, height: number, x: number, y: number): string;
|
|
20
|
+
pathLength(pathJson: string, width: number, height: number): string;
|
|
21
|
+
trimPath(pathJson: string, width: number, height: number, start: number, end: number, offset: number): string;
|
|
22
|
+
resamplePath(pathJson: string, width: number, height: number, vertexCounts: Uint32Array): string;
|
|
23
|
+
toPath(geometryJson: string, time: number, width: number, height: number): string;
|
|
24
|
+
motionPath(pointJson: string, width: number, height: number): string;
|
|
25
|
+
}
|
|
26
|
+
/** The size of the picture shapes are drawn on, in pixels. */
|
|
27
|
+
export interface PictureSize {
|
|
28
|
+
readonly width: number;
|
|
29
|
+
readonly height: number;
|
|
30
|
+
}
|
|
31
|
+
/** A normalized rectangle: `x0`, `y0` its top-left corner, `x1`, `y1` its bottom-right. */
|
|
32
|
+
export interface Bounds {
|
|
33
|
+
readonly x0: number;
|
|
34
|
+
readonly y0: number;
|
|
35
|
+
readonly x1: number;
|
|
36
|
+
readonly y1: number;
|
|
37
|
+
}
|
|
38
|
+
/** An item's bounds, by its place in the tree (`items[0].items[2]`). */
|
|
39
|
+
export interface ItemBounds {
|
|
40
|
+
readonly at: string;
|
|
41
|
+
/** What it covers: geometry's outline, a paint's area; `null` for an item that shows nothing. */
|
|
42
|
+
readonly bounds: Bounds | null;
|
|
43
|
+
}
|
|
44
|
+
/** The point of a path nearest another. */
|
|
45
|
+
export interface NearestPoint {
|
|
46
|
+
/** The subpath. */
|
|
47
|
+
readonly subpath: number;
|
|
48
|
+
/** The segment within it: segment `i` runs from vertex `i` to the next. */
|
|
49
|
+
readonly segment: number;
|
|
50
|
+
/** The parameter along the segment, in `0..=1`. */
|
|
51
|
+
readonly t: number;
|
|
52
|
+
/** The point, normalized. */
|
|
53
|
+
readonly point: Vec2;
|
|
54
|
+
/** Its distance from the point asked about, in pixels. */
|
|
55
|
+
readonly distance: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Each item's bounds at `time`, in document order: a group's are its items', a stroke's include
|
|
59
|
+
* its width.
|
|
60
|
+
*
|
|
61
|
+
* @throws When `items` is not a valid content tree.
|
|
62
|
+
*/
|
|
63
|
+
export declare function shapeBounds(binding: GeometryBinding, items: readonly ShapeItem[], time: Ticks, size: PictureSize): ItemBounds[];
|
|
64
|
+
/**
|
|
65
|
+
* The front-most fill or stroke at normalized `point` at `time`, by its fill rule (a stroke by
|
|
66
|
+
* its outline): its place in the tree, or `undefined` where nothing is painted.
|
|
67
|
+
*
|
|
68
|
+
* @throws When `items` is not a valid content tree.
|
|
69
|
+
*/
|
|
70
|
+
export declare function hitTest(binding: GeometryBinding, items: readonly ShapeItem[], time: Ticks, size: PictureSize, point: Vec2): string | undefined;
|
|
71
|
+
/** The point of `path` nearest normalized `point`, or `undefined` for an empty path. */
|
|
72
|
+
export declare function nearestPoint(binding: GeometryBinding, path: Path, size: PictureSize, point: Vec2): NearestPoint | undefined;
|
|
73
|
+
/** Each subpath's length, in pixels. */
|
|
74
|
+
export declare function pathLength(binding: GeometryBinding, path: Path, size: PictureSize): number[];
|
|
75
|
+
/**
|
|
76
|
+
* The part of `path` a trim item keeps: from `start` to `end` (fractions of its pixel length, all
|
|
77
|
+
* subpaths end to end, clamped to `0..=1`), shifted by `offset` turns. Nothing when `start` is not
|
|
78
|
+
* before `end`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function trimPath(binding: GeometryBinding, path: Path, size: PictureSize, start: number, end: number, offset?: number): Path;
|
|
81
|
+
/**
|
|
82
|
+
* `path` with `vertexCounts[i]` vertices on subpath `i`, evenly along its length, so two paths can
|
|
83
|
+
* be given the same structure and their keyframes can morph. The engine never resamples on its
|
|
84
|
+
* own. A subpath whose count is missing, below 2 (3 when closed), or that has no length is kept as
|
|
85
|
+
* it is.
|
|
86
|
+
*
|
|
87
|
+
* @throws When a count is over `MAX_PATH_VERTICES`.
|
|
88
|
+
*/
|
|
89
|
+
export declare function resamplePath(binding: GeometryBinding, path: Path, size: PictureSize, vertexCounts: readonly number[]): Path;
|
|
90
|
+
/**
|
|
91
|
+
* A rectangle, ellipse, or polystar at `time` as a path of the same outline, from the same start
|
|
92
|
+
* point and in the same direction: "convert to path".
|
|
93
|
+
*
|
|
94
|
+
* @throws When `geometry` is not valid.
|
|
95
|
+
*/
|
|
96
|
+
export declare function toPath(binding: GeometryBinding, geometry: ShapeGeometry, time: Ticks, size: PictureSize): Path;
|
|
97
|
+
/** The polyline a position travels between its keyframes, along their spatial tangents. */
|
|
98
|
+
export declare function motionPath(binding: GeometryBinding, position: AnimatedPoint, size: PictureSize): Vec2[];
|
package/dist/geometry.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape geometry for editors, answered in wasm by the code the engine draws shapes with: where a
|
|
3
|
+
* shapes generator's items are, which paint is under a point, how long a path is, and paths cut,
|
|
4
|
+
* resampled, or converted. A hit test or a trim here agrees with what a frame shows.
|
|
5
|
+
*
|
|
6
|
+
* Positions are normalized as the project document's are, `(0, 0)` top-left to `(1, 1)`
|
|
7
|
+
* bottom-right of a `width` by `height` picture; lengths and distances are in its pixels. Times
|
|
8
|
+
* are ticks, as keyframe times are.
|
|
9
|
+
*
|
|
10
|
+
* Every function throws an `INVALID_INPUT` error for a picture outside 1 to 16384 pixels a side, a
|
|
11
|
+
* time that is not a whole number of ticks, or input the model rejects (a content tree or geometry
|
|
12
|
+
* that is not valid, a path point or tangent that is not finite).
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Each item's bounds at `time`, in document order: a group's are its items', a stroke's include
|
|
16
|
+
* its width.
|
|
17
|
+
*
|
|
18
|
+
* @throws When `items` is not a valid content tree.
|
|
19
|
+
*/
|
|
20
|
+
export function shapeBounds(binding, items, time, size) {
|
|
21
|
+
return JSON.parse(binding.shapeBounds(JSON.stringify(items), time, size.width, size.height));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The front-most fill or stroke at normalized `point` at `time`, by its fill rule (a stroke by
|
|
25
|
+
* its outline): its place in the tree, or `undefined` where nothing is painted.
|
|
26
|
+
*
|
|
27
|
+
* @throws When `items` is not a valid content tree.
|
|
28
|
+
*/
|
|
29
|
+
export function hitTest(binding, items, time, size, point) {
|
|
30
|
+
return (binding.hitTest(JSON.stringify(items), time, size.width, size.height, point.x, point.y) ?? undefined);
|
|
31
|
+
}
|
|
32
|
+
/** The point of `path` nearest normalized `point`, or `undefined` for an empty path. */
|
|
33
|
+
export function nearestPoint(binding, path, size, point) {
|
|
34
|
+
return (JSON.parse(binding.nearestPoint(JSON.stringify(path), size.width, size.height, point.x, point.y)) ?? undefined);
|
|
35
|
+
}
|
|
36
|
+
/** Each subpath's length, in pixels. */
|
|
37
|
+
export function pathLength(binding, path, size) {
|
|
38
|
+
return JSON.parse(binding.pathLength(JSON.stringify(path), size.width, size.height));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The part of `path` a trim item keeps: from `start` to `end` (fractions of its pixel length, all
|
|
42
|
+
* subpaths end to end, clamped to `0..=1`), shifted by `offset` turns. Nothing when `start` is not
|
|
43
|
+
* before `end`.
|
|
44
|
+
*/
|
|
45
|
+
export function trimPath(binding, path, size, start, end, offset = 0) {
|
|
46
|
+
return JSON.parse(binding.trimPath(JSON.stringify(path), size.width, size.height, start, end, offset));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* `path` with `vertexCounts[i]` vertices on subpath `i`, evenly along its length, so two paths can
|
|
50
|
+
* be given the same structure and their keyframes can morph. The engine never resamples on its
|
|
51
|
+
* own. A subpath whose count is missing, below 2 (3 when closed), or that has no length is kept as
|
|
52
|
+
* it is.
|
|
53
|
+
*
|
|
54
|
+
* @throws When a count is over `MAX_PATH_VERTICES`.
|
|
55
|
+
*/
|
|
56
|
+
export function resamplePath(binding, path, size, vertexCounts) {
|
|
57
|
+
return JSON.parse(binding.resamplePath(JSON.stringify(path), size.width, size.height, Uint32Array.from(vertexCounts)));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A rectangle, ellipse, or polystar at `time` as a path of the same outline, from the same start
|
|
61
|
+
* point and in the same direction: "convert to path".
|
|
62
|
+
*
|
|
63
|
+
* @throws When `geometry` is not valid.
|
|
64
|
+
*/
|
|
65
|
+
export function toPath(binding, geometry, time, size) {
|
|
66
|
+
return JSON.parse(binding.toPath(JSON.stringify(geometry), time, size.width, size.height));
|
|
67
|
+
}
|
|
68
|
+
/** The polyline a position travels between its keyframes, along their spatial tangents. */
|
|
69
|
+
export function motionPath(binding, position, size) {
|
|
70
|
+
return JSON.parse(binding.motionPath(JSON.stringify(position), size.width, size.height));
|
|
71
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./audio-worklet.js";
|
|
|
4
4
|
export * from "./audio.js";
|
|
5
5
|
export * from "./audio-timeline.js";
|
|
6
6
|
export * from "./audio-worker.js";
|
|
7
|
+
export * from "./containers.js";
|
|
7
8
|
export * from "./effects.js";
|
|
8
9
|
export * from "./exporter.js";
|
|
9
10
|
export * from "./extensions.js";
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./audio-worklet.js";
|
|
|
4
4
|
export * from "./audio.js";
|
|
5
5
|
export * from "./audio-timeline.js";
|
|
6
6
|
export * from "./audio-worker.js";
|
|
7
|
+
export * from "./containers.js";
|
|
7
8
|
export * from "./effects.js";
|
|
8
9
|
export * from "./exporter.js";
|
|
9
10
|
export * from "./extensions.js";
|
package/dist/mediabunny.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { AudioDecoderRefillRequest, AudioSpeaker, BrowserDecodedFrame, Brow
|
|
|
3
3
|
import type { BrowserAudioBlockSink } from "./audio.js";
|
|
4
4
|
import type { BrowserEncodeSink, ExportedFrame } from "./exporter.js";
|
|
5
5
|
import type { VideoRateControl } from "./rate-control.js";
|
|
6
|
+
import { type ExportContainer } from "./containers.js";
|
|
6
7
|
import type { PositionedWrite } from "./export-destination.js";
|
|
7
8
|
/** Inputs supported by the optional pinned mediabunny adapter. */
|
|
8
9
|
export type MediabunnyInput = Blob | ArrayBuffer | ArrayBufferView;
|
|
@@ -143,9 +144,14 @@ export declare class MediabunnyAudioDecoder implements BrowserAudioDecoder {
|
|
|
143
144
|
close(): void;
|
|
144
145
|
}
|
|
145
146
|
/**
|
|
146
|
-
* Options for {@link
|
|
147
|
+
* Options for {@link MediabunnySink}. At least one of `videoCodec` and `audioCodec` is required.
|
|
147
148
|
*/
|
|
148
|
-
export interface
|
|
149
|
+
export interface MediabunnySinkOptions {
|
|
150
|
+
/**
|
|
151
|
+
* The file format. The codecs must be ones it offers (see `alpha2/containers`): MOV takes no VP9,
|
|
152
|
+
* AV1 or Opus, and WebM takes only VP9, AV1 and Opus.
|
|
153
|
+
*/
|
|
154
|
+
readonly container: ExportContainer;
|
|
149
155
|
/** Adds a video track in this codec; requires `videoRateControl`. */
|
|
150
156
|
readonly videoCodec?: "avc" | "hevc" | "vp9" | "av1";
|
|
151
157
|
/**
|
|
@@ -171,6 +177,13 @@ export interface MediabunnyMp4SinkOptions {
|
|
|
171
177
|
* refuses it; `appliedVideoRateControl` says which ran.
|
|
172
178
|
*/
|
|
173
179
|
readonly videoRateControl?: VideoRateControl;
|
|
180
|
+
/** The video encoder's latency mode; by default the one {@link videoEncoderLatencyMode} measures. */
|
|
181
|
+
readonly videoLatencyMode?: VideoEncoderLatencyMode;
|
|
182
|
+
/**
|
|
183
|
+
* How long the video encoder may hold frames without output before writes reject with
|
|
184
|
+
* `ENCODE_STALLED` (default 10 s).
|
|
185
|
+
*/
|
|
186
|
+
readonly stallTimeoutMs?: number;
|
|
174
187
|
/** The audio bitrate in bits per second, already resolved. Required with `audioCodec`. */
|
|
175
188
|
readonly audioBitrate?: number;
|
|
176
189
|
/**
|
|
@@ -186,19 +199,20 @@ export interface MediabunnyMp4SinkOptions {
|
|
|
186
199
|
*/
|
|
187
200
|
readonly audioResampler?: AudioResamplerBinding;
|
|
188
201
|
/**
|
|
189
|
-
* Where the file goes. `stream` writes a
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
* stream is closed (committed) only once
|
|
193
|
-
* and aborted (discarded) when the export
|
|
194
|
-
*
|
|
195
|
-
* caller sizes (and budgets for, see
|
|
196
|
-
* fails with `RESOURCE_LIMIT`
|
|
202
|
+
* Where the file goes. `stream` writes through a seekable positioned stream as it is muxed (see
|
|
203
|
+
* `WritableFileDestination` in `alpha2/export-destination`): MP4 and MOV put `moov` at the end,
|
|
204
|
+
* without fast start, and MKV and WebM patch sizes and Cues in place, so no part of the encoded
|
|
205
|
+
* output accumulates in memory; the stream is closed (committed) only once
|
|
206
|
+
* {@link MediabunnySink.finish} has finished the file, and aborted (discarded) when the export
|
|
207
|
+
* fails or is cancelled. `memory` keeps it in an `ArrayBuffer`, for small outputs only:
|
|
208
|
+
* `maxBytes` is the most the output may reach, which the caller sizes (and budgets for, see
|
|
209
|
+
* `memoryOutputPeakBytes`) before starting; past it the export fails with `RESOURCE_LIMIT`
|
|
210
|
+
* instead of growing.
|
|
197
211
|
*/
|
|
198
|
-
readonly destination:
|
|
212
|
+
readonly destination: ExportDestination;
|
|
199
213
|
}
|
|
200
|
-
/** Where a {@link
|
|
201
|
-
export type
|
|
214
|
+
/** Where a {@link MediabunnySink} writes. */
|
|
215
|
+
export type ExportDestination = {
|
|
202
216
|
readonly kind: "stream";
|
|
203
217
|
readonly writable: WritableStream<PositionedWrite>;
|
|
204
218
|
} | {
|
|
@@ -207,12 +221,12 @@ export type Mp4Destination = {
|
|
|
207
221
|
};
|
|
208
222
|
/**
|
|
209
223
|
* The mediabunny quality a video track encodes at for the engine's rate control: what
|
|
210
|
-
* {@link
|
|
224
|
+
* {@link MediabunnySink} configures its encoder with.
|
|
211
225
|
*/
|
|
212
226
|
export declare function videoEncoderQuality(rate: VideoRateControl): Quality;
|
|
213
227
|
/**
|
|
214
228
|
* Whether this browser can encode `codec` video at `width`x`height` with `rate`, asked with the
|
|
215
|
-
* configurations {@link
|
|
229
|
+
* configurations {@link MediabunnySink} would try. WebCodecs leaves the codecs to the browser
|
|
216
230
|
* (Chrome on Linux encodes no HEVC, for one), so an export asks before it opens its encoder.
|
|
217
231
|
*/
|
|
218
232
|
export declare function canEncodeVideoTrack(codec: "avc" | "hevc" | "vp9" | "av1", options: {
|
|
@@ -220,11 +234,19 @@ export declare function canEncodeVideoTrack(codec: "avc" | "hevc" | "vp9" | "av1
|
|
|
220
234
|
readonly height: number;
|
|
221
235
|
readonly rate: VideoRateControl;
|
|
222
236
|
}): Promise<boolean>;
|
|
237
|
+
/** How a browser's video encoder is opened: see {@link videoEncoderLatencyMode}. */
|
|
238
|
+
export type VideoEncoderLatencyMode = "quality" | "realtime";
|
|
239
|
+
/**
|
|
240
|
+
* The latency mode {@link MediabunnySink} opens `codec`'s encoder with: `"realtime"` only where a
|
|
241
|
+
* quality-mode encoder puts out nothing (Safari 27's H.264) and a realtime one works. Measured once
|
|
242
|
+
* per codec.
|
|
243
|
+
*/
|
|
244
|
+
export declare function videoEncoderLatencyMode(codec: "avc" | "hevc" | "vp9" | "av1"): Promise<VideoEncoderLatencyMode>;
|
|
223
245
|
/**
|
|
224
246
|
* The rate this browser encodes `codec` audio of a project at `sampleRate` with, by the rule a
|
|
225
247
|
* native host follows: the project rate when the browser's encoder takes it, else the lowest rate
|
|
226
248
|
* the codec carries above it that the encoder takes, else the highest below it; `null` when the
|
|
227
|
-
* encoder takes none. Pass it to {@link
|
|
249
|
+
* encoder takes none. Pass it to {@link MediabunnySink} as `audioSampleRate`, so every project
|
|
228
250
|
* rate exports where the browser encodes the codec at all.
|
|
229
251
|
*/
|
|
230
252
|
export declare function audioEncoderSampleRate(codec: "aac" | "opus", options: {
|
|
@@ -232,8 +254,8 @@ export declare function audioEncoderSampleRate(codec: "aac" | "opus", options: {
|
|
|
232
254
|
readonly numberOfChannels: number;
|
|
233
255
|
readonly bitrate: number;
|
|
234
256
|
}): Promise<number | null>;
|
|
235
|
-
/** What a finished {@link
|
|
236
|
-
export type
|
|
257
|
+
/** What a finished {@link MediabunnySink} produced. */
|
|
258
|
+
export type ExportOutput = {
|
|
237
259
|
readonly kind: "stream";
|
|
238
260
|
readonly bytes: number;
|
|
239
261
|
} | {
|
|
@@ -253,17 +275,20 @@ export interface AppliedVideoRateControl {
|
|
|
253
275
|
* The sink is the file: its `finish` finalizes every track, which suits one runner, or a host that
|
|
254
276
|
* writes both tracks itself and finishes once. When two runners share the file (`exportToSink` for
|
|
255
277
|
* the video and `renderOfflineAudio` for the audio, at once or one after the other), give each its
|
|
256
|
-
* track instead, {@link
|
|
278
|
+
* track instead, {@link MediabunnySink.videoTrack} and {@link MediabunnySink.audioTrack}: a
|
|
257
279
|
* runner's `finish` then ends its own track, and the file is finalized when every configured track
|
|
258
280
|
* has ended. Either track's `abort` discards the whole file, and the other runner's next write
|
|
259
281
|
* fails.
|
|
260
282
|
*
|
|
261
|
-
* The constructor throws `RangeError` when no track is configured,
|
|
262
|
-
* memory destination's `maxBytes` is not
|
|
283
|
+
* The constructor throws `RangeError` when no track is configured, the container does not offer a
|
|
284
|
+
* codec (an `ExportFormatError`), a codec lacks its rate, a memory destination's `maxBytes` is not
|
|
285
|
+
* a positive safe integer, or `stallTimeoutMs` is out of range.
|
|
263
286
|
*/
|
|
264
|
-
export declare class
|
|
287
|
+
export declare class MediabunnySink implements BrowserEncodeSink, BrowserAudioBlockSink {
|
|
265
288
|
#private;
|
|
266
|
-
constructor(options:
|
|
289
|
+
constructor(options: MediabunnySinkOptions);
|
|
290
|
+
/** The latency mode the video encoder was opened with; undefined until the sink has started. */
|
|
291
|
+
get videoLatencyMode(): VideoEncoderLatencyMode | undefined;
|
|
267
292
|
/**
|
|
268
293
|
* The video track as a sink of its own, for a runner that shares the file with another: its
|
|
269
294
|
* `finish` ends the video track and finalizes the file once every configured track has ended;
|
|
@@ -284,7 +309,8 @@ export declare class MediabunnyMp4Sink implements BrowserEncodeSink, BrowserAudi
|
|
|
284
309
|
/**
|
|
285
310
|
* Encodes one frame at its output time (`output.timeTicks`, counted from the output's zero).
|
|
286
311
|
* Closes `output.frame` whether or not it succeeds. Rejects with `RESOURCE_LIMIT` once a memory
|
|
287
|
-
* destination has passed `maxBytes`,
|
|
312
|
+
* destination has passed `maxBytes`, with `ENCODE_STALLED` when the encoder stalls, or when no
|
|
313
|
+
* video track is configured.
|
|
288
314
|
*/
|
|
289
315
|
writeVideo(output: ExportedFrame): Promise<void>;
|
|
290
316
|
/**
|
|
@@ -299,8 +325,9 @@ export declare class MediabunnyMp4Sink implements BrowserEncodeSink, BrowserAudi
|
|
|
299
325
|
writeAudio(block: BrowserAudioBlock): Promise<void>;
|
|
300
326
|
/**
|
|
301
327
|
* Finalizes the file and commits a stream destination; calling it again after it resolved does
|
|
302
|
-
* nothing. Rejects with `RESOURCE_LIMIT` when a memory destination passed `maxBytes`,
|
|
303
|
-
* what the muxer or the destination refused; a
|
|
328
|
+
* nothing. Rejects with `RESOURCE_LIMIT` when a memory destination passed `maxBytes`, with
|
|
329
|
+
* `ENCODE_STALLED` when the encoder stalls, and with what the muxer or the destination refused; a
|
|
330
|
+
* stream destination is then discarded.
|
|
304
331
|
*/
|
|
305
332
|
finish(): Promise<void>;
|
|
306
333
|
/**
|
|
@@ -312,7 +339,7 @@ export declare class MediabunnyMp4Sink implements BrowserEncodeSink, BrowserAudi
|
|
|
312
339
|
* The finished output: its length for a stream, the bytes in memory. Null until {@link finish}
|
|
313
340
|
* resolves.
|
|
314
341
|
*/
|
|
315
|
-
get output():
|
|
342
|
+
get output(): ExportOutput | null;
|
|
316
343
|
/** Bytes muxed so far: the file's length as written. */
|
|
317
344
|
get bytesWritten(): number;
|
|
318
345
|
}
|