@pexip/media-processor 21.0.0 → 22.0.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.
Files changed (115) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +17 -10
  3. package/api-docs/README.mdx +37 -18
  4. package/api-docs/functions/assertMediaStreamVideoTrack.mdx +13 -0
  5. package/api-docs/functions/createFrameCallbackRequest.mdx +8 -2
  6. package/api-docs/functions/createMediaStreamTrackInputProcessAdaptor.mdx +10 -0
  7. package/api-docs/functions/createReadWritableStreamFallbackInputProcessAdaptor.mdx +17 -0
  8. package/api-docs/functions/createReadWritableStreamInputProcessAdaptor.mdx +10 -0
  9. package/api-docs/functions/createVideoProcessor.mdx +3 -3
  10. package/api-docs/functions/getDefaultInputProcessAdaptor.mdx +17 -0
  11. package/api-docs/functions/isMediaStreamVideoTrack.mdx +13 -0
  12. package/api-docs/functions/playVideo.mdx +2 -2
  13. package/api-docs/interfaces/Analyzer.mdx +4 -0
  14. package/api-docs/interfaces/Benchmark.mdx +14 -2
  15. package/api-docs/interfaces/FrameTransformStats.mdx +9 -0
  16. package/api-docs/interfaces/Gain.mdx +4 -0
  17. package/api-docs/interfaces/ImageSegmenterOptions.mdx +0 -2
  18. package/api-docs/interfaces/InputProcessAdaptor.mdx +28 -0
  19. package/api-docs/interfaces/Process.mdx +8 -3
  20. package/api-docs/interfaces/ProcessEventMute.mdx +6 -0
  21. package/api-docs/interfaces/ProcessWorkerEventOpened.mdx +7 -0
  22. package/api-docs/interfaces/ProcessWorkerEventStats.mdx +6 -0
  23. package/api-docs/interfaces/ProcessWorkerEventUpdated.mdx +7 -0
  24. package/api-docs/interfaces/ProcessorEvent.mdx +1 -1
  25. package/api-docs/interfaces/ProcessorOptions.mdx +0 -1
  26. package/api-docs/interfaces/ProcessorProcessOptions.mdx +3 -1
  27. package/api-docs/interfaces/ProcessorUpdateOptions.mdx +15 -0
  28. package/api-docs/interfaces/ReadWritableStream.mdx +12 -0
  29. package/api-docs/interfaces/Renderer.mdx +2 -2
  30. package/api-docs/interfaces/RendererOptions.mdx +0 -4
  31. package/api-docs/interfaces/Segmenter.mdx +89 -10
  32. package/api-docs/interfaces/SegmenterOptions.mdx +0 -1
  33. package/api-docs/interfaces/VideoProcessor.mdx +49 -5
  34. package/api-docs/type-aliases/ProcessEvents.mdx +1 -0
  35. package/api-docs/type-aliases/ProcessInputType.mdx +3 -1
  36. package/api-docs/type-aliases/ProcessWorkerEvents.mdx +6 -4
  37. package/api-docs/type-aliases/ProcessorWorkerEvents.mdx +1 -1
  38. package/api-docs/type-aliases/Struct.mdx +9 -0
  39. package/api-docs/variables/FRAME_RATE.mdx +1 -1
  40. package/api-docs/variables/ImageFetchError.mdx +3 -0
  41. package/api-docs/variables/MediaStreamTrackTransferable.mdx +5 -0
  42. package/api-docs/variables/RENDERER_OPTIONS_STRUCT.mdx +3 -0
  43. package/api-docs/variables/cloneImageRecord.mdx +19 -0
  44. package/api-docs/variables/compareImageRecords.mdx +18 -0
  45. package/api-docs/variables/createRemoteImageBitmap.mdx +1 -1
  46. package/api-docs/variables/isRenderOptionsKey.mdx +13 -0
  47. package/api-docs/variables/isValidGpuAPI.mdx +13 -0
  48. package/dist/common/backends/webgl/renderer.js +2 -12
  49. package/dist/common/backends/webgl/texture.d.ts +1 -2
  50. package/dist/common/backends/webgl/texture.js +2 -2
  51. package/dist/common/backends/webgl/webglUtils.js +8 -4
  52. package/dist/common/backends/webgpu/renderer.js +2 -12
  53. package/dist/common/backends/webgpu/tentBlur.js +1 -1
  54. package/dist/common/backends/webgpu/texture.d.ts +1 -2
  55. package/dist/common/backends/webgpu/texture.js +6 -2
  56. package/dist/common/constants.d.ts +3 -0
  57. package/dist/common/constants.js +4 -0
  58. package/dist/common/index.d.ts +1 -0
  59. package/dist/common/index.js +1 -0
  60. package/dist/common/tsconfig.tsbuildinfo +1 -1
  61. package/dist/common/typeGuards.d.ts +2 -0
  62. package/dist/common/typeGuards.js +7 -0
  63. package/dist/common/types/media.d.ts +5 -1
  64. package/dist/common/types/messageEvents.d.ts +31 -4
  65. package/dist/common/types/processor.d.ts +6 -4
  66. package/dist/common/types/render.d.ts +5 -2
  67. package/dist/common/types/render.js +23 -1
  68. package/dist/common/types/segmentation.d.ts +0 -12
  69. package/dist/common/utils.d.ts +13 -2
  70. package/dist/common/utils.js +54 -10
  71. package/dist/main/audio.js +3 -3
  72. package/dist/main/benchUtils.d.ts +2 -2
  73. package/dist/main/benchUtils.js +4 -4
  74. package/dist/main/index.d.ts +1 -1
  75. package/dist/main/index.js +1 -1
  76. package/dist/main/tsconfig.tsbuildinfo +1 -1
  77. package/dist/main/types.d.ts +0 -6
  78. package/dist/main/utils.d.ts +4 -0
  79. package/dist/main/utils.js +31 -0
  80. package/dist/main/video/constants.d.ts +1 -4
  81. package/dist/main/video/constants.js +1 -5
  82. package/dist/main/video/index.d.ts +2 -3
  83. package/dist/main/video/index.js +2 -3
  84. package/dist/main/video/inputProcessAdaptor.d.ts +30 -0
  85. package/dist/main/video/inputProcessAdaptor.js +198 -0
  86. package/dist/main/video/segmenter.d.ts +35 -0
  87. package/dist/main/video/{segmenters/mediapipe.js → segmenter.js} +93 -53
  88. package/dist/main/video/typeGuards.d.ts +2 -0
  89. package/dist/main/video/typeGuards.js +8 -1
  90. package/dist/main/video/types.d.ts +36 -16
  91. package/dist/main/video/utils.d.ts +5 -4
  92. package/dist/main/video/utils.js +49 -44
  93. package/dist/main/video/video.d.ts +29 -7
  94. package/dist/main/video/video.js +323 -28
  95. package/dist/workers/mediaWorker.js +23 -23
  96. package/dist/workers/tsconfig.tsbuildinfo +1 -1
  97. package/dist/worklets/tsconfig.tsbuildinfo +1 -1
  98. package/package.json +7 -7
  99. package/api-docs/functions/createCanvasTransform.mdx +0 -14
  100. package/api-docs/functions/createVideoTrackProcessor.mdx +0 -9
  101. package/api-docs/functions/createVideoTrackProcessorWithFallback.mdx +0 -15
  102. package/api-docs/interfaces/Detector.mdx +0 -81
  103. package/api-docs/interfaces/SegmentationParams.mdx +0 -35
  104. package/api-docs/interfaces/Transform.mdx +0 -62
  105. package/api-docs/type-aliases/ProcessVideoTrack.mdx +0 -15
  106. package/api-docs/type-aliases/SegmentationTransform.mdx +0 -3
  107. package/dist/main/transformer.d.ts +0 -1
  108. package/dist/main/transformer.js +0 -4
  109. package/dist/main/video/canvasTransform.d.ts +0 -17
  110. package/dist/main/video/canvasTransform.js +0 -341
  111. package/dist/main/video/segmenters/mediapipe.d.ts +0 -22
  112. package/dist/main/video/transformer.d.ts +0 -9
  113. package/dist/main/video/transformer.js +0 -68
  114. package/dist/main/video/videoStreamTrackProcessor.d.ts +0 -20
  115. package/dist/main/video/videoStreamTrackProcessor.js +0 -86
package/CHANGELOG.md CHANGED
@@ -1,5 +1,75 @@
1
1
  # Changelog
2
2
 
3
+ ## 22.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 498ff3b: A full architectural overhaul of the video processing pipeline:
8
+
9
+ BREAKING CHANGES:
10
+
11
+ - **`createCanvasTransform` removed**
12
+ - **`createVideoTrackProcessor` / `createVideoTrackProcessorWithFallback`
13
+ removed**
14
+ - **`createVideoProcessor` redesigned** — now accepts a `Segmenter` +
15
+ `InputProcessAdaptor` instead of an array of `Transform`s. Exposes
16
+ `update()`, `mute()`, `status`, `renderOptions`, and processing dimensions.
17
+ - **New `InputProcessAdaptor` system**:
18
+ - `createMediaStreamTrackInputProcessAdaptor` — uses native
19
+ `MediaStreamTrack` transfer (Safari v18+ compatible).
20
+ - `createReadWritableStreamInputProcessAdaptor` — uses
21
+ `MediaStreamTrackProcessor` + `MediaStreamTrackGenerator`.
22
+ - `createReadWritableStreamFallbackInputProcessAdaptor` — canvas/video
23
+ element fallback.
24
+ - `getDefaultInputProcessAdaptor` — picks the best path via feature
25
+ detection (`MediaStreamTrackTransferable`).
26
+ - **`createSegmenter` updated**
27
+ - Now processes `MediaStreamTrack` or `ReadWritableStream` directly (no more
28
+ `VideoFrameLike`).
29
+ - Added `mute()` method.
30
+ - Added `stats` callback for frame timing data.
31
+ - Worker is no longer re-created on every `open()`.
32
+ - **Worker rewritten**:
33
+ - Processing now uses `TransformStream` to pipe `VideoFrame`s through
34
+ segmentation.
35
+ - Supports both track-based
36
+ (`VideoTrackGenerator`/`MediaStreamTrackProcessor`) and ReadWritable
37
+ stream processing.
38
+ - Added frame timing stats (`FrameTransformStats`) batched and posted back
39
+ to main thread.
40
+ - Removes direct canvas-copy output (`directOutput`/`output`); renderer now
41
+ writes to `processCanvas` and creates a new `VideoFrame`.
42
+ - `close` and `suspend` separated; resource cleanup improved.
43
+ - Background image fetching is now abortable.
44
+ - **`Renderer.render()` signature simplified** — accepts `OffscreenCanvas` +
45
+ `VideoFrame` directly (no `VideoFrameLike` wrapper).
46
+ - **WebGL/WebGPU texture renderers** updated to accept
47
+ `VideoFrame | ImageBitmap | OffscreenCanvas` natively.
48
+ - **WebGL program release guard** added to prevent double-free.
49
+ - **`benchUtils`** extended to accept explicit timestamps in
50
+ `begin()`/`end()` + tests added.
51
+ - **`MediaStreamTrackTransferable`** feature-detection helper exported.
52
+ - **Default frame rate raised** from 20 → 30 fps.
53
+ - **Default backend changed** to `webgpu`.
54
+
55
+ - fe0a0a4: Set a max width of 300px of in meeting selfview.
56
+
57
+ Rename openEffectsModal prop on InMeetingSelfview to openEffects
58
+
59
+ Make selfview muted indicator look more like an indicator
60
+
61
+ Show tooltips for background effects button and upload background effect
62
+
63
+ ### Patch Changes
64
+
65
+ - f8bd1c5: Fix VideoProcessor and Segment open/update behavior
66
+ - 925cce6: Fix f16 issue
67
+ - fb41d4d: Changes related to Typescript V6 Upgrade
68
+ - Updated dependencies [498ff3b]
69
+ - Updated dependencies [fb41d4d]
70
+ - Updated dependencies [b99c070]
71
+ - @pexip/utils@17.3.0
72
+
3
73
  ## 21.0.0
4
74
 
5
75
  ### Major Changes
package/README.md CHANGED
@@ -106,10 +106,12 @@ await audioGraph.release();
106
106
 
107
107
  ```typescript
108
108
  import {
109
+ createMediaStreamTrackInputProcessAdaptor,
110
+ createReadWritableStreamFallbackInputProcessAdaptor,
111
+ createReadWritableStreamInputProcessAdaptor,
109
112
  createSegmenter,
110
- createCanvasTransform,
111
- createVideoTrackProcessor,
112
- createVideoTrackProcessorWithFallback,
113
+ createVideoProcessor,
114
+ getDefaultInputProcessAdaptor,
113
115
  } from '@pexip/media-processor';
114
116
 
115
117
  // Grab the user's camera stream
@@ -129,17 +131,22 @@ const modelAsset = {
129
131
  modelName: 'selfie' as const,
130
132
  };
131
133
 
132
- const segmenter = createSegmenter(tasksVisionBasePath, {modelAssets});
133
- // Create a processing transformer and set the effects to `blur`
134
- const transformer = createCanvasTransform(segmenter, {effects: 'blur'});
135
- const processor = createVideoProcessor([transformer]);
134
+ const segmenter = createSegmenter(tasksVisionBasePath, {modelAsset});
135
+ // Choose the appropriate input process adaptor based on browser capabilities
136
+ const inputProcessAdaptor = getDefaultInputProcessAdaptor(true);
137
+ // Create a processor and set the effects to `blur`
138
+ const processor = createVideoProcessor(segmenter, inputProcessAdaptor);
136
139
 
137
140
  // Start the processor
138
141
  await videoProcessor.open();
139
142
 
140
- // Passing the raw MediaStream to apply the effects
141
- // Then, use the output stream for whatever purpose
142
- const processedStream = await videoProcessor.process(stream);
143
+ // Start the processor with blur effects
144
+ await processor.open({renderOptions: {effects: 'blur'}});
145
+
146
+ // Process the video track and create a new stream
147
+ const videoTrack = stream.getVideoTracks()[0];
148
+ const processedTrack = await processor.process(videoTrack);
149
+ const processedStream = new MediaStream([processedTrack]);
143
150
  ```
144
151
 
145
152
  ## Profiling Web Audio
@@ -106,10 +106,12 @@ await audioGraph.release();
106
106
 
107
107
  ```typescript
108
108
  import {
109
+ createMediaStreamTrackInputProcessAdaptor,
110
+ createReadWritableStreamFallbackInputProcessAdaptor,
111
+ createReadWritableStreamInputProcessAdaptor,
109
112
  createSegmenter,
110
- createCanvasTransform,
111
- createVideoTrackProcessor,
112
- createVideoTrackProcessorWithFallback,
113
+ createVideoProcessor,
114
+ getDefaultInputProcessAdaptor,
113
115
  } from '@pexip/media-processor';
114
116
 
115
117
  // Grab the user's camera stream
@@ -129,17 +131,22 @@ const modelAsset = {
129
131
  modelName: 'selfie' as const,
130
132
  };
131
133
 
132
- const segmenter = createSegmenter(tasksVisionBasePath, {modelAssets});
133
- // Create a processing transformer and set the effects to `blur`
134
- const transformer = createCanvasTransform(segmenter, {effects: 'blur'});
135
- const processor = createVideoProcessor([transformer]);
134
+ const segmenter = createSegmenter(tasksVisionBasePath, {modelAsset});
135
+ // Choose the appropriate input process adaptor based on browser capabilities
136
+ const inputProcessAdaptor = getDefaultInputProcessAdaptor(true);
137
+ // Create a processor and set the effects to `blur`
138
+ const processor = createVideoProcessor(segmenter, inputProcessAdaptor);
136
139
 
137
140
  // Start the processor
138
141
  await videoProcessor.open();
139
142
 
140
- // Passing the raw MediaStream to apply the effects
141
- // Then, use the output stream for whatever purpose
142
- const processedStream = await videoProcessor.process(stream);
143
+ // Start the processor with blur effects
144
+ await processor.open({renderOptions: {effects: 'blur'}});
145
+
146
+ // Process the video track and create a new stream
147
+ const videoTrack = stream.getVideoTracks()[0];
148
+ const processedTrack = await processor.process(videoTrack);
149
+ const processedStream = new MediaStream([processedTrack]);
143
150
  ```
144
151
 
145
152
  ## Profiling Web Audio
@@ -193,11 +200,13 @@ A library for media analysis using Web APIs.
193
200
  | Interface | Description |
194
201
  | ------ | ------ |
195
202
  | [Segmentation](interfaces/Segmentation.mdx) | - |
203
+ | [ReadWritableStream](interfaces/ReadWritableStream.mdx) | - |
196
204
  | [VideoFrameLike](interfaces/VideoFrameLike.mdx) | - |
197
205
  | [ImageRecord](interfaces/ImageRecord.mdx) | - |
198
206
  | [Rect](interfaces/Rect.mdx) | - |
199
207
  | [ProcessEventOpen](interfaces/ProcessEventOpen.mdx) | Message event to initializing the Processor |
200
208
  | [ProcessEventProcess](interfaces/ProcessEventProcess.mdx) | Message event to process the video frame |
209
+ | [ProcessEventMute](interfaces/ProcessEventMute.mdx) | - |
201
210
  | [ProcessEventUpdate](interfaces/ProcessEventUpdate.mdx) | Message event to update processor options |
202
211
  | [ProcessEventClose](interfaces/ProcessEventClose.mdx) | Message event to stop the processing |
203
212
  | [ProcessEventDestroy](interfaces/ProcessEventDestroy.mdx) | Message event to release all the resources |
@@ -207,6 +216,8 @@ A library for media analysis using Web APIs.
207
216
  | [ProcessWorkerEventUpdated](interfaces/ProcessWorkerEventUpdated.mdx) | - |
208
217
  | [ProcessWorkerEvent](interfaces/ProcessWorkerEvent.mdx) | - |
209
218
  | [ProcessWorkerEventDebug](interfaces/ProcessWorkerEventDebug.mdx) | - |
219
+ | [FrameTransformStats](interfaces/FrameTransformStats.mdx) | Frame transform statistic, i.e. the timing data for processing each frame |
220
+ | [ProcessWorkerEventStats](interfaces/ProcessWorkerEventStats.mdx) | - |
210
221
  | [ProcessorOptions](interfaces/ProcessorOptions.mdx) | - |
211
222
  | [ProcessorProcessOptions](interfaces/ProcessorProcessOptions.mdx) | - |
212
223
  | [ProcessWorkerDebugMessage](interfaces/ProcessWorkerDebugMessage.mdx) | - |
@@ -242,13 +253,12 @@ A library for media analysis using Web APIs.
242
253
  | [Clock](interfaces/Clock.mdx) | Clock interface to get the current time with now method, |
243
254
  | [ThrottleOptions](interfaces/ThrottleOptions.mdx) | Limit the rate of flow in terms of millisecond, and provided Clock |
244
255
  | [Runner](interfaces/Runner.mdx) | - |
245
- | [Transform](interfaces/Transform.mdx) | - |
246
256
  | [AsyncAssets](interfaces/AsyncAssets.mdx) | - |
247
257
  | [Process](interfaces/Process.mdx) | - |
248
258
  | [BackgroundImage](interfaces/BackgroundImage.mdx) | - |
249
259
  | [Segmenter](interfaces/Segmenter.mdx) | - |
250
- | [Detector](interfaces/Detector.mdx) | - |
251
- | [SegmentationParams](interfaces/SegmentationParams.mdx) | Options controlling the rendering and effects for person/background segmentation. All values are stable per-frame and can be safely updated in real-time. |
260
+ | [InputProcessAdaptor](interfaces/InputProcessAdaptor.mdx) | - |
261
+ | [ProcessorUpdateOptions](interfaces/ProcessorUpdateOptions.mdx) | - |
252
262
  | [VideoProcessor](interfaces/VideoProcessor.mdx) | - |
253
263
 
254
264
  ## Type Aliases
@@ -266,6 +276,7 @@ A library for media analysis using Web APIs.
266
276
  | [ProcessWorkerEvents](type-aliases/ProcessWorkerEvents.mdx) | Message events returned from the processor |
267
277
  | [ProcessorEvents](type-aliases/ProcessorEvents.mdx) | - |
268
278
  | [ProcessorWorkerEvents](type-aliases/ProcessorWorkerEvents.mdx) | - |
279
+ | [Struct](type-aliases/Struct.mdx) | - |
269
280
  | [SegmentationModel](type-aliases/SegmentationModel.mdx) | - |
270
281
  | [Delegate](type-aliases/Delegate.mdx) | - |
271
282
  | [ExtractMessageEventType](type-aliases/ExtractMessageEventType.mdx) | - |
@@ -309,8 +320,6 @@ A library for media analysis using Web APIs.
309
320
  | [WasmPaths](type-aliases/WasmPaths.mdx) | - |
310
321
  | [Color](type-aliases/Color.mdx) | - |
311
322
  | [InputFrame](type-aliases/InputFrame.mdx) | - |
312
- | [SegmentationTransform](type-aliases/SegmentationTransform.mdx) | - |
313
- | [ProcessVideoTrack](type-aliases/ProcessVideoTrack.mdx) | - |
314
323
 
315
324
  ## Variables
316
325
 
@@ -342,18 +351,24 @@ A library for media analysis using Web APIs.
342
351
  | [RENDER\_EFFECT](variables/RENDER_EFFECT.mdx) | - |
343
352
  | [RENDER\_BACKEND](variables/RENDER_BACKEND.mdx) | - |
344
353
  | [RENDERING\_EVENTS](variables/RENDERING_EVENTS.mdx) | - |
354
+ | [isValidGpuAPI](variables/isValidGpuAPI.mdx) | - |
355
+ | [isRenderOptionsKey](variables/isRenderOptionsKey.mdx) | - |
356
+ | [RENDERER\_OPTIONS\_STRUCT](variables/RENDERER_OPTIONS_STRUCT.mdx) | - |
345
357
  | [SEGMENTATION\_MODELS](variables/SEGMENTATION_MODELS.mdx) | - |
346
358
  | [isSegmentationModel](variables/isSegmentationModel.mdx) | - |
347
359
  | [isRenderingEvents](variables/isRenderingEvents.mdx) | - |
348
360
  | [toRenderingEvents](variables/toRenderingEvents.mdx) | - |
349
361
  | [getErrorMessage](variables/getErrorMessage.mdx) | - |
350
362
  | [createObjectUpdater](variables/createObjectUpdater.mdx) | - |
363
+ | [ImageFetchError](variables/ImageFetchError.mdx) | - |
351
364
  | [createRemoteImageBitmap](variables/createRemoteImageBitmap.mdx) | - |
352
365
  | [clamping](variables/clamping.mdx) | - |
353
366
  | [calculateMaxBlurPass](variables/calculateMaxBlurPass.mdx) | - |
354
367
  | [resize](variables/resize.mdx) | Calculate the coordinates and size of the source and destination to fit the target aspect ratio. |
355
368
  | [createLazyProps](variables/createLazyProps.mdx) | - |
356
369
  | [handleWebGLContextLoss](variables/handleWebGLContextLoss.mdx) | - |
370
+ | [cloneImageRecord](variables/cloneImageRecord.mdx) | - |
371
+ | [compareImageRecords](variables/compareImageRecords.mdx) | Compare provided ImageRecord |
357
372
  | [urls](variables/urls.mdx) | - |
358
373
  | [SILENT\_THRESHOLD](variables/SILENT_THRESHOLD.mdx) | Default silent threshold At least one LSB 16-bit data (compare is on absolute value). |
359
374
  | [MONO\_THRESHOLD](variables/MONO_THRESHOLD.mdx) | Default mono detection threshold Data must be identical within one LSB 16-bit to be identified as mono. |
@@ -361,6 +376,7 @@ A library for media analysis using Web APIs.
361
376
  | [CLIP\_THRESHOLD](variables/CLIP_THRESHOLD.mdx) | Default clipping detection threshold |
362
377
  | [VOICE\_PROBABILITY\_THRESHOLD](variables/VOICE_PROBABILITY_THRESHOLD.mdx) | Default Voice probability threshold |
363
378
  | [CLIP\_COUNT\_THRESHOLD](variables/CLIP_COUNT_THRESHOLD.mdx) | Default clipping count threshold Number of consecutive clipThreshold level samples that indicate clipping. |
379
+ | [MediaStreamTrackTransferable](variables/MediaStreamTrackTransferable.mdx) | Result of the feature detection if `MediaStreamTrack` is `Transferable` |
364
380
  | [FRAME\_RATE](variables/FRAME_RATE.mdx) | - |
365
381
  | [PLAY\_VIDEO\_TIMEOUT](variables/PLAY_VIDEO_TIMEOUT.mdx) | - |
366
382
 
@@ -419,18 +435,21 @@ A library for media analysis using Web APIs.
419
435
  | [isAudioNodeInit](functions/isAudioNodeInit.mdx) | - |
420
436
  | [isAnalyzerNodeInit](functions/isAnalyzerNodeInit.mdx) | - |
421
437
  | [createAsyncCallbackLoop](functions/createAsyncCallbackLoop.mdx) | Create an async callback loop to be called recursively with delay based on the `frameRate` |
422
- | [createCanvasTransform](functions/createCanvasTransform.mdx) | - |
438
+ | [createReadWritableStreamInputProcessAdaptor](functions/createReadWritableStreamInputProcessAdaptor.mdx) | An implementation of `InputProcessAdaptor` which uses `MediaStreamTrackGenerator` and `MediaStreamTrackProcessor` APIs to create `ReadableStream` & `WritableStream` |
439
+ | [createReadWritableStreamFallbackInputProcessAdaptor](functions/createReadWritableStreamFallbackInputProcessAdaptor.mdx) | An implementation of `InputProcessAdaptor` which uses `HTMLCanvasElement` or `OffscreenCanvas` API to create `ReadableStream` & `WritableStream` |
440
+ | [createMediaStreamTrackInputProcessAdaptor](functions/createMediaStreamTrackInputProcessAdaptor.mdx) | An implementation of `InputProcessAdaptor` which adapts `MediaStreamTrack` directly as specified from the spec https://w3c.github.io/mediacapture-transform |
441
+ | [getDefaultInputProcessAdaptor](functions/getDefaultInputProcessAdaptor.mdx) | Get the supported InputProcessAdaptor based on feature detection and preference provided |
423
442
  | [loadScript](functions/loadScript.mdx) | - |
424
443
  | [loadWasms](functions/loadWasms.mdx) | - |
425
444
  | [createSegmenter](functions/createSegmenter.mdx) | - |
426
445
  | [isRenderEffects](functions/isRenderEffects.mdx) | - |
446
+ | [isMediaStreamVideoTrack](functions/isMediaStreamVideoTrack.mdx) | - |
447
+ | [assertMediaStreamVideoTrack](functions/assertMediaStreamVideoTrack.mdx) | - |
427
448
  | [createCanvas](functions/createCanvas.mdx) | Create a Canvas element with provided width and height |
428
449
  | [setVideoElementSrc](functions/setVideoElementSrc.mdx) | - |
429
450
  | [playVideo](functions/playVideo.mdx) | - |
430
451
  | [createFrameCallbackRequest](functions/createFrameCallbackRequest.mdx) | Create a callback loop for video frame processing using `requestVideoFrameCallback` under-the-hood when available otherwise our fallback implementation based on `setTimeout`. |
431
452
  | [createVideoProcessor](functions/createVideoProcessor.mdx) | - |
432
- | [createVideoTrackProcessor](functions/createVideoTrackProcessor.mdx) | Video track processor using MediaStreamTrackProcessor API |
433
- | [createVideoTrackProcessorWithFallback](functions/createVideoTrackProcessorWithFallback.mdx) | Video track processor using Canvas[captureStream] API |
434
453
  | [calculateDistance](functions/calculateDistance.mdx) | Calculate the distance between two Points |
435
454
  | [getBezierCurveControlPoints](functions/getBezierCurveControlPoints.mdx) | Spline Interpolation for Bezier Curve |
436
455
  | [line](functions/line.mdx) | Create a straight line path command |
@@ -0,0 +1,13 @@
1
+ ```ts
2
+ function assertMediaStreamVideoTrack(t): asserts t is MediaStreamVideoTrack;
3
+ ```
4
+
5
+ ## Parameters
6
+
7
+ | Parameter | Type |
8
+ | ------ | ------ |
9
+ | `t` | `MediaStreamTrack` |
10
+
11
+ ## Returns
12
+
13
+ `asserts t is MediaStreamVideoTrack`
@@ -1,5 +1,5 @@
1
1
  ```ts
2
- function createFrameCallbackRequest(
2
+ function createFrameCallbackRequest<T>(
3
3
  callback,
4
4
  frameRate,
5
5
  __namedParameters): object;
@@ -9,11 +9,17 @@ Create a callback loop for video frame processing using
9
9
  `requestVideoFrameCallback` under-the-hood when available otherwise our
10
10
  fallback implementation based on `setTimeout`.
11
11
 
12
+ ## Type Parameters
13
+
14
+ | Type Parameter |
15
+ | ------ |
16
+ | `T` |
17
+
12
18
  ## Parameters
13
19
 
14
20
  | Parameter | Type | Description |
15
21
  | ------ | ------ | ------ |
16
- | `callback` | [`Callback`](../type-aliases/Callback.mdx)\<`Promise`\<`void`\>, \[[`ProcessInputType`](../type-aliases/ProcessInputType.mdx)\]\> | To be called by the loop |
22
+ | `callback` | [`Callback`](../type-aliases/Callback.mdx)\<`Promise`\<`void`\>, \[`T`\]\> | To be called by the loop |
17
23
  | `frameRate` | `number` | A fallback frame rate when we are not able to get the rate from API |
18
24
  | `__namedParameters` | `FrameCallbackRequestOptions` | - |
19
25
 
@@ -0,0 +1,10 @@
1
+ ```ts
2
+ function createMediaStreamTrackInputProcessAdaptor(): InputProcessAdaptor;
3
+ ```
4
+
5
+ An implementation of `InputProcessAdaptor` which adapts `MediaStreamTrack`
6
+ directly as specified from the spec https://w3c.github.io/mediacapture-transform
7
+
8
+ ## Returns
9
+
10
+ [`InputProcessAdaptor`](../interfaces/InputProcessAdaptor.mdx)
@@ -0,0 +1,17 @@
1
+ ```ts
2
+ function createReadWritableStreamFallbackInputProcessAdaptor(__namedParameters): InputProcessAdaptor;
3
+ ```
4
+
5
+ An implementation of `InputProcessAdaptor` which uses `HTMLCanvasElement` or
6
+ `OffscreenCanvas` API to create `ReadableStream` & `WritableStream`
7
+
8
+ ## Parameters
9
+
10
+ | Parameter | Type | Description |
11
+ | ------ | ------ | ------ |
12
+ | `__namedParameters` | \{ `frameRate`: `number`; \} | - |
13
+ | `__namedParameters.frameRate` | `number` | Fallback frame rate |
14
+
15
+ ## Returns
16
+
17
+ [`InputProcessAdaptor`](../interfaces/InputProcessAdaptor.mdx)
@@ -0,0 +1,10 @@
1
+ ```ts
2
+ function createReadWritableStreamInputProcessAdaptor(): InputProcessAdaptor;
3
+ ```
4
+
5
+ An implementation of `InputProcessAdaptor` which uses `MediaStreamTrackGenerator` and
6
+ `MediaStreamTrackProcessor` APIs to create `ReadableStream` & `WritableStream`
7
+
8
+ ## Returns
9
+
10
+ [`InputProcessAdaptor`](../interfaces/InputProcessAdaptor.mdx)
@@ -1,13 +1,13 @@
1
1
  ```ts
2
- function createVideoProcessor(transformers, processTrack): VideoProcessor;
2
+ function createVideoProcessor(segmenter, inputProcessAdaptor): VideoProcessor;
3
3
  ```
4
4
 
5
5
  ## Parameters
6
6
 
7
7
  | Parameter | Type |
8
8
  | ------ | ------ |
9
- | `transformers` | [`Transform`](../interfaces/Transform.mdx)\<[`InputFrame`](../type-aliases/InputFrame.mdx), [`InputFrame`](../type-aliases/InputFrame.mdx)\>[] |
10
- | `processTrack` | [`ProcessVideoTrack`](../type-aliases/ProcessVideoTrack.mdx) |
9
+ | `segmenter` | [`Segmenter`](../interfaces/Segmenter.mdx) |
10
+ | `inputProcessAdaptor` | [`InputProcessAdaptor`](../interfaces/InputProcessAdaptor.mdx) |
11
11
 
12
12
  ## Returns
13
13
 
@@ -0,0 +1,17 @@
1
+ ```ts
2
+ function getDefaultInputProcessAdaptor(tryNativeAPI, targetFrameRate): InputProcessAdaptor;
3
+ ```
4
+
5
+ Get the supported InputProcessAdaptor based on feature detection
6
+ and preference provided
7
+
8
+ ## Parameters
9
+
10
+ | Parameter | Type | Default value | Description |
11
+ | ------ | ------ | ------ | ------ |
12
+ | `tryNativeAPI` | `boolean` | `true` | Whether or not to try to use the Native MediaStreamTrackProcessor APIs |
13
+ | `targetFrameRate` | `number` | `FRAME_RATE` | The target frame rate to use when fallback implementation of video frame extraction rate |
14
+
15
+ ## Returns
16
+
17
+ [`InputProcessAdaptor`](../interfaces/InputProcessAdaptor.mdx)
@@ -0,0 +1,13 @@
1
+ ```ts
2
+ function isMediaStreamVideoTrack(t): t is MediaStreamVideoTrack;
3
+ ```
4
+
5
+ ## Parameters
6
+
7
+ | Parameter | Type |
8
+ | ------ | ------ |
9
+ | `t` | `MediaStreamTrack` |
10
+
11
+ ## Returns
12
+
13
+ `t is MediaStreamVideoTrack`
@@ -1,5 +1,5 @@
1
1
  ```ts
2
- function playVideo(video, __namedParameters): Promise<void>;
2
+ function playVideo(video, __namedParameters): Promise<[void, void]> | undefined;
3
3
  ```
4
4
 
5
5
  ## Parameters
@@ -13,4 +13,4 @@ function playVideo(video, __namedParameters): Promise<void>;
13
13
 
14
14
  ## Returns
15
15
 
16
- `Promise`\<`void`\>
16
+ `Promise`\<\[`void`, `void`\]\> \| `undefined`
@@ -163,6 +163,8 @@ connect(
163
163
  input?): AudioNode;
164
164
  ```
165
165
 
166
+ The **`connect()`** method of the AudioNode interface lets you connect one of the node's outputs to a target, which may be either another AudioNode (thereby directing the sound data to the specified node) or an AudioParam, so that the node's output data is automatically used to change the value of that parameter over time.
167
+
166
168
  [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioNode/connect)
167
169
 
168
170
  ##### Parameters
@@ -216,6 +218,8 @@ BaseAudioNode.connect
216
218
  disconnect(): void;
217
219
  ```
218
220
 
221
+ The **`disconnect()`** method of the AudioNode interface lets you disconnect one or more nodes from the node on which the method is called.
222
+
219
223
  [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioNode/disconnect)
220
224
 
221
225
  ##### Returns
@@ -3,9 +3,15 @@
3
3
  ### begin()
4
4
 
5
5
  ```ts
6
- begin(): void;
6
+ begin(timestamp?): void;
7
7
  ```
8
8
 
9
+ #### Parameters
10
+
11
+ | Parameter | Type |
12
+ | ------ | ------ |
13
+ | `timestamp?` | `number` |
14
+
9
15
  #### Returns
10
16
 
11
17
  `void`
@@ -15,9 +21,15 @@ begin(): void;
15
21
  ### end()
16
22
 
17
23
  ```ts
18
- end(): void;
24
+ end(timestamp?): void;
19
25
  ```
20
26
 
27
+ #### Parameters
28
+
29
+ | Parameter | Type |
30
+ | ------ | ------ |
31
+ | `timestamp?` | `number` |
32
+
21
33
  #### Returns
22
34
 
23
35
  `void`
@@ -0,0 +1,9 @@
1
+ Frame transform statistic, i.e. the timing data for processing each frame
2
+
3
+ ## Properties
4
+
5
+ | Property | Type | Description |
6
+ | ------ | ------ | ------ |
7
+ | <a id="start"></a> `start` | `number` | Start time of the transform |
8
+ | <a id="end"></a> `end` | `number` | End time of the transform |
9
+ | <a id="segmentation"></a> `segmentation?` | `number` | Segmentation inference end time |
@@ -22,6 +22,8 @@ connect(
22
22
  input?): AudioNode;
23
23
  ```
24
24
 
25
+ The **`connect()`** method of the AudioNode interface lets you connect one of the node's outputs to a target, which may be either another AudioNode (thereby directing the sound data to the specified node) or an AudioParam, so that the node's output data is automatically used to change the value of that parameter over time.
26
+
25
27
  [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioNode/connect)
26
28
 
27
29
  ##### Parameters
@@ -75,6 +77,8 @@ BaseAudioNode.connect
75
77
  disconnect(): void;
76
78
  ```
77
79
 
80
+ The **`disconnect()`** method of the AudioNode interface lets you disconnect one or more nodes from the node on which the method is called.
81
+
78
82
  [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioNode/disconnect)
79
83
 
80
84
  ##### Returns
@@ -2,7 +2,5 @@
2
2
 
3
3
  | Property | Type | Description |
4
4
  | ------ | ------ | ------ |
5
- | <a id="canvas"></a> `canvas?` | `OffscreenCanvas` | The canvas element to bind textures to. This has to be set for GPU processing. The task will initialize a WebGL or WebGPU context and throw an error if this fails (e.g. if you have already initialized a different type of context). |
6
- | <a id="segmentercanvas"></a> `segmenterCanvas?` | `OffscreenCanvas` | The Google TaskVision segmentation model only works with WebGl so we need a separate canvas for this. |
7
5
  | <a id="modelasset"></a> `modelAsset?` | [`SegmentationModelAsset`](SegmentationModelAsset.mdx) | - |
8
6
  | <a id="delegate"></a> `delegate?` | [`Delegate`](../type-aliases/Delegate.mdx) | Overrides the default backend to use for the provided model. |
@@ -0,0 +1,28 @@
1
+ ## Properties
2
+
3
+ | Property | Type | Description |
4
+ | ------ | ------ | ------ |
5
+ | <a id="outputtrack"></a> `outputTrack?` | `MediaStreamTrack` | The generated track from the `adapt` function, and only available after calling the `adapt` method otherwise `undefined` |
6
+
7
+ ## Methods
8
+
9
+ ### adapt()
10
+
11
+ ```ts
12
+ adapt(track):
13
+ | MediaStreamTrack
14
+ | ReadWritableStream<VideoFrame>;
15
+ ```
16
+
17
+ Adapt the provided input track based on browser capabilities.
18
+
19
+ #### Parameters
20
+
21
+ | Parameter | Type |
22
+ | ------ | ------ |
23
+ | `track` | `MediaStreamTrack` |
24
+
25
+ #### Returns
26
+
27
+ \| `MediaStreamTrack`
28
+ \| [`ReadWritableStream`](ReadWritableStream.mdx)\<`VideoFrame`\>
@@ -1,7 +1,12 @@
1
1
  ## Extended by
2
2
 
3
3
  - [`Segmenter`](Segmenter.mdx)
4
- - [`Detector`](Detector.mdx)
4
+
5
+ ## Type Parameters
6
+
7
+ | Type Parameter |
8
+ | ------ |
9
+ | `T` |
5
10
 
6
11
  ## Properties
7
12
 
@@ -14,12 +19,12 @@
14
19
  ### open()
15
20
 
16
21
  ```ts
17
- open(): Promise<void>;
22
+ open(): Promise<T>;
18
23
  ```
19
24
 
20
25
  #### Returns
21
26
 
22
- `Promise`\<`void`\>
27
+ `Promise`\<`T`\>
23
28
 
24
29
  ***
25
30
 
@@ -0,0 +1,6 @@
1
+ ## Properties
2
+
3
+ | Property | Type |
4
+ | ------ | ------ |
5
+ | <a id="type"></a> `type` | `"mute"` |
6
+ | <a id="data"></a> `data` | `boolean` |
@@ -1,5 +1,12 @@
1
+ ## Type Parameters
2
+
3
+ | Type Parameter |
4
+ | ------ |
5
+ | `T` |
6
+
1
7
  ## Properties
2
8
 
3
9
  | Property | Type |
4
10
  | ------ | ------ |
5
11
  | <a id="type"></a> `type` | `"opened"` |
12
+ | <a id="data"></a> `data` | `T` |
@@ -0,0 +1,6 @@
1
+ ## Properties
2
+
3
+ | Property | Type |
4
+ | ------ | ------ |
5
+ | <a id="type"></a> `type` | `"stats"` |
6
+ | <a id="data"></a> `data` | [`FrameTransformStats`](FrameTransformStats.mdx)[] |
@@ -1,5 +1,12 @@
1
+ ## Type Parameters
2
+
3
+ | Type Parameter |
4
+ | ------ |
5
+ | `T` |
6
+
1
7
  ## Properties
2
8
 
3
9
  | Property | Type |
4
10
  | ------ | ------ |
5
11
  | <a id="type"></a> `type` | `"updated"` |
12
+ | <a id="data"></a> `data` | `T` |
@@ -4,4 +4,4 @@
4
4
  | ------ | ------ |
5
5
  | <a id="type"></a> `type` | \| `"Error"` \| `"ContextCreationError"` \| `"ContextLost"` \| `"ContextRestored"` \| `"ProcessorRestarted"` \| `"SamplingError"` |
6
6
  | <a id="message"></a> `message?` | `string` |
7
- | <a id="frame"></a> `frame?` | [`VideoFrameLike`](VideoFrameLike.mdx) |
7
+ | <a id="track"></a> `track?` | `MediaStreamTrack` |
@@ -10,7 +10,6 @@
10
10
  | <a id="backgroundimage"></a> `backgroundImage?` | [`ImageRecord`](ImageRecord.mdx) | - |
11
11
  | <a id="restart"></a> `restart?` | `boolean` | - |
12
12
  | <a id="basepath"></a> `basePath?` | `string` | [`SegmenterOptions`](SegmenterOptions.mdx).[`basePath`](SegmenterOptions.mdx#basepath) |
13
- | <a id="output"></a> `output?` | `OffscreenCanvas` \| `null` | [`SegmenterOptions`](SegmenterOptions.mdx).[`output`](SegmenterOptions.mdx#output) |
14
13
  | <a id="processingwidth"></a> `processingWidth?` | `number` | [`SegmenterOptions`](SegmenterOptions.mdx).[`processingWidth`](SegmenterOptions.mdx#processingwidth) |
15
14
  | <a id="processingheight"></a> `processingHeight?` | `number` | [`SegmenterOptions`](SegmenterOptions.mdx).[`processingHeight`](SegmenterOptions.mdx#processingheight) |
16
15
  | <a id="imagesegmenteroptions"></a> `imageSegmenterOptions?` | [`ImageSegmenterOptions`](ImageSegmenterOptions.mdx) | [`SegmenterOptions`](SegmenterOptions.mdx).[`imageSegmenterOptions`](SegmenterOptions.mdx#imagesegmenteroptions) |
@@ -2,5 +2,7 @@
2
2
 
3
3
  | Property | Type |
4
4
  | ------ | ------ |
5
- | <a id="videoframe"></a> `videoFrame` | [`VideoFrameLike`](VideoFrameLike.mdx) |
5
+ | <a id="track"></a> `track?` | `MediaStreamTrack` |
6
+ | <a id="readable"></a> `readable?` | `ReadableStream`\<`VideoFrame`\> |
7
+ | <a id="writable"></a> `writable?` | `WritableStream`\<`VideoFrame`\> |
6
8
  | <a id="renderoptions"></a> `renderOptions?` | [`RendererOptions`](RendererOptions.mdx) |