@napi-rs/webcodecs 0.0.0 → 1.1.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 +79 -3
- package/index.d.ts +879 -3
- package/index.js +58 -52
- package/package.json +24 -10
- package/standard.d.ts +26 -0
package/index.d.ts
CHANGED
|
@@ -33,6 +33,344 @@ export {
|
|
|
33
33
|
AllowSharedBufferSource,
|
|
34
34
|
} from './standard'
|
|
35
35
|
|
|
36
|
+
export type TypedArray =
|
|
37
|
+
| Int8Array
|
|
38
|
+
| Uint8Array
|
|
39
|
+
| Uint8ClampedArray
|
|
40
|
+
| Int16Array
|
|
41
|
+
| Uint16Array
|
|
42
|
+
| Int32Array
|
|
43
|
+
| Uint32Array
|
|
44
|
+
| Float32Array
|
|
45
|
+
| Float64Array
|
|
46
|
+
| BigInt64Array
|
|
47
|
+
| BigUint64Array
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Interface for Canvas-like objects compatible with VideoFrame constructor.
|
|
51
|
+
* Compatible with @napi-rs/canvas Canvas class.
|
|
52
|
+
*
|
|
53
|
+
* @napi-rs/canvas is an optional peer dependency. If installed, Canvas objects
|
|
54
|
+
* can be used as VideoFrame sources. The Canvas pixel data is copied (RGBA format).
|
|
55
|
+
*/
|
|
56
|
+
export interface CanvasLike {
|
|
57
|
+
readonly width: number
|
|
58
|
+
readonly height: number
|
|
59
|
+
/** Returns raw RGBA pixel data as a Buffer */
|
|
60
|
+
data(): Uint8Array
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// ============================================================================
|
|
64
|
+
// Muxer/Demuxer Types
|
|
65
|
+
// ============================================================================
|
|
66
|
+
|
|
67
|
+
/** Demuxer state */
|
|
68
|
+
export type DemuxerState = 'unloaded' | 'ready' | 'demuxing' | 'ended' | 'closed'
|
|
69
|
+
|
|
70
|
+
/** Muxer state */
|
|
71
|
+
export type MuxerState = 'configuring' | 'muxing' | 'finalized' | 'closed'
|
|
72
|
+
|
|
73
|
+
/** Track type for demuxer */
|
|
74
|
+
export type DemuxerTrackType = 'video' | 'audio' | 'subtitle' | 'data'
|
|
75
|
+
|
|
76
|
+
/** Track info from demuxer */
|
|
77
|
+
export interface DemuxerTrackInfo {
|
|
78
|
+
/** Track index */
|
|
79
|
+
index: number
|
|
80
|
+
/** Track type */
|
|
81
|
+
trackType: DemuxerTrackType
|
|
82
|
+
/** Codec string */
|
|
83
|
+
codec?: string
|
|
84
|
+
/** Coded width (video only) */
|
|
85
|
+
codedWidth?: number
|
|
86
|
+
/** Coded height (video only) */
|
|
87
|
+
codedHeight?: number
|
|
88
|
+
/** Sample rate (audio only) */
|
|
89
|
+
sampleRate?: number
|
|
90
|
+
/** Number of channels (audio only) */
|
|
91
|
+
numberOfChannels?: number
|
|
92
|
+
/** Duration in microseconds */
|
|
93
|
+
duration?: number
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Video decoder config from demuxer */
|
|
97
|
+
export interface DemuxerVideoDecoderConfig {
|
|
98
|
+
/** Codec string */
|
|
99
|
+
codec: string
|
|
100
|
+
/** Coded width */
|
|
101
|
+
codedWidth: number
|
|
102
|
+
/** Coded height */
|
|
103
|
+
codedHeight: number
|
|
104
|
+
/** Codec description (e.g., avcC for H.264) */
|
|
105
|
+
description?: Uint8Array
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Audio decoder config from demuxer */
|
|
109
|
+
export interface DemuxerAudioDecoderConfig {
|
|
110
|
+
/** Codec string */
|
|
111
|
+
codec: string
|
|
112
|
+
/** Sample rate */
|
|
113
|
+
sampleRate: number
|
|
114
|
+
/** Number of channels */
|
|
115
|
+
numberOfChannels: number
|
|
116
|
+
/** Codec description */
|
|
117
|
+
description?: Uint8Array
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Init options for Mp4Demuxer */
|
|
121
|
+
export interface Mp4DemuxerInit {
|
|
122
|
+
/** Callback for video chunks */
|
|
123
|
+
videoOutput?: (chunk: EncodedVideoChunk) => void
|
|
124
|
+
/** Callback for audio chunks */
|
|
125
|
+
audioOutput?: (chunk: EncodedAudioChunk) => void
|
|
126
|
+
/** Error callback (required) */
|
|
127
|
+
error: (error: Error) => void
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Init options for WebMDemuxer */
|
|
131
|
+
export interface WebMDemuxerInit {
|
|
132
|
+
/** Callback for video chunks */
|
|
133
|
+
videoOutput?: (chunk: EncodedVideoChunk) => void
|
|
134
|
+
/** Callback for audio chunks */
|
|
135
|
+
audioOutput?: (chunk: EncodedAudioChunk) => void
|
|
136
|
+
/** Error callback (required) */
|
|
137
|
+
error: (error: Error) => void
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Init options for MkvDemuxer */
|
|
141
|
+
export interface MkvDemuxerInit {
|
|
142
|
+
/** Callback for video chunks */
|
|
143
|
+
videoOutput?: (chunk: EncodedVideoChunk) => void
|
|
144
|
+
/** Callback for audio chunks */
|
|
145
|
+
audioOutput?: (chunk: EncodedAudioChunk) => void
|
|
146
|
+
/** Error callback (required) */
|
|
147
|
+
error: (error: Error) => void
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Video track config for muxer */
|
|
151
|
+
export interface MuxerVideoTrackConfig {
|
|
152
|
+
/** Codec string */
|
|
153
|
+
codec: string
|
|
154
|
+
/** Video width */
|
|
155
|
+
width: number
|
|
156
|
+
/** Video height */
|
|
157
|
+
height: number
|
|
158
|
+
/** Codec description (e.g., avcC for H.264) */
|
|
159
|
+
description?: Uint8Array
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Audio track config for muxer */
|
|
163
|
+
export interface MuxerAudioTrackConfig {
|
|
164
|
+
/** Codec string */
|
|
165
|
+
codec: string
|
|
166
|
+
/** Sample rate */
|
|
167
|
+
sampleRate: number
|
|
168
|
+
/** Number of channels */
|
|
169
|
+
numberOfChannels: number
|
|
170
|
+
/** Codec description */
|
|
171
|
+
description?: Uint8Array
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Init options for Mp4Muxer */
|
|
175
|
+
export interface Mp4MuxerInit {
|
|
176
|
+
/** Move moov atom to beginning (not compatible with streaming) */
|
|
177
|
+
fastStart?: boolean
|
|
178
|
+
/** Use fragmented MP4 for streaming */
|
|
179
|
+
fragmented?: boolean
|
|
180
|
+
/** Enable streaming output mode */
|
|
181
|
+
streaming?: { bufferCapacity?: number }
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** Init options for WebMMuxer */
|
|
185
|
+
export interface WebMMuxerInit {
|
|
186
|
+
/** Enable live streaming mode */
|
|
187
|
+
live?: boolean
|
|
188
|
+
/** Enable streaming output mode */
|
|
189
|
+
streaming?: { bufferCapacity?: number }
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Init options for MkvMuxer */
|
|
193
|
+
export interface MkvMuxerInit {
|
|
194
|
+
/** Enable live streaming mode */
|
|
195
|
+
live?: boolean
|
|
196
|
+
/** Enable streaming output mode */
|
|
197
|
+
streaming?: { bufferCapacity?: number }
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* MP4 Demuxer - reads encoded video/audio from MP4 containers
|
|
202
|
+
*/
|
|
203
|
+
export declare class Mp4Demuxer {
|
|
204
|
+
constructor(init: Mp4DemuxerInit)
|
|
205
|
+
/** Load from file path */
|
|
206
|
+
load(path: string): Promise<void>
|
|
207
|
+
/** Load from buffer */
|
|
208
|
+
loadBuffer(data: Uint8Array): Promise<void>
|
|
209
|
+
/** Get all tracks */
|
|
210
|
+
get tracks(): DemuxerTrackInfo[]
|
|
211
|
+
/** Get container duration in microseconds */
|
|
212
|
+
get duration(): number | null
|
|
213
|
+
/** Get video decoder configuration */
|
|
214
|
+
get videoDecoderConfig(): DemuxerVideoDecoderConfig | null
|
|
215
|
+
/** Get audio decoder configuration */
|
|
216
|
+
get audioDecoderConfig(): DemuxerAudioDecoderConfig | null
|
|
217
|
+
/** Select video track by index */
|
|
218
|
+
selectVideoTrack(trackIndex: number): void
|
|
219
|
+
/** Select audio track by index */
|
|
220
|
+
selectAudioTrack(trackIndex: number): void
|
|
221
|
+
/** Start demuxing (optional packet count limit) */
|
|
222
|
+
demux(count?: number): void
|
|
223
|
+
/** Seek to timestamp in microseconds */
|
|
224
|
+
seek(timestampUs: number): void
|
|
225
|
+
/** Close and release resources */
|
|
226
|
+
close(): void
|
|
227
|
+
/** Get current state */
|
|
228
|
+
get state(): DemuxerState
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* WebM Demuxer - reads encoded video/audio from WebM containers
|
|
233
|
+
*/
|
|
234
|
+
export declare class WebMDemuxer {
|
|
235
|
+
constructor(init: WebMDemuxerInit)
|
|
236
|
+
/** Load from file path */
|
|
237
|
+
load(path: string): Promise<void>
|
|
238
|
+
/** Load from buffer */
|
|
239
|
+
loadBuffer(data: Uint8Array): Promise<void>
|
|
240
|
+
/** Get all tracks */
|
|
241
|
+
get tracks(): DemuxerTrackInfo[]
|
|
242
|
+
/** Get container duration in microseconds */
|
|
243
|
+
get duration(): number | null
|
|
244
|
+
/** Get video decoder configuration */
|
|
245
|
+
get videoDecoderConfig(): DemuxerVideoDecoderConfig | null
|
|
246
|
+
/** Get audio decoder configuration */
|
|
247
|
+
get audioDecoderConfig(): DemuxerAudioDecoderConfig | null
|
|
248
|
+
/** Select video track by index */
|
|
249
|
+
selectVideoTrack(trackIndex: number): void
|
|
250
|
+
/** Select audio track by index */
|
|
251
|
+
selectAudioTrack(trackIndex: number): void
|
|
252
|
+
/** Start demuxing (optional packet count limit) */
|
|
253
|
+
demux(count?: number): void
|
|
254
|
+
/** Seek to timestamp in microseconds */
|
|
255
|
+
seek(timestampUs: number): void
|
|
256
|
+
/** Close and release resources */
|
|
257
|
+
close(): void
|
|
258
|
+
/** Get current state */
|
|
259
|
+
get state(): DemuxerState
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* MKV Demuxer - reads encoded video/audio from MKV containers
|
|
264
|
+
*/
|
|
265
|
+
export declare class MkvDemuxer {
|
|
266
|
+
constructor(init: MkvDemuxerInit)
|
|
267
|
+
/** Load from file path */
|
|
268
|
+
load(path: string): Promise<void>
|
|
269
|
+
/** Load from buffer */
|
|
270
|
+
loadBuffer(data: Uint8Array): Promise<void>
|
|
271
|
+
/** Get all tracks */
|
|
272
|
+
get tracks(): DemuxerTrackInfo[]
|
|
273
|
+
/** Get container duration in microseconds */
|
|
274
|
+
get duration(): number | null
|
|
275
|
+
/** Get video decoder configuration */
|
|
276
|
+
get videoDecoderConfig(): DemuxerVideoDecoderConfig | null
|
|
277
|
+
/** Get audio decoder configuration */
|
|
278
|
+
get audioDecoderConfig(): DemuxerAudioDecoderConfig | null
|
|
279
|
+
/** Select video track by index */
|
|
280
|
+
selectVideoTrack(trackIndex: number): void
|
|
281
|
+
/** Select audio track by index */
|
|
282
|
+
selectAudioTrack(trackIndex: number): void
|
|
283
|
+
/** Start demuxing (optional packet count limit) */
|
|
284
|
+
demux(count?: number): void
|
|
285
|
+
/** Seek to timestamp in microseconds */
|
|
286
|
+
seek(timestampUs: number): void
|
|
287
|
+
/** Close and release resources */
|
|
288
|
+
close(): void
|
|
289
|
+
/** Get current state */
|
|
290
|
+
get state(): DemuxerState
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* MP4 Muxer - writes encoded video/audio to MP4 containers
|
|
295
|
+
*/
|
|
296
|
+
export declare class Mp4Muxer {
|
|
297
|
+
constructor(init?: Mp4MuxerInit)
|
|
298
|
+
/** Add video track */
|
|
299
|
+
addVideoTrack(config: MuxerVideoTrackConfig): void
|
|
300
|
+
/** Add audio track */
|
|
301
|
+
addAudioTrack(config: MuxerAudioTrackConfig): void
|
|
302
|
+
/** Add encoded video chunk */
|
|
303
|
+
addVideoChunk(chunk: EncodedVideoChunk, metadata?: EncodedVideoChunkMetadata): void
|
|
304
|
+
/** Add encoded audio chunk */
|
|
305
|
+
addAudioChunk(chunk: EncodedAudioChunk, metadata?: EncodedAudioChunkMetadata): void
|
|
306
|
+
/** Flush pending data */
|
|
307
|
+
flush(): Promise<void>
|
|
308
|
+
/** Finalize and get output data */
|
|
309
|
+
finalize(): Uint8Array
|
|
310
|
+
/** Read available data (streaming mode) */
|
|
311
|
+
read(): Uint8Array | null
|
|
312
|
+
/** Check if finished (streaming mode) */
|
|
313
|
+
get isFinished(): boolean
|
|
314
|
+
/** Close and release resources */
|
|
315
|
+
close(): void
|
|
316
|
+
/** Get current state */
|
|
317
|
+
get state(): MuxerState
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* WebM Muxer - writes encoded video/audio to WebM containers
|
|
322
|
+
*/
|
|
323
|
+
export declare class WebMMuxer {
|
|
324
|
+
constructor(init?: WebMMuxerInit)
|
|
325
|
+
/** Add video track */
|
|
326
|
+
addVideoTrack(config: MuxerVideoTrackConfig): void
|
|
327
|
+
/** Add audio track */
|
|
328
|
+
addAudioTrack(config: MuxerAudioTrackConfig): void
|
|
329
|
+
/** Add encoded video chunk */
|
|
330
|
+
addVideoChunk(chunk: EncodedVideoChunk, metadata?: EncodedVideoChunkMetadata): void
|
|
331
|
+
/** Add encoded audio chunk */
|
|
332
|
+
addAudioChunk(chunk: EncodedAudioChunk, metadata?: EncodedAudioChunkMetadata): void
|
|
333
|
+
/** Flush pending data */
|
|
334
|
+
flush(): Promise<void>
|
|
335
|
+
/** Finalize and get output data */
|
|
336
|
+
finalize(): Uint8Array
|
|
337
|
+
/** Read available data (streaming mode) */
|
|
338
|
+
read(): Uint8Array | null
|
|
339
|
+
/** Check if finished (streaming mode) */
|
|
340
|
+
get isFinished(): boolean
|
|
341
|
+
/** Close and release resources */
|
|
342
|
+
close(): void
|
|
343
|
+
/** Get current state */
|
|
344
|
+
get state(): MuxerState
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* MKV Muxer - writes encoded video/audio to MKV containers
|
|
349
|
+
*/
|
|
350
|
+
export declare class MkvMuxer {
|
|
351
|
+
constructor(init?: MkvMuxerInit)
|
|
352
|
+
/** Add video track */
|
|
353
|
+
addVideoTrack(config: MuxerVideoTrackConfig): void
|
|
354
|
+
/** Add audio track */
|
|
355
|
+
addAudioTrack(config: MuxerAudioTrackConfig): void
|
|
356
|
+
/** Add encoded video chunk */
|
|
357
|
+
addVideoChunk(chunk: EncodedVideoChunk, metadata?: EncodedVideoChunkMetadata): void
|
|
358
|
+
/** Add encoded audio chunk */
|
|
359
|
+
addAudioChunk(chunk: EncodedAudioChunk, metadata?: EncodedAudioChunkMetadata): void
|
|
360
|
+
/** Flush pending data */
|
|
361
|
+
flush(): Promise<void>
|
|
362
|
+
/** Finalize and get output data */
|
|
363
|
+
finalize(): Uint8Array
|
|
364
|
+
/** Read available data (streaming mode) */
|
|
365
|
+
read(): Uint8Array | null
|
|
366
|
+
/** Check if finished (streaming mode) */
|
|
367
|
+
get isFinished(): boolean
|
|
368
|
+
/** Close and release resources */
|
|
369
|
+
close(): void
|
|
370
|
+
/** Get current state */
|
|
371
|
+
get state(): MuxerState
|
|
372
|
+
}
|
|
373
|
+
|
|
36
374
|
export type TypedArray =
|
|
37
375
|
| Int8Array
|
|
38
376
|
| Uint8Array
|
|
@@ -453,6 +791,252 @@ export declare class ImageTrackList {
|
|
|
453
791
|
item(index: number): ImageTrack | null
|
|
454
792
|
}
|
|
455
793
|
|
|
794
|
+
/**
|
|
795
|
+
* MKV Demuxer for reading encoded video and audio from Matroska container
|
|
796
|
+
*
|
|
797
|
+
* MKV supports almost any video and audio codec.
|
|
798
|
+
*/
|
|
799
|
+
export declare class MkvDemuxer {
|
|
800
|
+
constructor(init: MkvDemuxerInit)
|
|
801
|
+
load(path: string): Promise<void>
|
|
802
|
+
/**
|
|
803
|
+
* Load an MKV from a buffer
|
|
804
|
+
*
|
|
805
|
+
* This method uses zero-copy buffer loading - the Uint8Array data is passed
|
|
806
|
+
* directly to the demuxer without an intermediate copy.
|
|
807
|
+
*/
|
|
808
|
+
loadBuffer(data: Uint8Array): Promise<void>
|
|
809
|
+
get tracks(): Array<DemuxerTrackInfo>
|
|
810
|
+
get duration(): number | null
|
|
811
|
+
get videoDecoderConfig(): DemuxerVideoDecoderConfig | null
|
|
812
|
+
get audioDecoderConfig(): DemuxerAudioDecoderConfig | null
|
|
813
|
+
selectVideoTrack(trackIndex: number): void
|
|
814
|
+
selectAudioTrack(trackIndex: number): void
|
|
815
|
+
demux(count?: number | undefined | null): void
|
|
816
|
+
seek(timestampUs: number): void
|
|
817
|
+
close(): void
|
|
818
|
+
get state(): string
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* MKV Muxer for combining encoded video and audio into Matroska container
|
|
823
|
+
*
|
|
824
|
+
* MKV (Matroska) supports virtually all video and audio codecs.
|
|
825
|
+
*
|
|
826
|
+
* Usage:
|
|
827
|
+
* ```javascript
|
|
828
|
+
* const muxer = new MkvMuxer();
|
|
829
|
+
* muxer.addVideoTrack({ codec: 'avc1.42001E', width: 1920, height: 1080 });
|
|
830
|
+
* muxer.addAudioTrack({ codec: 'opus', sampleRate: 48000, numberOfChannels: 2 });
|
|
831
|
+
*
|
|
832
|
+
* // Add encoded chunks from VideoEncoder/AudioEncoder
|
|
833
|
+
* encoder.configure({
|
|
834
|
+
* output: (chunk, metadata) => muxer.addVideoChunk(chunk, metadata)
|
|
835
|
+
* });
|
|
836
|
+
*
|
|
837
|
+
* // Finalize and get MKV data
|
|
838
|
+
* const mkvData = muxer.finalize();
|
|
839
|
+
* ```
|
|
840
|
+
*/
|
|
841
|
+
export declare class MkvMuxer {
|
|
842
|
+
/** Create a new MKV muxer */
|
|
843
|
+
constructor(options?: MkvMuxerOptions | undefined | null)
|
|
844
|
+
/**
|
|
845
|
+
* Add a video track to the muxer
|
|
846
|
+
*
|
|
847
|
+
* MKV supports H.264, H.265, VP8, VP9, AV1, and many other video codecs.
|
|
848
|
+
*/
|
|
849
|
+
addVideoTrack(config: MkvVideoTrackConfig): void
|
|
850
|
+
/**
|
|
851
|
+
* Add an audio track to the muxer
|
|
852
|
+
*
|
|
853
|
+
* MKV supports AAC, Opus, Vorbis, FLAC, MP3, AC3, and many other audio codecs.
|
|
854
|
+
*/
|
|
855
|
+
addAudioTrack(config: MkvAudioTrackConfig): void
|
|
856
|
+
/** Add an encoded video chunk to the muxer */
|
|
857
|
+
addVideoChunk(
|
|
858
|
+
chunk: import('./standard').EncodedVideoChunk,
|
|
859
|
+
metadata?: import('./standard').EncodedVideoChunkMetadata,
|
|
860
|
+
): void
|
|
861
|
+
/** Add an encoded audio chunk to the muxer */
|
|
862
|
+
addAudioChunk(
|
|
863
|
+
chunk: import('./standard').EncodedAudioChunk,
|
|
864
|
+
metadata?: import('./standard').EncodedAudioChunkMetadata,
|
|
865
|
+
): void
|
|
866
|
+
/** Flush any buffered data */
|
|
867
|
+
flush(): void
|
|
868
|
+
/** Finalize the muxer and return the MKV data */
|
|
869
|
+
finalize(): Uint8Array
|
|
870
|
+
/**
|
|
871
|
+
* Read available data from streaming buffer (streaming mode only)
|
|
872
|
+
*
|
|
873
|
+
* Returns available data, or null if no data is ready yet.
|
|
874
|
+
* Returns empty Uint8Array when streaming is finished.
|
|
875
|
+
*/
|
|
876
|
+
read(): Uint8Array | null
|
|
877
|
+
/** Check if muxer is in streaming mode */
|
|
878
|
+
get isStreaming(): boolean
|
|
879
|
+
/** Check if streaming is finished (streaming mode only) */
|
|
880
|
+
get isFinished(): boolean
|
|
881
|
+
/** Close the muxer and release resources */
|
|
882
|
+
close(): void
|
|
883
|
+
/** Get the current state of the muxer */
|
|
884
|
+
get state(): string
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* MP4 Demuxer for reading encoded video and audio from MP4 container
|
|
889
|
+
*
|
|
890
|
+
* Usage:
|
|
891
|
+
* ```javascript
|
|
892
|
+
* const demuxer = new Mp4Demuxer({
|
|
893
|
+
* videoOutput: (chunk) => videoDecoder.decode(chunk),
|
|
894
|
+
* audioOutput: (chunk) => audioDecoder.decode(chunk),
|
|
895
|
+
* error: (err) => console.error(err)
|
|
896
|
+
* });
|
|
897
|
+
*
|
|
898
|
+
* await demuxer.load('./video.mp4');
|
|
899
|
+
*
|
|
900
|
+
* // Get decoder configs
|
|
901
|
+
* const videoConfig = demuxer.videoDecoderConfig;
|
|
902
|
+
* const audioConfig = demuxer.audioDecoderConfig;
|
|
903
|
+
*
|
|
904
|
+
* // Configure decoders
|
|
905
|
+
* videoDecoder.configure(videoConfig);
|
|
906
|
+
* audioDecoder.configure(audioConfig);
|
|
907
|
+
*
|
|
908
|
+
* // Start demuxing
|
|
909
|
+
* demuxer.demux();
|
|
910
|
+
*
|
|
911
|
+
* // Seek to 5 seconds
|
|
912
|
+
* demuxer.seek(5_000_000);
|
|
913
|
+
*
|
|
914
|
+
* demuxer.close();
|
|
915
|
+
* ```
|
|
916
|
+
*/
|
|
917
|
+
export declare class Mp4Demuxer {
|
|
918
|
+
/** Create a new MP4 demuxer */
|
|
919
|
+
constructor(init: Mp4DemuxerInit)
|
|
920
|
+
/** Load an MP4 file from a path */
|
|
921
|
+
load(path: string): Promise<void>
|
|
922
|
+
/**
|
|
923
|
+
* Load an MP4 from a buffer
|
|
924
|
+
*
|
|
925
|
+
* This method uses zero-copy buffer loading - the Uint8Array data is passed
|
|
926
|
+
* directly to the demuxer without an intermediate copy.
|
|
927
|
+
*/
|
|
928
|
+
loadBuffer(data: Uint8Array): Promise<void>
|
|
929
|
+
/** Get all tracks */
|
|
930
|
+
get tracks(): Array<DemuxerTrackInfo>
|
|
931
|
+
/** Get container duration in microseconds */
|
|
932
|
+
get duration(): number | null
|
|
933
|
+
/** Get video decoder configuration for the selected video track */
|
|
934
|
+
get videoDecoderConfig(): DemuxerVideoDecoderConfig | null
|
|
935
|
+
/** Get audio decoder configuration for the selected audio track */
|
|
936
|
+
get audioDecoderConfig(): DemuxerAudioDecoderConfig | null
|
|
937
|
+
/** Select a video track by index */
|
|
938
|
+
selectVideoTrack(trackIndex: number): void
|
|
939
|
+
/** Select an audio track by index */
|
|
940
|
+
selectAudioTrack(trackIndex: number): void
|
|
941
|
+
/**
|
|
942
|
+
* Start demuxing packets
|
|
943
|
+
*
|
|
944
|
+
* If count is specified, reads up to that many packets.
|
|
945
|
+
* Otherwise, reads all packets until end of stream.
|
|
946
|
+
*/
|
|
947
|
+
demux(count?: number | undefined | null): void
|
|
948
|
+
/** Seek to a timestamp in microseconds */
|
|
949
|
+
seek(timestampUs: number): void
|
|
950
|
+
/** Close the demuxer and release resources */
|
|
951
|
+
close(): void
|
|
952
|
+
/** Get the current state of the demuxer */
|
|
953
|
+
get state(): string
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* MP4 Muxer for combining encoded video and audio into MP4 container
|
|
958
|
+
*
|
|
959
|
+
* Usage:
|
|
960
|
+
* ```javascript
|
|
961
|
+
* const muxer = new Mp4Muxer({ fastStart: true });
|
|
962
|
+
* muxer.addVideoTrack({ codec: 'avc1.42001E', width: 1920, height: 1080 });
|
|
963
|
+
* muxer.addAudioTrack({ codec: 'mp4a.40.2', sampleRate: 48000, numberOfChannels: 2 });
|
|
964
|
+
*
|
|
965
|
+
* // Add encoded chunks from VideoEncoder/AudioEncoder
|
|
966
|
+
* encoder.configure({
|
|
967
|
+
* output: (chunk, metadata) => muxer.addVideoChunk(chunk, metadata)
|
|
968
|
+
* });
|
|
969
|
+
*
|
|
970
|
+
* // Finalize and get MP4 data
|
|
971
|
+
* const mp4Data = muxer.finalize();
|
|
972
|
+
* ```
|
|
973
|
+
*/
|
|
974
|
+
export declare class Mp4Muxer {
|
|
975
|
+
/** Create a new MP4 muxer */
|
|
976
|
+
constructor(options?: Mp4MuxerOptions | undefined | null)
|
|
977
|
+
/**
|
|
978
|
+
* Add a video track to the muxer
|
|
979
|
+
*
|
|
980
|
+
* Must be called before adding any chunks.
|
|
981
|
+
*/
|
|
982
|
+
addVideoTrack(config: Mp4VideoTrackConfig): void
|
|
983
|
+
/**
|
|
984
|
+
* Add an audio track to the muxer
|
|
985
|
+
*
|
|
986
|
+
* Must be called before adding any chunks.
|
|
987
|
+
*/
|
|
988
|
+
addAudioTrack(config: Mp4AudioTrackConfig): void
|
|
989
|
+
/**
|
|
990
|
+
* Add an encoded video chunk to the muxer
|
|
991
|
+
*
|
|
992
|
+
* The chunk should come from a VideoEncoder's output callback.
|
|
993
|
+
* If metadata contains decoderConfig.description, it will be used to update
|
|
994
|
+
* the codec extradata (useful for extracting avcC/hvcC from the encoder).
|
|
995
|
+
*/
|
|
996
|
+
addVideoChunk(
|
|
997
|
+
chunk: import('./standard').EncodedVideoChunk,
|
|
998
|
+
metadata?: import('./standard').EncodedVideoChunkMetadata,
|
|
999
|
+
): void
|
|
1000
|
+
/**
|
|
1001
|
+
* Add an encoded audio chunk to the muxer
|
|
1002
|
+
*
|
|
1003
|
+
* The chunk should come from an AudioEncoder's output callback.
|
|
1004
|
+
*/
|
|
1005
|
+
addAudioChunk(
|
|
1006
|
+
chunk: import('./standard').EncodedAudioChunk,
|
|
1007
|
+
metadata?: import('./standard').EncodedAudioChunkMetadata,
|
|
1008
|
+
): void
|
|
1009
|
+
/** Flush any buffered data */
|
|
1010
|
+
flush(): void
|
|
1011
|
+
/**
|
|
1012
|
+
* Finalize the muxer and return the MP4 data
|
|
1013
|
+
*
|
|
1014
|
+
* After calling this, no more chunks can be added.
|
|
1015
|
+
* Returns the complete MP4 file as a Uint8Array.
|
|
1016
|
+
*/
|
|
1017
|
+
finalize(): Uint8Array
|
|
1018
|
+
/**
|
|
1019
|
+
* Read available data from streaming buffer (streaming mode only)
|
|
1020
|
+
*
|
|
1021
|
+
* Returns available data, or null if no data is ready yet.
|
|
1022
|
+
* Returns empty Uint8Array when streaming is finished.
|
|
1023
|
+
*/
|
|
1024
|
+
read(): Uint8Array | null
|
|
1025
|
+
/** Check if muxer is in streaming mode */
|
|
1026
|
+
get isStreaming(): boolean
|
|
1027
|
+
/** Check if streaming is finished (streaming mode only) */
|
|
1028
|
+
get isFinished(): boolean
|
|
1029
|
+
/**
|
|
1030
|
+
* Close the muxer and release resources
|
|
1031
|
+
*
|
|
1032
|
+
* This is called automatically when the muxer is garbage collected,
|
|
1033
|
+
* but can be called explicitly to release resources early.
|
|
1034
|
+
*/
|
|
1035
|
+
close(): void
|
|
1036
|
+
/** Get the current state of the muxer */
|
|
1037
|
+
get state(): string
|
|
1038
|
+
}
|
|
1039
|
+
|
|
456
1040
|
/** Video color space parameters (WebCodecs spec) - as a class per spec */
|
|
457
1041
|
export declare class VideoColorSpace {
|
|
458
1042
|
/** Create a new VideoColorSpace */
|
|
@@ -668,13 +1252,14 @@ export declare class VideoEncoder {
|
|
|
668
1252
|
*/
|
|
669
1253
|
export declare class VideoFrame {
|
|
670
1254
|
/**
|
|
671
|
-
* Create a new VideoFrame from buffer data
|
|
1255
|
+
* Create a new VideoFrame from buffer data, another VideoFrame, or a Canvas (W3C WebCodecs spec)
|
|
672
1256
|
*
|
|
673
|
-
*
|
|
1257
|
+
* Constructor forms per W3C spec:
|
|
674
1258
|
* 1. `new VideoFrame(data, init)` - from BufferSource with VideoFrameBufferInit
|
|
675
1259
|
* 2. `new VideoFrame(source, init?)` - from another VideoFrame with optional VideoFrameInit
|
|
1260
|
+
* 3. `new VideoFrame(canvas, init)` - from @napi-rs/canvas Canvas (requires timestamp in init)
|
|
676
1261
|
*/
|
|
677
|
-
constructor(source: VideoFrame | Uint8Array, init?: VideoFrameBufferInit | VideoFrameInit)
|
|
1262
|
+
constructor(source: VideoFrame | Uint8Array | CanvasLike, init?: VideoFrameBufferInit | VideoFrameInit)
|
|
678
1263
|
/** Get the pixel format */
|
|
679
1264
|
get format(): VideoPixelFormat | null
|
|
680
1265
|
/** Get the coded width in pixels (returns 0 when closed per W3C spec) */
|
|
@@ -752,6 +1337,99 @@ export declare class VideoFrame {
|
|
|
752
1337
|
close(): void
|
|
753
1338
|
}
|
|
754
1339
|
|
|
1340
|
+
/**
|
|
1341
|
+
* WebM Demuxer for reading encoded video and audio from WebM container
|
|
1342
|
+
*
|
|
1343
|
+
* WebM typically contains VP8, VP9, or AV1 video with Opus or Vorbis audio.
|
|
1344
|
+
*/
|
|
1345
|
+
export declare class WebMDemuxer {
|
|
1346
|
+
constructor(init: WebMDemuxerInit)
|
|
1347
|
+
load(path: string): Promise<void>
|
|
1348
|
+
/**
|
|
1349
|
+
* Load a WebM from a buffer
|
|
1350
|
+
*
|
|
1351
|
+
* This method uses zero-copy buffer loading - the Uint8Array data is passed
|
|
1352
|
+
* directly to the demuxer without an intermediate copy.
|
|
1353
|
+
*/
|
|
1354
|
+
loadBuffer(data: Uint8Array): Promise<void>
|
|
1355
|
+
get tracks(): Array<DemuxerTrackInfo>
|
|
1356
|
+
get duration(): number | null
|
|
1357
|
+
get videoDecoderConfig(): DemuxerVideoDecoderConfig | null
|
|
1358
|
+
get audioDecoderConfig(): DemuxerAudioDecoderConfig | null
|
|
1359
|
+
selectVideoTrack(trackIndex: number): void
|
|
1360
|
+
selectAudioTrack(trackIndex: number): void
|
|
1361
|
+
demux(count?: number | undefined | null): void
|
|
1362
|
+
seek(timestampUs: number): void
|
|
1363
|
+
close(): void
|
|
1364
|
+
get state(): string
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
/**
|
|
1368
|
+
* WebM Muxer for combining encoded video and audio into WebM container
|
|
1369
|
+
*
|
|
1370
|
+
* WebM supports VP8, VP9, AV1 video codecs and Opus, Vorbis audio codecs.
|
|
1371
|
+
*
|
|
1372
|
+
* Usage:
|
|
1373
|
+
* ```javascript
|
|
1374
|
+
* const muxer = new WebMMuxer();
|
|
1375
|
+
* muxer.addVideoTrack({ codec: 'vp09.00.10.08', width: 1920, height: 1080 });
|
|
1376
|
+
* muxer.addAudioTrack({ codec: 'opus', sampleRate: 48000, numberOfChannels: 2 });
|
|
1377
|
+
*
|
|
1378
|
+
* // Add encoded chunks from VideoEncoder/AudioEncoder
|
|
1379
|
+
* encoder.configure({
|
|
1380
|
+
* output: (chunk, metadata) => muxer.addVideoChunk(chunk, metadata)
|
|
1381
|
+
* });
|
|
1382
|
+
*
|
|
1383
|
+
* // Finalize and get WebM data
|
|
1384
|
+
* const webmData = muxer.finalize();
|
|
1385
|
+
* ```
|
|
1386
|
+
*/
|
|
1387
|
+
export declare class WebMMuxer {
|
|
1388
|
+
/** Create a new WebM muxer */
|
|
1389
|
+
constructor(options?: WebMMuxerOptions | undefined | null)
|
|
1390
|
+
/**
|
|
1391
|
+
* Add a video track to the muxer
|
|
1392
|
+
*
|
|
1393
|
+
* WebM supports VP8, VP9, and AV1 video codecs.
|
|
1394
|
+
*/
|
|
1395
|
+
addVideoTrack(config: WebMVideoTrackConfig): void
|
|
1396
|
+
/**
|
|
1397
|
+
* Add an audio track to the muxer
|
|
1398
|
+
*
|
|
1399
|
+
* WebM supports Opus and Vorbis audio codecs.
|
|
1400
|
+
*/
|
|
1401
|
+
addAudioTrack(config: WebMAudioTrackConfig): void
|
|
1402
|
+
/** Add an encoded video chunk to the muxer */
|
|
1403
|
+
addVideoChunk(
|
|
1404
|
+
chunk: import('./standard').EncodedVideoChunk,
|
|
1405
|
+
metadata?: import('./standard').EncodedVideoChunkMetadata,
|
|
1406
|
+
): void
|
|
1407
|
+
/** Add an encoded audio chunk to the muxer */
|
|
1408
|
+
addAudioChunk(
|
|
1409
|
+
chunk: import('./standard').EncodedAudioChunk,
|
|
1410
|
+
metadata?: import('./standard').EncodedAudioChunkMetadata,
|
|
1411
|
+
): void
|
|
1412
|
+
/** Flush any buffered data */
|
|
1413
|
+
flush(): void
|
|
1414
|
+
/** Finalize the muxer and return the WebM data */
|
|
1415
|
+
finalize(): Uint8Array
|
|
1416
|
+
/**
|
|
1417
|
+
* Read available data from streaming buffer (streaming mode only)
|
|
1418
|
+
*
|
|
1419
|
+
* Returns available data, or null if no data is ready yet.
|
|
1420
|
+
* Returns empty Uint8Array when streaming is finished.
|
|
1421
|
+
*/
|
|
1422
|
+
read(): Uint8Array | null
|
|
1423
|
+
/** Check if muxer is in streaming mode */
|
|
1424
|
+
get isStreaming(): boolean
|
|
1425
|
+
/** Check if streaming is finished (streaming mode only) */
|
|
1426
|
+
get isFinished(): boolean
|
|
1427
|
+
/** Close the muxer and release resources */
|
|
1428
|
+
close(): void
|
|
1429
|
+
/** Get the current state of the muxer */
|
|
1430
|
+
get state(): string
|
|
1431
|
+
}
|
|
1432
|
+
|
|
755
1433
|
/** AAC bitstream format (W3C WebCodecs AAC Registration) */
|
|
756
1434
|
export type AacBitstreamFormat = /** Raw AAC frames - metadata in description */
|
|
757
1435
|
| 'aac'
|
|
@@ -799,6 +1477,18 @@ export interface AudioDecoderAddEventListenerOptions {
|
|
|
799
1477
|
passive?: boolean
|
|
800
1478
|
}
|
|
801
1479
|
|
|
1480
|
+
/** JavaScript-facing audio decoder config type */
|
|
1481
|
+
export interface AudioDecoderConfigJs {
|
|
1482
|
+
/** Codec string */
|
|
1483
|
+
codec?: string
|
|
1484
|
+
/** Sample rate */
|
|
1485
|
+
sampleRate?: number
|
|
1486
|
+
/** Number of channels */
|
|
1487
|
+
numberOfChannels?: number
|
|
1488
|
+
/** Codec-specific description */
|
|
1489
|
+
description?: Uint8Array
|
|
1490
|
+
}
|
|
1491
|
+
|
|
802
1492
|
/** Decoder configuration output (for passing to decoder) */
|
|
803
1493
|
export interface AudioDecoderConfigOutput {
|
|
804
1494
|
/** Codec string */
|
|
@@ -897,6 +1587,50 @@ export type ColorSpaceConversion = /** Apply default color space conversion (spe
|
|
|
897
1587
|
/** No color space conversion */
|
|
898
1588
|
| 'none'
|
|
899
1589
|
|
|
1590
|
+
/** Audio decoder configuration exposed to JavaScript */
|
|
1591
|
+
export interface DemuxerAudioDecoderConfig {
|
|
1592
|
+
/** Codec string */
|
|
1593
|
+
codec: string
|
|
1594
|
+
/** Sample rate */
|
|
1595
|
+
sampleRate: number
|
|
1596
|
+
/** Number of channels */
|
|
1597
|
+
numberOfChannels: number
|
|
1598
|
+
/** Codec-specific description data */
|
|
1599
|
+
description?: Uint8Array
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
/** Track information exposed to JavaScript */
|
|
1603
|
+
export interface DemuxerTrackInfo {
|
|
1604
|
+
/** Track index */
|
|
1605
|
+
index: number
|
|
1606
|
+
/** Track type ("video" or "audio") */
|
|
1607
|
+
trackType: string
|
|
1608
|
+
/** Codec string (WebCodecs format) */
|
|
1609
|
+
codec: string
|
|
1610
|
+
/** Duration in microseconds */
|
|
1611
|
+
duration?: number
|
|
1612
|
+
/** Coded width (video only) */
|
|
1613
|
+
codedWidth?: number
|
|
1614
|
+
/** Coded height (video only) */
|
|
1615
|
+
codedHeight?: number
|
|
1616
|
+
/** Sample rate (audio only) */
|
|
1617
|
+
sampleRate?: number
|
|
1618
|
+
/** Number of channels (audio only) */
|
|
1619
|
+
numberOfChannels?: number
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
/** Video decoder configuration exposed to JavaScript */
|
|
1623
|
+
export interface DemuxerVideoDecoderConfig {
|
|
1624
|
+
/** Codec string */
|
|
1625
|
+
codec: string
|
|
1626
|
+
/** Coded width */
|
|
1627
|
+
codedWidth: number
|
|
1628
|
+
/** Coded height */
|
|
1629
|
+
codedHeight: number
|
|
1630
|
+
/** Codec-specific description data (avcC/hvcC) */
|
|
1631
|
+
description?: Uint8Array
|
|
1632
|
+
}
|
|
1633
|
+
|
|
900
1634
|
/** DOMRectInit for specifying regions */
|
|
901
1635
|
export interface DOMRectInit {
|
|
902
1636
|
x?: number
|
|
@@ -911,6 +1645,12 @@ export interface EncodedAudioChunkMetadata {
|
|
|
911
1645
|
decoderConfig?: AudioDecoderConfigOutput
|
|
912
1646
|
}
|
|
913
1647
|
|
|
1648
|
+
/** JavaScript-facing metadata type for audio chunks */
|
|
1649
|
+
export interface EncodedAudioChunkMetadataJs {
|
|
1650
|
+
/** Decoder configuration from encoder */
|
|
1651
|
+
decoderConfig?: AudioDecoderConfigJS
|
|
1652
|
+
}
|
|
1653
|
+
|
|
914
1654
|
/** Type of encoded audio chunk */
|
|
915
1655
|
export type EncodedAudioChunkType = /** Key chunk - can be decoded independently */
|
|
916
1656
|
| 'key'
|
|
@@ -927,6 +1667,14 @@ export interface EncodedVideoChunkMetadata {
|
|
|
927
1667
|
alphaSideData?: Uint8Array
|
|
928
1668
|
}
|
|
929
1669
|
|
|
1670
|
+
/** JavaScript-facing metadata type for video chunks */
|
|
1671
|
+
export interface EncodedVideoChunkMetadataJs {
|
|
1672
|
+
/** Decoder configuration from encoder */
|
|
1673
|
+
decoderConfig?: VideoDecoderConfigJS
|
|
1674
|
+
/** SVC output metadata */
|
|
1675
|
+
svc?: SvcOutputMetadataJS
|
|
1676
|
+
}
|
|
1677
|
+
|
|
930
1678
|
/** Type of encoded video chunk */
|
|
931
1679
|
export type EncodedVideoChunkType = /** Keyframe - can be decoded independently */
|
|
932
1680
|
| 'key'
|
|
@@ -1002,6 +1750,78 @@ export type LatencyMode = /** Optimize for quality (default) */
|
|
|
1002
1750
|
/** Optimize for low latency */
|
|
1003
1751
|
| 'realtime'
|
|
1004
1752
|
|
|
1753
|
+
/** Audio track configuration for MKV muxer */
|
|
1754
|
+
export interface MkvAudioTrackConfig {
|
|
1755
|
+
/** Codec string (e.g., "mp4a.40.2", "opus", "flac", "vorbis", "ac3") */
|
|
1756
|
+
codec: string
|
|
1757
|
+
/** Sample rate in Hz */
|
|
1758
|
+
sampleRate: number
|
|
1759
|
+
/** Number of audio channels */
|
|
1760
|
+
numberOfChannels: number
|
|
1761
|
+
/** Codec-specific description data */
|
|
1762
|
+
description?: Uint8Array
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
/** MKV muxer options */
|
|
1766
|
+
export interface MkvMuxerOptions {
|
|
1767
|
+
/** Enable live streaming mode */
|
|
1768
|
+
live?: boolean
|
|
1769
|
+
/** Enable streaming output mode */
|
|
1770
|
+
streaming?: StreamingMuxerOptions
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
/** Video track configuration for MKV muxer */
|
|
1774
|
+
export interface MkvVideoTrackConfig {
|
|
1775
|
+
/** Codec string (e.g., "avc1.42001E", "hev1.1.6.L93.B0", "vp09.00.10.08", "av01.0.04M.08") */
|
|
1776
|
+
codec: string
|
|
1777
|
+
/** Video width in pixels */
|
|
1778
|
+
width: number
|
|
1779
|
+
/** Video height in pixels */
|
|
1780
|
+
height: number
|
|
1781
|
+
/** Codec-specific description data */
|
|
1782
|
+
description?: Uint8Array
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
/** Audio track configuration for MP4 muxer */
|
|
1786
|
+
export interface Mp4AudioTrackConfig {
|
|
1787
|
+
/** Codec string (e.g., "mp4a.40.2" for AAC-LC, "opus") */
|
|
1788
|
+
codec: string
|
|
1789
|
+
/** Sample rate in Hz */
|
|
1790
|
+
sampleRate: number
|
|
1791
|
+
/** Number of audio channels */
|
|
1792
|
+
numberOfChannels: number
|
|
1793
|
+
/** Codec-specific description data (esds for AAC, etc.) */
|
|
1794
|
+
description?: Uint8Array
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
/** MP4 muxer options */
|
|
1798
|
+
export interface Mp4MuxerOptions {
|
|
1799
|
+
/**
|
|
1800
|
+
* Move moov atom to beginning for better streaming (default: false)
|
|
1801
|
+
* Note: Not compatible with streaming output mode
|
|
1802
|
+
*/
|
|
1803
|
+
fastStart?: boolean
|
|
1804
|
+
/**
|
|
1805
|
+
* Use fragmented MP4 for streaming output
|
|
1806
|
+
* When true, uses frag_keyframe+empty_moov+default_base_moof
|
|
1807
|
+
*/
|
|
1808
|
+
fragmented?: boolean
|
|
1809
|
+
/** Enable streaming output mode */
|
|
1810
|
+
streaming?: StreamingMuxerOptions
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1813
|
+
/** Video track configuration for MP4 muxer */
|
|
1814
|
+
export interface Mp4VideoTrackConfig {
|
|
1815
|
+
/** Codec string (e.g., "avc1.42001E", "hev1.1.6.L93.B0", "av01.0.04M.08") */
|
|
1816
|
+
codec: string
|
|
1817
|
+
/** Video width in pixels */
|
|
1818
|
+
width: number
|
|
1819
|
+
/** Video height in pixels */
|
|
1820
|
+
height: number
|
|
1821
|
+
/** Codec-specific description data (avcC/hvcC/av1C from encoder metadata) */
|
|
1822
|
+
description?: Uint8Array
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1005
1825
|
/** Opus application mode (W3C WebCodecs Opus Registration) */
|
|
1006
1826
|
export type OpusApplication = /** Optimize for VoIP (speech intelligibility) */
|
|
1007
1827
|
| 'voip'
|
|
@@ -1066,12 +1886,24 @@ export interface PlaneLayout {
|
|
|
1066
1886
|
*/
|
|
1067
1887
|
export declare function resetHardwareFallbackState(): void
|
|
1068
1888
|
|
|
1889
|
+
/** Streaming mode options for muxers */
|
|
1890
|
+
export interface StreamingMuxerOptions {
|
|
1891
|
+
/** Buffer capacity for streaming output (default: 256KB) */
|
|
1892
|
+
bufferCapacity?: number
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1069
1895
|
/** SVC (Scalable Video Coding) output metadata (W3C WebCodecs spec) */
|
|
1070
1896
|
export interface SvcOutputMetadata {
|
|
1071
1897
|
/** Temporal layer ID for this frame */
|
|
1072
1898
|
temporalLayerId?: number
|
|
1073
1899
|
}
|
|
1074
1900
|
|
|
1901
|
+
/** JavaScript-facing SVC metadata */
|
|
1902
|
+
export interface SvcOutputMetadataJs {
|
|
1903
|
+
/** Temporal layer ID */
|
|
1904
|
+
temporalLayerId?: number
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1075
1907
|
/** Video color primaries (W3C WebCodecs spec) */
|
|
1076
1908
|
export type VideoColorPrimaries = /** BT.709 / sRGB primaries */
|
|
1077
1909
|
| 'bt709'
|
|
@@ -1091,6 +1923,18 @@ export interface VideoDecoderAddEventListenerOptions {
|
|
|
1091
1923
|
passive?: boolean
|
|
1092
1924
|
}
|
|
1093
1925
|
|
|
1926
|
+
/** JavaScript-facing decoder config type */
|
|
1927
|
+
export interface VideoDecoderConfigJs {
|
|
1928
|
+
/** Codec string */
|
|
1929
|
+
codec?: string
|
|
1930
|
+
/** Codec-specific description */
|
|
1931
|
+
description?: Uint8Array
|
|
1932
|
+
/** Coded width */
|
|
1933
|
+
codedWidth?: number
|
|
1934
|
+
/** Coded height */
|
|
1935
|
+
codedHeight?: number
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1094
1938
|
/** Decoder configuration output (for passing to decoder) */
|
|
1095
1939
|
export interface VideoDecoderConfigOutput {
|
|
1096
1940
|
/** Codec string */
|
|
@@ -1297,3 +2141,35 @@ export type VideoTransferCharacteristics = /** BT.709 transfer */
|
|
|
1297
2141
|
| 'pq'
|
|
1298
2142
|
/** Hybrid Log-Gamma (HDR) */
|
|
1299
2143
|
| 'hlg'
|
|
2144
|
+
|
|
2145
|
+
/** Audio track configuration for WebM muxer */
|
|
2146
|
+
export interface WebMAudioTrackConfig {
|
|
2147
|
+
/** Codec string (e.g., "opus", "vorbis") */
|
|
2148
|
+
codec: string
|
|
2149
|
+
/** Sample rate in Hz */
|
|
2150
|
+
sampleRate: number
|
|
2151
|
+
/** Number of audio channels */
|
|
2152
|
+
numberOfChannels: number
|
|
2153
|
+
/** Codec-specific description data */
|
|
2154
|
+
description?: Uint8Array
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
/** WebM muxer options */
|
|
2158
|
+
export interface WebMMuxerOptions {
|
|
2159
|
+
/** Enable live streaming mode (cluster-at-a-time output) */
|
|
2160
|
+
live?: boolean
|
|
2161
|
+
/** Enable streaming output mode */
|
|
2162
|
+
streaming?: StreamingMuxerOptions
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
/** Video track configuration for WebM muxer */
|
|
2166
|
+
export interface WebMVideoTrackConfig {
|
|
2167
|
+
/** Codec string (e.g., "vp8", "vp09.00.10.08", "av01.0.04M.08") */
|
|
2168
|
+
codec: string
|
|
2169
|
+
/** Video width in pixels */
|
|
2170
|
+
width: number
|
|
2171
|
+
/** Video height in pixels */
|
|
2172
|
+
height: number
|
|
2173
|
+
/** Codec-specific description data */
|
|
2174
|
+
description?: Uint8Array
|
|
2175
|
+
}
|