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/media.d.ts
CHANGED
|
@@ -1,211 +1,105 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* How much later than a requested time a decoded frame's timestamp may be and still be the frame
|
|
3
|
-
* shown at it, for a stream whose time resolution is not known: 0.5 ms and one tick, a millisecond
|
|
4
|
-
* time base's slack. It is also the most a stream whose timestamps show no rounding of their own is
|
|
5
|
-
* given. The engine's `PRESENTATION_SLACK`.
|
|
6
|
-
*/
|
|
1
|
+
/** Presentation slack for an unknown time resolution (0.5 ms plus one tick); also the cap. */
|
|
7
2
|
export declare const PRESENTATION_SLACK_TICKS = 61n;
|
|
8
|
-
/**
|
|
9
|
-
* How many of a stream's first packets {@link roundingQuantum} reads the timestamps of: at most
|
|
10
|
-
* this many, and none once the packets read hold {@link ROUNDING_SCAN_BYTES}. The engine's
|
|
11
|
-
* `ROUNDING_SCAN_FRAMES`.
|
|
12
|
-
*/
|
|
3
|
+
/** Most leading packets read for {@link roundingQuantum}. Matches the engine. */
|
|
13
4
|
export declare const ROUNDING_SCAN_FRAMES = 64;
|
|
14
|
-
/**
|
|
15
|
-
* The packet bytes (16 MiB) past which no more of a stream's first packets are read for {@link
|
|
16
|
-
* roundingQuantum}, as a native host stops. The engine's `ROUNDING_SCAN_BYTES`.
|
|
17
|
-
*/
|
|
5
|
+
/** Packet bytes (16 MiB) after which no more leading packets are read. */
|
|
18
6
|
export declare const ROUNDING_SCAN_BYTES: number;
|
|
19
7
|
/**
|
|
20
|
-
* The unit a stream's timestamps are rounded to,
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* `
|
|
25
|
-
* resolution, in any order: {@link ROUNDING_SCAN_FRAMES} of them, fewer when those before hold
|
|
26
|
-
* {@link ROUNDING_SCAN_BYTES}. A frame interval that is not a whole number of a rounding unit comes
|
|
27
|
-
* out of the rounding as two lengths a unit apart (29.97 fps in milliseconds is 33 and 34 ms), so
|
|
28
|
-
* the unit is the greatest common divisor of the differences between the intervals. Intervals all
|
|
29
|
-
* of one length show none, and so do intervals whose differences are as long as half the shortest
|
|
30
|
-
* (a variable frame rate, such as 60 and 30 fps frames in an exact 1/90000 time base), and fewer
|
|
31
|
-
* than three distinct timestamps. Throws `RangeError` for a timestamp that is not a safe integer.
|
|
8
|
+
* The unit a stream's timestamps are rounded to, in units of its time resolution, or 0 when none
|
|
9
|
+
* shows. A frame interval that is not a whole number of units rounds to two lengths a unit apart
|
|
10
|
+
* (29.97 fps in ms gives 33 and 34), so the unit is the GCD of the interval differences. Returns 0
|
|
11
|
+
* for uniform or variable frame rates and for fewer than three distinct timestamps.
|
|
12
|
+
* Throws `RangeError` for a timestamp that is not a safe integer.
|
|
32
13
|
*/
|
|
33
14
|
export declare function roundingQuantum(timestamps: readonly number[]): number;
|
|
34
15
|
/**
|
|
35
|
-
* The
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* A container that rounds timestamps (Matroska and WebM to the millisecond) stores a frame up to
|
|
40
|
-
* half its unit from where the frame starts, 24 samples at 48 kHz, so a frame placed by its own
|
|
41
|
-
* timestamp after a seek and the same frame reached by decoding straight through land apart. A
|
|
42
|
-
* codec whose frames are all one length (AAC's 1024 samples, Opus's 20 ms) puts every frame on one
|
|
43
|
-
* grid, which the first timestamps together locate: a first frame placed on it gives the samples
|
|
44
|
-
* a decode straight through gives, however it is reached.
|
|
16
|
+
* The samples an audio stream's frames start at: every `period` samples from `anchor`. Lets frames
|
|
17
|
+
* with millisecond-rounded timestamps (Matroska, WebM) land on the same samples after a seek as in
|
|
18
|
+
* a straight decode.
|
|
45
19
|
*/
|
|
46
20
|
export interface AudioFrameGrid {
|
|
47
|
-
/** A source sample, at the stream's rate, that a frame starts at. */
|
|
48
21
|
readonly anchor: number;
|
|
49
|
-
/** The samples in every frame. */
|
|
50
22
|
readonly period: number;
|
|
51
|
-
/**
|
|
52
|
-
* The farthest a frame's timestamp, as a sample, is from the start it stands for: half the
|
|
53
|
-
* rounding unit and the half sample of rounding it to a sample, rounded down after adding one.
|
|
54
|
-
*/
|
|
55
23
|
readonly startTolerance: number;
|
|
56
|
-
/**
|
|
57
|
-
* The farthest the end of a frame shorter than `period` is from the grid: a decoder that drops a
|
|
58
|
-
* codec's delay from its first frame after a start or a seek (Opus's pre-skip) moves its
|
|
59
|
-
* timestamp by the samples dropped, rounded again, so twice the half unit and a sample.
|
|
60
|
-
*/
|
|
24
|
+
/** Wider than `startTolerance` because dropping codec delay (Opus pre-skip) rounds again. */
|
|
61
25
|
readonly trimmedTolerance: number;
|
|
62
26
|
}
|
|
63
27
|
/**
|
|
64
|
-
* The frame grid an audio stream's first packet timestamps show at `sampleRate`, for
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* `timestamps` are the first packets' presentation times as whole units of the resolution, in any
|
|
70
|
-
* order, read as for {@link roundingQuantum}. Their rounding unit is its quantum, or one unit when
|
|
71
|
-
* they show none. The grid is one every timestamp is within half a unit of: of the whole-sample
|
|
72
|
-
* periods within a unit over their count of their span over it, the one that leaves the most room,
|
|
73
|
-
* the shortest of those that leave as much; and of the anchors it leaves, the middle one, rounded
|
|
74
|
-
* to a sample. There is none when half the unit is under a sample (a time base of the sample rate),
|
|
75
|
-
* when fewer than three distinct timestamps are given or no grid holds them all (frames of several
|
|
76
|
-
* lengths, a missing packet), when no period longer than twice the trimmed tolerance holds them, or
|
|
77
|
-
* when the resolution or the rate is not a positive integer. Throws `RangeError` for a timestamp
|
|
78
|
-
* that is not a safe integer.
|
|
28
|
+
* The frame grid an audio stream's first packet timestamps show at `sampleRate`, for timestamps in
|
|
29
|
+
* whole units of `1 / timeResolution` seconds. Matches the engine's `audio_frame_grid`. Returns
|
|
30
|
+
* `undefined` when the timestamps do not fix a grid (too few, mixed frame lengths, a missing
|
|
31
|
+
* packet, sub-sample rounding) or the resolution or rate is not a positive integer.
|
|
32
|
+
* Throws `RangeError` for a timestamp that is not a safe integer.
|
|
79
33
|
*/
|
|
80
34
|
export declare function audioFrameGrid(timestamps: readonly number[], timeResolution: number, sampleRate: number): AudioFrameGrid | undefined;
|
|
81
35
|
/**
|
|
82
|
-
* Where a frame of `frames` samples
|
|
83
|
-
* `
|
|
84
|
-
*
|
|
85
|
-
* pre-skip): it ends on the grid. The engine's `AudioFrameGrid::place`.
|
|
36
|
+
* Where a frame of `frames` samples with timestamp sample `at` starts: on `grid` when within its
|
|
37
|
+
* tolerance, otherwise at `at`. A short frame is taken as start-trimmed (Opus pre-skip), so its end
|
|
38
|
+
* goes on the grid.
|
|
86
39
|
*/
|
|
87
40
|
export declare function placeOnAudioFrameGrid(grid: AudioFrameGrid, at: number, frames: number): number;
|
|
88
41
|
/**
|
|
89
42
|
* How much later than a requested time a decoded frame's timestamp may be and still be the frame
|
|
90
|
-
* shown at it,
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* `presentationSlackTicks(1, timeResolution, quantum)`.
|
|
94
|
-
*
|
|
95
|
-
* A stream whose timestamps show a rounding is given half of it, rounded up to a tick, and one tick
|
|
96
|
-
* more, however coarse (61 ticks for milliseconds, 101 for 29.97 fps in 1/600). One that shows none
|
|
97
|
-
* is given half its unit, rounded up to a tick, and one tick more, at most {@link
|
|
98
|
-
* PRESENTATION_SLACK_TICKS}: its frames are exact in the time base. A resolution not known is
|
|
99
|
-
* {@link PRESENTATION_SLACK_TICKS}.
|
|
100
|
-
*
|
|
101
|
-
* The frame shown at a time is the last one at or before `time + slack`: a timestamp is rounded to
|
|
102
|
-
* its time base (Matroska's millisecond) and to the nearest tick, while a project frame's time is
|
|
103
|
-
* floored, so the frame truly shown can carry a timestamp a few ticks late. A native host decides
|
|
104
|
-
* the same way.
|
|
43
|
+
* shown at it, in ticks: half the timestamp rounding unit, rounded up, plus one tick.
|
|
44
|
+
* `timeResolution` is mediabunny's `getTimeResolution()`, `quantum` from {@link roundingQuantum}
|
|
45
|
+
* (0 for none). Unknown resolutions get {@link PRESENTATION_SLACK_TICKS}.
|
|
105
46
|
*/
|
|
106
47
|
export declare function presentationSlackTicks(timeResolution?: number, quantum?: number): bigint;
|
|
107
|
-
/**
|
|
108
|
-
* The longest `stallTimeoutMs` a decoder takes, about 24.8 days: timers hold their delay in a
|
|
109
|
-
* signed 32-bit integer, and a longer one fires at once (Node) or wraps (browsers), which would
|
|
110
|
-
* fail every read as a stall.
|
|
111
|
-
*/
|
|
48
|
+
/** About 24.8 days; timers misfire past a signed 32-bit delay. */
|
|
112
49
|
export declare const MAX_STALL_TIMEOUT_MS = 2147483647;
|
|
113
50
|
/**
|
|
114
|
-
* Throws `RangeError` unless `value` is
|
|
115
|
-
* {@link MAX_STALL_TIMEOUT_MS}.
|
|
51
|
+
* Throws `RangeError` unless `value` is whole milliseconds in 1..{@link MAX_STALL_TIMEOUT_MS}.
|
|
116
52
|
*
|
|
117
|
-
* @internal
|
|
53
|
+
* @internal
|
|
118
54
|
*/
|
|
119
55
|
export declare function validateStallTimeout(value: number): void;
|
|
120
|
-
/** Why the engine needs a decoded source frame. */
|
|
121
56
|
export type DecoderRefillReason = "prefetch" | "seek" | "evicted" | "device-recovery";
|
|
122
57
|
/** A request for the frame of one source presented at a time, shared by every video decoder. */
|
|
123
58
|
export interface DecoderRefillRequest {
|
|
124
|
-
/** The source the decoder was opened for; a decoder rejects any other. */
|
|
125
59
|
readonly sourceId: string;
|
|
126
60
|
/** Source time, in ticks (120 000 per second). */
|
|
127
61
|
readonly mediaTimeTicks: bigint;
|
|
128
62
|
/** `seek` and `device-recovery` always restart decoding from a keyframe. */
|
|
129
63
|
readonly reason: DecoderRefillReason;
|
|
130
|
-
/**
|
|
131
|
-
* The seek generation the request belongs to. A request from a new generation drops the
|
|
132
|
-
* decoder's cursor and cached frames; a frame answered for an older one is stale.
|
|
133
|
-
*/
|
|
64
|
+
/** A request from a newer generation drops the cursor and cache; older frames are stale. */
|
|
134
65
|
readonly generation: number;
|
|
135
|
-
/**
|
|
136
|
-
* Who reads the source sequentially ({@link decoderConsumerId}): requests with different
|
|
137
|
-
* consumers keep different decode cursors, as the engine requires of two clips, or two
|
|
138
|
-
* composition steps, reading one source at different times. Absent, the source has one cursor.
|
|
139
|
-
*/
|
|
66
|
+
/** Each consumer ({@link decoderConsumerId}) keeps its own decode cursor. */
|
|
140
67
|
readonly consumerId?: string;
|
|
68
|
+
/** `"software"` decodes on the CPU, for a host that cannot take the browser decoder's frame. */
|
|
69
|
+
readonly decode?: "default" | "software";
|
|
141
70
|
}
|
|
142
|
-
/**
|
|
143
|
-
* The consumer that owns a decode cursor: the clip, or one composition step of it (`readerId`)
|
|
144
|
-
* that reads a source on its own. A decoder shared by two of them would seek on every frame.
|
|
145
|
-
*/
|
|
71
|
+
/** The owner of a decode cursor: a clip, or a composition step that reads the source itself. */
|
|
146
72
|
export declare function decoderConsumerId(clipId: string, readerId?: string | null): string;
|
|
147
|
-
/**
|
|
148
|
-
* How a video's pictures are shown upright: mirrored left to right when `mirror` is set, then
|
|
149
|
-
* turned clockwise by `rotationDegrees`. The eight together are every orientation a container
|
|
150
|
-
* states with a multiple of 90 degrees, as the engine's media contract carries it.
|
|
151
|
-
*/
|
|
73
|
+
/** Mirrored left to right when `mirror` is set, then rotated clockwise by `rotationDegrees`. */
|
|
152
74
|
export interface VideoOrientation {
|
|
153
75
|
readonly rotationDegrees: 0 | 90 | 180 | 270;
|
|
154
76
|
readonly mirror: boolean;
|
|
155
77
|
}
|
|
156
78
|
/** Shown as stored. */
|
|
157
79
|
export declare const UPRIGHT: VideoOrientation;
|
|
158
|
-
/** A container file, or its bytes. */
|
|
159
80
|
export type ContainerBytes = Blob | ArrayBuffer | ArrayBufferView;
|
|
160
81
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* the `tkhd` track ID or the Matroska `TrackNumber`, which mediabunny reports as `InputTrack.id`. A
|
|
165
|
-
* matrix that turns by other than a multiple of 90 degrees is shown upright, as natively.
|
|
166
|
-
*
|
|
167
|
-
* Resolves to `undefined` for any other container, or one whose header this cannot find; demuxers
|
|
168
|
-
* report a rotation but not a mirror, so a caller then has only the rotation its demuxer reports.
|
|
82
|
+
* Reads track `trackId`'s orientation, mirror included, from MP4/QuickTime `tkhd`/`mvhd` matrices
|
|
83
|
+
* or the Matroska projection pose, as `FFmpeg` does. `trackId` is mediabunny's `InputTrack.id`.
|
|
84
|
+
* Resolves to `undefined` for other containers or when the header is not found.
|
|
169
85
|
*/
|
|
170
86
|
export declare function readVideoOrientation(container: ContainerBytes, trackId: number): Promise<VideoOrientation | undefined>;
|
|
171
87
|
/**
|
|
172
|
-
* The `CodecDelay` a Matroska or WebM file declares for track `trackId
|
|
173
|
-
*
|
|
174
|
-
* specification has a reader subtract it from every block time, and native decoding (FFmpeg) does,
|
|
175
|
-
* rounded to the track's time base; mediabunny does not. `trackId` is the Matroska `TrackNumber`,
|
|
176
|
-
* which mediabunny reports as `InputTrack.id`.
|
|
177
|
-
*
|
|
178
|
-
* Resolves to 0 for a track that declares none, and for any other container.
|
|
88
|
+
* The `CodecDelay` a Matroska or WebM file declares for track `trackId` (mediabunny's
|
|
89
|
+
* `InputTrack.id`), in nanoseconds; 0 when none. Readers should subtract it; mediabunny does not.
|
|
179
90
|
*/
|
|
180
91
|
export declare function readMatroskaCodecDelay(container: ContainerBytes, trackId: number): Promise<number>;
|
|
181
92
|
/** A demuxer-independent encoded video source consumed by WebCodecs. */
|
|
182
93
|
export interface EncodedVideoSource {
|
|
183
94
|
readonly config: VideoDecoderConfig;
|
|
184
|
-
/**
|
|
185
|
-
* Clockwise turn that shows the pictures upright, after {@link mirror}. {@link
|
|
186
|
-
* readVideoOrientation} reads both from an MP4, QuickTime, or Matroska file.
|
|
187
|
-
*/
|
|
95
|
+
/** Clockwise turn after {@link mirror}; {@link readVideoOrientation} reads both. */
|
|
188
96
|
readonly rotationDegrees?: 0 | 90 | 180 | 270;
|
|
189
|
-
/** Whether the pictures are mirrored left to right before they turn. */
|
|
190
97
|
readonly mirror?: boolean;
|
|
191
|
-
/**
|
|
192
|
-
* The units per second the chunks' timestamps are whole multiples of, when the demuxer knows it
|
|
193
|
-
* (mediabunny's `getTimeResolution()`): it bounds how late a frame's timestamp may be and still
|
|
194
|
-
* be the frame shown at a time ({@link presentationSlackTicks}).
|
|
195
|
-
*/
|
|
98
|
+
/** Units per second of the chunk timestamps (mediabunny's `getTimeResolution()`), if known. */
|
|
196
99
|
readonly timeResolution?: number;
|
|
197
|
-
/**
|
|
198
|
-
* The unit, of {@link timeResolution}, the stream's timestamps are rounded to, as the first ones
|
|
199
|
-
* show ({@link roundingQuantum} of the first chunks' times, up to {@link ROUNDING_SCAN_FRAMES}
|
|
200
|
-
* and {@link ROUNDING_SCAN_BYTES}); 0 or absent when they show none. It widens the slack past
|
|
201
|
-
* what the resolution alone gives: an MP4 that kept a Matroska file's milliseconds in a 1/16000
|
|
202
|
-
* time base needs a millisecond's.
|
|
203
|
-
*/
|
|
100
|
+
/** The timestamps' rounding unit ({@link roundingQuantum}); widens the presentation slack. */
|
|
204
101
|
readonly roundingQuantum?: number;
|
|
205
|
-
/**
|
|
206
|
-
* The stream's chunks in decode order, starting at the keyframe at or before `mediaTimeTicks`
|
|
207
|
-
* (the first keyframe when none is). Stops early when `signal` aborts.
|
|
208
|
-
*/
|
|
102
|
+
/** Chunks in decode order from the keyframe at or before `mediaTimeTicks` (else the first). */
|
|
209
103
|
chunksFrom(mediaTimeTicks: bigint, signal: AbortSignal): AsyncIterable<EncodedVideoChunk>;
|
|
210
104
|
}
|
|
211
105
|
/** Decoded output with explicit ownership: the receiver must close `frame`. */
|
|
@@ -215,88 +109,53 @@ export interface BrowserDecodedFrame {
|
|
|
215
109
|
readonly decodedTimeTicks: bigint;
|
|
216
110
|
readonly generation: number;
|
|
217
111
|
readonly frame: VideoFrame;
|
|
218
|
-
/** Clockwise turn
|
|
112
|
+
/** Clockwise turn applied after {@link mirror}. */
|
|
219
113
|
readonly rotationDegrees?: 0 | 90 | 180 | 270;
|
|
220
|
-
/** Whether the frame is mirrored left to right before it turns. */
|
|
221
114
|
readonly mirror?: boolean;
|
|
222
|
-
/**
|
|
223
|
-
* Where chroma samples sit, which WebCodecs does not report: see {@link chromaSitingForStream}.
|
|
224
|
-
*/
|
|
115
|
+
/** WebCodecs does not report it; see {@link chromaSitingForStream}. */
|
|
225
116
|
readonly chromaSiting?: ChromaSiting;
|
|
117
|
+
/** Set on a frame a `decode: "software"` request was answered with. */
|
|
118
|
+
readonly decode?: "software";
|
|
226
119
|
}
|
|
227
120
|
/** Public browser decoder contract; no optional demuxer types leak through it. */
|
|
228
121
|
export interface BrowserVideoDecoder {
|
|
229
122
|
/**
|
|
230
|
-
* Resolves to the frame
|
|
231
|
-
*
|
|
232
|
-
* stream's presentation slack (`presentationSlackTicks`), as the native decoder resolves a time.
|
|
233
|
-
* A stream whose first frame is later answers with that frame, and past the end the last frame
|
|
234
|
-
* answers. `decodedTimeTicks` is the frame's own time.
|
|
123
|
+
* Resolves to the last frame at or before `request.mediaTimeTicks` plus the presentation slack;
|
|
124
|
+
* the first frame before the stream starts and the last past its end.
|
|
235
125
|
*/
|
|
236
126
|
refill(request: DecoderRefillRequest, signal?: AbortSignal): Promise<BrowserDecodedFrame>;
|
|
237
127
|
/** Drops the decode cursor and every cached frame; the next request seeks. */
|
|
238
128
|
flush(): Promise<void>;
|
|
239
|
-
/** Releases the decoder and
|
|
129
|
+
/** Releases the decoder and its frames. Frames already returned stay the caller's. */
|
|
240
130
|
close(): void;
|
|
241
131
|
}
|
|
242
|
-
/**
|
|
243
|
-
* Limits for {@link WebCodecsVideoDecoder}. Each must be a positive safe integer, and
|
|
244
|
-
* `stallTimeoutMs` at most {@link MAX_STALL_TIMEOUT_MS}.
|
|
245
|
-
*/
|
|
132
|
+
/** Each must be a positive safe integer; `stallTimeoutMs` at most {@link MAX_STALL_TIMEOUT_MS}. */
|
|
246
133
|
export interface BrowserVideoDecoderOptions {
|
|
247
|
-
/**
|
|
248
|
-
* Bytes of decoded frames the cache keeps (default 64 MiB). It never evicts below two frames,
|
|
249
|
-
* which answering a time takes, however large they are.
|
|
250
|
-
*/
|
|
134
|
+
/** Bytes of decoded frames cached (default 64 MiB). Never evicts below two frames. */
|
|
251
135
|
readonly maxCachedFrameBytes?: number;
|
|
252
|
-
/**
|
|
253
|
-
* Bytes of decoded frames queued ahead of the cursor (default 64 MiB). Past it, queued frames
|
|
254
|
-
* earlier than the requested time move to the cache, keeping at least one queued.
|
|
255
|
-
*/
|
|
136
|
+
/** Bytes of decoded frames queued ahead of the cursor (default 64 MiB). */
|
|
256
137
|
readonly maxReadyFrameBytes?: number;
|
|
257
|
-
/**
|
|
258
|
-
* Frames the reverse-window cache keeps at most (default 2, at least 2). Each holds a decoder
|
|
259
|
-
* surface.
|
|
260
|
-
*/
|
|
138
|
+
/** Frames cached at most (default 2, at least 2). Each holds a decoder surface. */
|
|
261
139
|
readonly maxCachedFrames?: number;
|
|
262
|
-
/**
|
|
263
|
-
* Milliseconds a decoder may produce no output while chunks are queued before the refill fails
|
|
264
|
-
* (default 5000, at most {@link MAX_STALL_TIMEOUT_MS}). Before failing, the cache is released,
|
|
265
|
-
* since its frames hold decoder surfaces. Also bounds EOF flush; abort or timeout closes that
|
|
266
|
-
* decoder and releases its cached frames.
|
|
267
|
-
*/
|
|
140
|
+
/** Milliseconds without decoder output before the refill fails (default 5000). */
|
|
268
141
|
readonly stallTimeoutMs?: number;
|
|
269
142
|
}
|
|
270
|
-
/**
|
|
271
|
-
* The loudspeaker one plane of an audio block feeds, by `FFmpeg`'s channel name: front left, right
|
|
272
|
-
* and center, low-frequency, back, left and right of center, side, top and bottom positions, a
|
|
273
|
-
* matrix downmix's Lt/Rt (`DL`, `DR`), wide, surround direct, binaural. `UNK` is a plane no speaker
|
|
274
|
-
* names (unknown, ambisonic), which the engine leaves out of its fold.
|
|
275
|
-
*/
|
|
143
|
+
/** Loudspeaker by `FFmpeg` channel name. `UNK` planes (unknown, ambisonic) are not mixed. */
|
|
276
144
|
export type AudioSpeaker = "FL" | "FR" | "FC" | "LFE" | "BL" | "BR" | "FLC" | "FRC" | "BC" | "SL" | "SR" | "TC" | "TFL" | "TFC" | "TFR" | "TBL" | "TBC" | "TBR" | "DL" | "DR" | "WL" | "WR" | "SDL" | "SDR" | "LFE2" | "TSL" | "TSR" | "BFC" | "BFL" | "BFR" | "SSL" | "SSR" | "TTL" | "TTR" | "BIL" | "BIR" | "UNK";
|
|
277
|
-
/**
|
|
278
|
-
* Most channels a decoded {@link BrowserAudioBlock} carries: a 22.2 layout's 24, the most of any
|
|
279
|
-
* layout `FFmpeg` names. A source with more is refused by browser and native hosts alike.
|
|
280
|
-
*/
|
|
145
|
+
/** A 22.2 layout's 24; sources with more are refused. */
|
|
281
146
|
export declare const MAX_AUDIO_CHANNELS = 24;
|
|
282
147
|
/** Owned project-rate planar audio returned by browser adapters. */
|
|
283
148
|
export interface BrowserAudioBlock {
|
|
284
149
|
readonly sourceId: string;
|
|
285
150
|
/**
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
* position written there). Never ticks, which are not a whole number of samples at 44.1 kHz.
|
|
151
|
+
* First sample at `sampleRate`: in the source for a decoded block, on the project timeline for a
|
|
152
|
+
* mixed one, from the output's start for an encode sink. Samples because ticks are not whole
|
|
153
|
+
* samples at 44.1 kHz.
|
|
290
154
|
*/
|
|
291
155
|
readonly startSample: bigint;
|
|
292
156
|
readonly generation: number;
|
|
293
157
|
readonly sampleRate: number;
|
|
294
|
-
/**
|
|
295
|
-
* The speaker each plane of `channels` feeds, in plane order: the layout the source declares, in
|
|
296
|
-
* the order its planes arrive. Absent when the source declares none: the engine then assumes
|
|
297
|
-
* `FFmpeg`'s default for the channel count (mono, stereo, 2.1, 4.0, 5.0, 5.1, 6.1, 7.1, ...), as
|
|
298
|
-
* a native host does. The engine folds the planes into the project's channels by these speakers.
|
|
299
|
-
*/
|
|
158
|
+
/** Speaker per plane; absent means `FFmpeg`'s default layout for the channel count. */
|
|
300
159
|
readonly speakers?: readonly AudioSpeaker[];
|
|
301
160
|
readonly channels: readonly Float32Array[];
|
|
302
161
|
}
|
|
@@ -309,64 +168,58 @@ export interface AudioDecoderRefillRequest {
|
|
|
309
168
|
}
|
|
310
169
|
/** Demuxer-independent browser audio decoder. */
|
|
311
170
|
export interface BrowserAudioDecoder {
|
|
312
|
-
/**
|
|
313
|
-
* Decodes the requested source interval, resampled to `projectSampleRate`. Rejects when the
|
|
314
|
-
* decoder is closed, the request names another source, or `signal` aborts.
|
|
315
|
-
*/
|
|
171
|
+
/** Rejects when closed, for another source, or when `signal` aborts. */
|
|
316
172
|
refill(request: AudioDecoderRefillRequest, projectSampleRate: number, signal?: AbortSignal): Promise<BrowserAudioBlock>;
|
|
317
|
-
/** Releases the decoder; a later `refill` rejects. */
|
|
318
173
|
close(): void;
|
|
319
174
|
}
|
|
320
175
|
/** WebCodecs adapter for elementary chunks supplied by any demuxer. */
|
|
321
176
|
export declare class WebCodecsVideoDecoder implements BrowserVideoDecoder {
|
|
322
177
|
#private;
|
|
323
|
-
/**
|
|
324
|
-
* Throws `RangeError` when an option is not a positive safe integer, `maxCachedFrames` is below
|
|
325
|
-
* 2, or `stallTimeoutMs` is above {@link MAX_STALL_TIMEOUT_MS}.
|
|
326
|
-
*/
|
|
178
|
+
/** Throws `RangeError` for invalid options (see {@link BrowserVideoDecoderOptions}). */
|
|
327
179
|
constructor(sourceId: string, source: EncodedVideoSource, options?: BrowserVideoDecoderOptions);
|
|
328
|
-
/**
|
|
180
|
+
/** Why decoding moved to software after the browser's first pick failed, if it did. */
|
|
181
|
+
get softwareFallback(): string | undefined;
|
|
329
182
|
get cachedFrameBytes(): number;
|
|
330
|
-
/** Requests answered from the cache without decoding. */
|
|
331
183
|
get reverseCacheHits(): number;
|
|
184
|
+
/**
|
|
185
|
+
* A decoder failure retries once from the keyframe with `"prefer-software"`. If that fails too,
|
|
186
|
+
* rejects with `DecodeUnavailableError` when no frame was ever decoded, else with the failure.
|
|
187
|
+
*/
|
|
332
188
|
refill(request: DecoderRefillRequest, signal?: AbortSignal): Promise<BrowserDecodedFrame>;
|
|
333
189
|
flush(): Promise<void>;
|
|
334
190
|
close(): void;
|
|
335
191
|
}
|
|
336
192
|
/** Limits for a {@link DecoderRefillCoordinator}. Each must be a positive safe integer. */
|
|
337
193
|
export interface DecoderRefillCoordinatorOptions {
|
|
338
|
-
/**
|
|
194
|
+
/** Concurrent refills across sources (default 2). */
|
|
339
195
|
readonly maxConcurrency?: number;
|
|
340
|
-
/**
|
|
341
|
-
* Decoders kept open per source, one per consumer reading it (default 4). Past it, the one used
|
|
342
|
-
* least recently is closed; each open decoder holds decoder surfaces.
|
|
343
|
-
*/
|
|
196
|
+
/** Decoders kept open per source (default 4); the least recently used one closes past it. */
|
|
344
197
|
readonly maxCursorsPerSource?: number;
|
|
345
198
|
}
|
|
199
|
+
/** What a {@link DecoderRefillCoordinator} asks its opener for. */
|
|
200
|
+
export interface DecoderOpenOptions {
|
|
201
|
+
/** An opener without a software decoder rejects with `code: "software_decode_unavailable"`. */
|
|
202
|
+
readonly decode: "default" | "software";
|
|
203
|
+
}
|
|
346
204
|
/**
|
|
347
|
-
* Runs refills
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
* at once, delivering each frame through `deliver`. A newer generation aborts the requests in
|
|
351
|
-
* flight; a frame decoded for an older one is closed instead of delivered.
|
|
205
|
+
* Runs refills on decoders it opens, one per source and consumer (plus one for software), with
|
|
206
|
+
* one refill per source at a time and at most `maxConcurrency` overall. A newer generation aborts
|
|
207
|
+
* requests in flight and closes their frames instead of delivering them.
|
|
352
208
|
*/
|
|
353
209
|
export declare class DecoderRefillCoordinator {
|
|
354
210
|
#private;
|
|
355
211
|
/**
|
|
356
|
-
* `open`
|
|
357
|
-
*
|
|
358
|
-
* a positive safe integer.
|
|
212
|
+
* A rejected `open` rejects that refill; `software_decode_unavailable` becomes
|
|
213
|
+
* `PlanarDecodeUnavailableError`. Throws `RangeError` for invalid options.
|
|
359
214
|
*/
|
|
360
|
-
constructor(open: (sourceId: string) => BrowserVideoDecoder | Promise<BrowserVideoDecoder>, deliver: (frame: BrowserDecodedFrame) => Promise<void>, options?: DecoderRefillCoordinatorOptions);
|
|
361
|
-
/** Aborts
|
|
215
|
+
constructor(open: (sourceId: string, options: DecoderOpenOptions) => BrowserVideoDecoder | Promise<BrowserVideoDecoder>, deliver: (frame: BrowserDecodedFrame) => Promise<void>, options?: DecoderRefillCoordinatorOptions);
|
|
216
|
+
/** Aborts requests in flight and returns the new generation number. */
|
|
362
217
|
beginGeneration(): number;
|
|
363
218
|
/**
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
* error, and once the coordinator is closed.
|
|
219
|
+
* Resolves without delivering when the request's generation is superseded; rejects with the
|
|
220
|
+
* decoder's, delivery's or abort's error, and once closed.
|
|
367
221
|
*/
|
|
368
222
|
refill(request: DecoderRefillRequest): Promise<void>;
|
|
369
|
-
/** Aborts every request in flight and closes every decoder it opened. */
|
|
370
223
|
close(): void;
|
|
371
224
|
}
|
|
372
225
|
/** Shape used to wrap mediabunny without importing its types into alpha2. */
|
|
@@ -375,13 +228,8 @@ export interface OptionalMediaAdapterFactory {
|
|
|
375
228
|
openAudio?(sourceId: string, input: unknown): Promise<BrowserAudioDecoder>;
|
|
376
229
|
}
|
|
377
230
|
/**
|
|
378
|
-
* The tick nearest a WebCodecs microsecond timestamp.
|
|
379
|
-
*
|
|
380
|
-
* A tick is 1/120 000 s (8.33 microseconds), so a frame boundary that is a whole tick arrives from
|
|
381
|
-
* the container rounded to the microsecond: 30 fps frame one is 33 333 microseconds, or 3999.96
|
|
382
|
-
* ticks. Flooring would make it 3999, below its own tick, so a request for 4000 would skip it.
|
|
383
|
-
* Every decoder path converts through this one function, so a frame's tick never depends on which
|
|
384
|
-
* path produced it.
|
|
231
|
+
* The tick nearest a WebCodecs microsecond timestamp. Rounds, not floors, because tick boundaries
|
|
232
|
+
* arrive just below themselves (30 fps frame one is 3999.96 ticks).
|
|
385
233
|
*/
|
|
386
234
|
export declare function microsecondsToTicks(microseconds: number): bigint;
|
|
387
235
|
import { type ChromaSiting } from "./chroma-siting.js";
|