alpha2 0.4.6 → 0.5.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 +5 -4
- package/THIRD_PARTY_NOTICES.md +4 -0
- package/dist/abort.d.ts +12 -0
- package/dist/abort.js +48 -0
- package/dist/active-clock.d.ts +35 -0
- package/dist/active-clock.js +99 -0
- package/dist/assets.d.ts +28 -22
- package/dist/assets.js +8 -12
- package/dist/audio-layout.d.ts +52 -74
- package/dist/audio-layout.js +114 -148
- package/dist/audio-timeline.d.ts +89 -117
- package/dist/audio-timeline.js +102 -118
- package/dist/audio-worker.d.ts +12 -21
- package/dist/audio-worker.js +8 -13
- package/dist/audio-worklet-processor.js +45 -58
- package/dist/audio-worklet.d.ts +45 -76
- package/dist/audio-worklet.js +44 -79
- package/dist/audio.d.ts +15 -23
- package/dist/audio.js +9 -13
- package/dist/builder.d.ts +45 -63
- package/dist/builder.js +49 -45
- package/dist/capabilities.d.ts +99 -16
- package/dist/capabilities.js +2 -2
- package/dist/captions.d.ts +45 -22
- package/dist/captions.js +60 -15
- package/dist/chroma-siting.d.ts +24 -41
- package/dist/chroma-siting.js +38 -71
- package/dist/containers.d.ts +41 -30
- package/dist/containers.js +59 -27
- package/dist/decoder-fallback.d.ts +13 -0
- package/dist/decoder-fallback.js +38 -0
- package/dist/decoder-order.d.ts +24 -39
- package/dist/decoder-order.js +28 -42
- package/dist/edit.d.ts +77 -154
- package/dist/edit.js +98 -180
- package/dist/effects.d.ts +108 -177
- package/dist/effects.js +7 -9
- package/dist/export-destination.d.ts +25 -41
- package/dist/export-destination.js +20 -32
- package/dist/export-failure.d.ts +34 -59
- package/dist/export-failure.js +54 -48
- package/dist/export-metrics.d.ts +116 -0
- package/dist/export-metrics.js +74 -0
- package/dist/export-retry.d.ts +46 -29
- package/dist/export-retry.js +86 -51
- package/dist/exporter.d.ts +67 -116
- package/dist/exporter.js +133 -133
- package/dist/extensions.d.ts +69 -115
- package/dist/extensions.js +55 -82
- package/dist/frame-intake.d.ts +92 -0
- package/dist/frame-intake.js +114 -0
- package/dist/frame-supply.d.ts +96 -162
- package/dist/frame-supply.js +181 -171
- package/dist/generated/project-schema.d.ts +701 -485
- package/dist/generated/project-schema.js +55 -2
- package/dist/generated/project-shape.js +261 -16
- package/dist/geometry.d.ts +28 -34
- package/dist/geometry.js +18 -23
- package/dist/gpu-recovery.d.ts +92 -0
- package/dist/gpu-recovery.js +135 -0
- package/dist/hdr-frames.d.ts +82 -67
- package/dist/hdr-frames.js +112 -49
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/json-text.d.ts +13 -23
- package/dist/json-text.js +10 -20
- package/dist/layout-values.d.ts +14 -22
- package/dist/layout-values.js +18 -21
- package/dist/layout.d.ts +48 -63
- package/dist/layout.js +37 -37
- package/dist/loudness.d.ts +27 -32
- package/dist/loudness.js +19 -23
- package/dist/media.d.ts +85 -237
- package/dist/media.js +133 -287
- package/dist/mediabunny.d.ts +166 -245
- package/dist/mediabunny.js +741 -580
- package/dist/physical-frames.d.ts +5 -17
- package/dist/physical-frames.js +4 -11
- package/dist/player.d.ts +56 -47
- package/dist/player.js +155 -40
- package/dist/presented-frames.d.ts +2 -7
- package/dist/presented-frames.js +3 -8
- package/dist/project.d.ts +73 -117
- package/dist/project.js +384 -445
- package/dist/rate-control.d.ts +9 -23
- package/dist/rate-control.js +7 -18
- package/dist/renderer-choice.d.ts +41 -0
- package/dist/renderer-choice.js +82 -0
- package/dist/repacked-bytes.d.ts +0 -2
- package/dist/repacked-bytes.js +2 -5
- package/dist/robustness.d.ts +25 -37
- package/dist/robustness.js +71 -54
- package/dist/sha256.d.ts +5 -13
- package/dist/sha256.js +9 -24
- package/dist/text.d.ts +97 -71
- package/dist/text.js +33 -70
- package/dist/video-frames.d.ts +7 -25
- package/dist/video-frames.js +12 -29
- package/dist/waveform.d.ts +5 -11
- package/dist/waveform.js +4 -9
- package/dist/worker-error.d.ts +5 -20
- package/dist/worker-error.js +8 -25
- package/dist/worker.d.ts +82 -95
- package/dist/worker.js +235 -143
- package/package.json +26 -2
- package/wasm/alpha2_audio_worklet.wasm +0 -0
- package/wasm/alpha2_extensions.d.ts +26 -47
- package/wasm/alpha2_extensions.js +26 -47
- package/wasm/alpha2_extensions_bg.wasm +0 -0
- package/wasm/alpha2_wasm.d.ts +460 -567
- package/wasm/alpha2_wasm.js +594 -594
- package/wasm/alpha2_wasm_bg.wasm +0 -0
- package/wasm/alpha2_wasm_bg.wasm.d.ts +15 -8
- package/wasm/rust-crate-licenses.md +2 -2
- package/wasm/snippets/{alpha2-wasm-c62e60c964e88a52 → alpha2-wasm-1313375d424845c0}/inline1.js +1 -0
- package/wasm/snippets/alpha2-wasm-1313375d424845c0/inline2.js +82 -0
- package/wasm/snippets/alpha2-wasm-c62e60c964e88a52/inline2.js +0 -52
- /package/wasm/snippets/{alpha2-wasm-c62e60c964e88a52 → alpha2-wasm-1313375d424845c0}/inline0.js +0 -0
- /package/wasm/snippets/{alpha2-wasm-c62e60c964e88a52 → alpha2-wasm-1313375d424845c0}/inline3.js +0 -0
package/dist/exporter.d.ts
CHANGED
|
@@ -1,51 +1,43 @@
|
|
|
1
1
|
import type { MissingFrame } from "./player.js";
|
|
2
|
-
|
|
2
|
+
import { type AacEncoderProbe, type BrowserExportPerformance, type EncodeLatency, type VideoLatencyProbe } from "./export-metrics.js";
|
|
3
|
+
/** `num / den` frames per second; both terms must be positive. */
|
|
3
4
|
export interface RationalFrameRate {
|
|
4
5
|
readonly num: bigint;
|
|
5
6
|
readonly den: bigint;
|
|
6
7
|
}
|
|
7
8
|
/** One rendered output frame, in output order. */
|
|
8
9
|
export interface ExportedFrame {
|
|
9
|
-
/** Zero-based position in the output. */
|
|
10
10
|
readonly index: bigint;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* start
|
|
14
|
-
* the sample's timestamp.
|
|
12
|
+
* Output start time in 1/120000 s ticks, relative to {@link Alpha2Exporter.effectiveRange}'s
|
|
13
|
+
* start, so the first frame is at 0.
|
|
15
14
|
*/
|
|
16
15
|
readonly timeTicks: bigint;
|
|
17
|
-
/**
|
|
16
|
+
/** The receiver must close it. */
|
|
18
17
|
readonly frame: VideoFrame;
|
|
19
18
|
}
|
|
20
19
|
/**
|
|
21
|
-
* A backend's answer to one frame request:
|
|
22
|
-
*
|
|
20
|
+
* A backend's answer to one frame request: the source frames still needed, or a submitted render
|
|
21
|
+
* whose readback holds `retainedBytes` until it resolves.
|
|
23
22
|
*/
|
|
24
23
|
export type ExportTicket = {
|
|
25
24
|
readonly kind: "waiting";
|
|
26
25
|
readonly missingSources: readonly string[];
|
|
27
|
-
/** Each clip's missing frame, with the source time to decode
|
|
26
|
+
/** Each clip's missing frame, with the source time to decode. */
|
|
28
27
|
readonly missingFrames: readonly MissingFrame[];
|
|
29
28
|
} | {
|
|
30
29
|
readonly kind: "rendered";
|
|
31
30
|
readonly retainedBytes: number;
|
|
32
31
|
readonly readback: Promise<VideoFrame>;
|
|
33
32
|
};
|
|
34
|
-
/**
|
|
35
|
-
* One step of {@link Alpha2Exporter.next}: sources to upload before the same frame is asked for
|
|
36
|
-
* again, a submitted frame, or the end of the range.
|
|
37
|
-
*/
|
|
33
|
+
/** Result of {@link Alpha2Exporter.next}. */
|
|
38
34
|
export type ExportAdvance = {
|
|
39
35
|
readonly kind: "waiting";
|
|
40
|
-
/** The waiting frame's position in the output. */
|
|
41
36
|
readonly index: bigint;
|
|
42
|
-
/**
|
|
37
|
+
/** Timeline time in 1/120000 s ticks. */
|
|
43
38
|
readonly timelineTicks: bigint;
|
|
44
39
|
readonly missingSources: readonly string[];
|
|
45
|
-
/**
|
|
46
|
-
* Each clip's missing frame, with the source time to decode: a trimmed, offset, or retimed
|
|
47
|
-
* clip needs its source at a time other than `timelineTicks`.
|
|
48
|
-
*/
|
|
40
|
+
/** Each clip's missing frame, with the source time to decode. */
|
|
49
41
|
readonly missingFrames: readonly MissingFrame[];
|
|
50
42
|
} | {
|
|
51
43
|
readonly kind: "rendered";
|
|
@@ -54,108 +46,72 @@ export type ExportAdvance = {
|
|
|
54
46
|
} | {
|
|
55
47
|
readonly kind: "complete";
|
|
56
48
|
};
|
|
57
|
-
/**
|
|
49
|
+
/** The waiting {@link ExportAdvance} that {@link exportToSink} passes to `refill`. */
|
|
58
50
|
export type ExportWaiting = Extract<ExportAdvance, {
|
|
59
51
|
kind: "waiting";
|
|
60
52
|
}>;
|
|
61
53
|
/** Options for {@link exportToSink}. */
|
|
62
54
|
export interface BrowserExportOptions {
|
|
63
|
-
/**
|
|
55
|
+
/** Aborting rejects with an {@link ExportAbortedError} coded `cancelled`. */
|
|
64
56
|
readonly signal?: AbortSignal;
|
|
65
|
-
/** Frames rendering, reading back or encoding at once
|
|
57
|
+
/** Frames rendering, reading back or encoding at once (default 3). */
|
|
66
58
|
readonly maxInFlightFrames?: number;
|
|
67
59
|
/**
|
|
68
|
-
* Readback bytes
|
|
69
|
-
*
|
|
60
|
+
* Readback bytes in flight at once (default 128 MiB). A single frame over it fails the export
|
|
61
|
+
* with `RESOURCE_LIMIT`.
|
|
70
62
|
*/
|
|
71
63
|
readonly maxInFlightBytes?: number;
|
|
72
64
|
}
|
|
73
|
-
/**
|
|
74
|
-
export interface BrowserExportMetrics {
|
|
75
|
-
readonly pipelineEnabled: true;
|
|
76
|
-
/** Time spent waiting for the host to decode and upload missing sources. */
|
|
77
|
-
readonly sourceConvertUploadMs: number;
|
|
78
|
-
/** Worker/Wasm evaluation, render, submission, and response time. */
|
|
79
|
-
readonly frameSubmitMs: number;
|
|
80
|
-
/** End-to-end GPU mapping latency, including time overlapped with other work. */
|
|
81
|
-
readonly readbackMapLatencyMs: number;
|
|
82
|
-
/** Time for which ordered export progress was blocked on GPU mapping. */
|
|
83
|
-
readonly readbackWaitMs: number;
|
|
84
|
-
/** Alias retained for direct comparison with native metrics. */
|
|
85
|
-
readonly readbackBlockingMs: number;
|
|
86
|
-
/** Time a rendered frame waited behind earlier encoder work. */
|
|
87
|
-
readonly encodeQueueWaitMs: number;
|
|
88
|
-
/** Time spent inside the browser encoder/muxer video-write adapter. */
|
|
89
|
-
readonly videoEncodeMs: number;
|
|
90
|
-
/** Time spent finalizing the encoder and muxer. */
|
|
91
|
-
readonly muxFinishMs: number;
|
|
92
|
-
readonly inFlightDepth: number;
|
|
93
|
-
readonly encodeChannelDepth: number;
|
|
94
|
-
readonly inFlightByteBudget: number;
|
|
95
|
-
readonly stagingBytesPerFrame: number;
|
|
96
|
-
readonly peakReadbackBytes: number;
|
|
97
|
-
/**
|
|
98
|
-
* Mapped staging bytes the export read back: the raw video that crossed from the GPU to script.
|
|
99
|
-
* Native reports the same field.
|
|
100
|
-
*/
|
|
101
|
-
readonly outputReadbackBytes: number;
|
|
102
|
-
/**
|
|
103
|
-
* Bytes script copied to pack read-back planes tight, because this browser's `VideoFrame` ignores
|
|
104
|
-
* `layout` (Safari). 0 where the frame reads the padded planes in place.
|
|
105
|
-
*/
|
|
106
|
-
readonly outputRepackBytes: number;
|
|
107
|
-
readonly peakEncodeQueueBytes: number;
|
|
108
|
-
readonly maxPendingMediaEvents: number;
|
|
109
|
-
readonly averagePendingMediaEvents: number;
|
|
110
|
-
readonly maxInFlightReadbacks: number;
|
|
111
|
-
readonly maxEncodeQueueEvents: number;
|
|
112
|
-
readonly encodeBackpressureCount: number;
|
|
113
|
-
readonly pipelineOverlapFrames: number;
|
|
114
|
-
}
|
|
115
|
-
/** Completion data shaped like the comparable part of a native export result. */
|
|
65
|
+
/** Completion data, shaped like the comparable part of a native export result. */
|
|
116
66
|
export interface BrowserExportResult {
|
|
117
67
|
readonly renderMs: number;
|
|
118
68
|
readonly frames: number;
|
|
119
69
|
readonly fps: number;
|
|
120
|
-
readonly performance:
|
|
70
|
+
readonly performance: BrowserExportPerformance;
|
|
71
|
+
/** Present when the sink reports it. */
|
|
72
|
+
readonly videoLatencyProbe?: VideoLatencyProbe;
|
|
73
|
+
/** Present when the sink reports it. */
|
|
74
|
+
readonly aacPrimingProbe?: AacEncoderProbe;
|
|
75
|
+
/** Present when the sink reports it. */
|
|
76
|
+
readonly videoEncoderAcceleration?: "no-preference" | "prefer-software";
|
|
121
77
|
}
|
|
122
78
|
/** Backend implemented by the worker that owns the shared wasm renderer. */
|
|
123
79
|
export interface ExportBackend {
|
|
124
80
|
/**
|
|
125
|
-
* Renders the frame
|
|
126
|
-
*
|
|
127
|
-
* frame's {@link ExportedFrame.timeTicks} (its `timestamp` is that time in whole microseconds,
|
|
128
|
-
* rounded down), so a sink that encodes the frame as it arrives starts its file at 0 too.
|
|
81
|
+
* Renders the frame at timeline time `timeTicks`, or reports which sources it still needs. The
|
|
82
|
+
* read-back `VideoFrame`'s `timestamp` is `outputTimeTicks` in whole microseconds, rounded down.
|
|
129
83
|
*/
|
|
130
84
|
begin(timeTicks: bigint, outputTimeTicks: bigint): Promise<ExportTicket>;
|
|
131
|
-
/**
|
|
85
|
+
/** Checked before every frame. */
|
|
132
86
|
isDeviceLost(): boolean;
|
|
133
|
-
/** Abandons the export after a failure the exporter detected
|
|
87
|
+
/** Abandons the export after a failure the exporter detected. */
|
|
134
88
|
abort(reason: Error): void;
|
|
135
89
|
}
|
|
136
|
-
/**
|
|
137
|
-
* Encoder/muxer adapter. Ownership of a frame transfers to `writeVideo`. Frame times count from the
|
|
138
|
-
* output's zero ({@link ExportedFrame.timeTicks}).
|
|
139
|
-
*/
|
|
90
|
+
/** Encoder and muxer adapter. Ownership of a frame transfers to `writeVideo`. */
|
|
140
91
|
export interface BrowserEncodeSink {
|
|
141
|
-
/**
|
|
92
|
+
/** Calls are serialized and arrive in output order. */
|
|
142
93
|
writeVideo(frame: ExportedFrame): Promise<void>;
|
|
143
94
|
/** Flushes the encoder and finalizes the container after the last frame. */
|
|
144
95
|
finish(): Promise<void>;
|
|
145
96
|
/** Discards partial output; called once when the export fails. */
|
|
146
97
|
abort(reason: Error): Promise<void> | void;
|
|
98
|
+
/** Copied into the result when present. */
|
|
99
|
+
readonly videoLatencyProbe?: VideoLatencyProbe;
|
|
100
|
+
readonly aacPrimingProbe?: AacEncoderProbe;
|
|
101
|
+
readonly videoEncoderAcceleration?: "no-preference" | "prefer-software";
|
|
102
|
+
readonly videoEncodeLatencyMs?: EncodeLatency;
|
|
147
103
|
}
|
|
148
104
|
/**
|
|
149
105
|
* An export stopped by cancellation (`cancelled`), a lost GPU device (`device-lost`) or a sink that
|
|
150
|
-
* threw a non-`Error` value (`adapter`).
|
|
106
|
+
* threw a non-`Error` value (`adapter`). The export can be restarted cleanly.
|
|
151
107
|
*/
|
|
152
108
|
export declare class ExportAbortedError extends Error {
|
|
153
109
|
readonly code: "cancelled" | "device-lost" | "adapter";
|
|
154
110
|
constructor(code: "cancelled" | "device-lost" | "adapter", message: string, options?: ErrorOptions);
|
|
155
111
|
}
|
|
156
112
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
113
|
+
* Browser export scheduler that walks the frame grid of `rate` over a timeline range. Encoding and
|
|
114
|
+
* muxing stay with the host.
|
|
159
115
|
*/
|
|
160
116
|
export declare class Alpha2Exporter {
|
|
161
117
|
#private;
|
|
@@ -167,19 +123,17 @@ export declare class Alpha2Exporter {
|
|
|
167
123
|
*/
|
|
168
124
|
constructor(backend: ExportBackend, rate: RationalFrameRate, startTicks: bigint, endTicks: bigint);
|
|
169
125
|
/**
|
|
170
|
-
* The
|
|
171
|
-
*
|
|
172
|
-
* export's audio.
|
|
126
|
+
* The requested range widened to the frame grid, `[floor(start), ceil(end))`. Its start is
|
|
127
|
+
* output time zero, where the host should also start the audio.
|
|
173
128
|
*/
|
|
174
129
|
get effectiveRange(): {
|
|
175
130
|
readonly startTicks: bigint;
|
|
176
131
|
readonly endTicks: bigint;
|
|
177
132
|
};
|
|
178
133
|
/**
|
|
179
|
-
* The
|
|
180
|
-
* {@link effectiveRange}'s start to the one nearest its end,
|
|
181
|
-
* `export_audio_window
|
|
182
|
-
* the output's zero.
|
|
134
|
+
* The audio samples this export covers at `sampleRate`, from the sample nearest
|
|
135
|
+
* {@link effectiveRange}'s start to the one nearest its end, matching the engine's
|
|
136
|
+
* `export_audio_window`. `startSample` is the mix position at output time zero.
|
|
183
137
|
*
|
|
184
138
|
* @throws RangeError when `sampleRate` is not a positive safe integer.
|
|
185
139
|
*/
|
|
@@ -187,45 +141,42 @@ export declare class Alpha2Exporter {
|
|
|
187
141
|
readonly startSample: bigint;
|
|
188
142
|
readonly frames: bigint;
|
|
189
143
|
};
|
|
190
|
-
/** Frames whose readback has resolved, out of the
|
|
144
|
+
/** Frames whose readback has resolved, out of the total. */
|
|
191
145
|
get progress(): {
|
|
192
146
|
readonly completed: bigint;
|
|
193
147
|
readonly total: bigint;
|
|
194
148
|
};
|
|
195
149
|
/**
|
|
196
|
-
* Submits the next frame. Calls are serialized
|
|
197
|
-
*
|
|
198
|
-
* uploading the missing sources.
|
|
150
|
+
* Submits the next frame. Calls are serialized. A `waiting` result leaves the frame unsubmitted;
|
|
151
|
+
* call again after uploading the missing sources.
|
|
199
152
|
*
|
|
200
153
|
* Rejects with an {@link ExportAbortedError} coded `device-lost` (after aborting the backend)
|
|
201
|
-
* when the GPU device is lost,
|
|
154
|
+
* when the GPU device is lost, or with the backend's error.
|
|
202
155
|
*/
|
|
203
156
|
next(): Promise<ExportAdvance>;
|
|
204
157
|
}
|
|
205
158
|
/**
|
|
206
|
-
* Runs an exporter into
|
|
207
|
-
* `maxInFlightFrames` frames and `maxInFlightBytes` readback bytes in flight.
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
* `sources-not-held
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
159
|
+
* Runs an exporter into a WebCodecs or mediabunny-compatible sink, keeping at most
|
|
160
|
+
* `maxInFlightFrames` frames and `maxInFlightBytes` readback bytes in flight.
|
|
161
|
+
*
|
|
162
|
+
* `refill` uploads the source frames named in `missingFrames` before the frame is requested again.
|
|
163
|
+
* A frame still waiting after four refills fails with `RESOURCE_LIMIT` at stage
|
|
164
|
+
* `sources-not-held`; an upload over the binding's frame budget fails with `RESOURCE_LIMIT` at
|
|
165
|
+
* stage `working-set-over-budget`. `decideRetry` retries neither.
|
|
166
|
+
*
|
|
167
|
+
* A refill rejected with `SOFTWARE_DECODE_REQUIRED` is retried once with `decode: "software"` on
|
|
168
|
+
* that `missingFrames` entry, and a `non-planar` source is requested in software from then on.
|
|
169
|
+
* `refill` must honor `decode`.
|
|
215
170
|
*
|
|
216
|
-
* `refill` must
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
* A coordinator resolves a request from a generation older than its own without delivering it,
|
|
220
|
-
* so the preview's, past generation 0 after its first seek, would drop the export's refills
|
|
221
|
-
* silently and the frame would fail at `sources-not-held`.
|
|
171
|
+
* `refill` must use a `DecoderRefillCoordinator` created for this export (requests at generation
|
|
172
|
+
* 0), not the preview's. The preview's coordinator moves past generation 0 after its first seek
|
|
173
|
+
* and would silently drop the export's requests.
|
|
222
174
|
*
|
|
223
|
-
* Resolves after `sink.finish()` with timing and memory metrics
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
* `
|
|
228
|
-
*
|
|
229
|
-
* `abort` that throws does not replace that failure ({@link recordCleanupFailure}).
|
|
175
|
+
* Resolves after `sink.finish()` with timing and memory metrics. Aborting `signal`, even during
|
|
176
|
+
* `finish()`, rejects immediately; late results are closed. On other failures, held frames are
|
|
177
|
+
* closed and pending writes awaited. In both cases `sink.abort` is called once and the promise
|
|
178
|
+
* rejects with an {@link ExportAbortedError}, a `RESOURCE_LIMIT` `ExportFailureError`, a
|
|
179
|
+
* `RangeError` for an invalid option, or the error from the backend, `refill` or sink. An error
|
|
180
|
+
* thrown by `sink.abort` does not replace it.
|
|
230
181
|
*/
|
|
231
182
|
export declare function exportToSink(exporter: Alpha2Exporter, sink: BrowserEncodeSink, refill: (waiting: ExportWaiting) => Promise<void>, options?: BrowserExportOptions): Promise<BrowserExportResult>;
|