@pexip/media-processor 21.0.0 → 22.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.
Files changed (170) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +17 -10
  3. package/api-docs/README.mdx +40 -19
  4. package/api-docs/functions/assertMediaStreamVideoTrack.mdx +13 -0
  5. package/api-docs/functions/avg.mdx +1 -1
  6. package/api-docs/functions/createAnalyzerGraphNode.mdx +3 -1
  7. package/api-docs/functions/createAnalyzerSubscribableGraphNode.mdx +3 -1
  8. package/api-docs/functions/createAsyncCallbackLoop.mdx +6 -6
  9. package/api-docs/functions/createAudioDestinationGraphNode.mdx +1 -1
  10. package/api-docs/functions/createAudioSignalDetector.mdx +4 -4
  11. package/api-docs/functions/createAudioStats.mdx +1 -1
  12. package/api-docs/functions/createChannelMergerGraphNode.mdx +1 -1
  13. package/api-docs/functions/createChannelSplitterGraphNode.mdx +1 -1
  14. package/api-docs/functions/createDelayGraphNode.mdx +1 -1
  15. package/api-docs/functions/createDenoiseWorkletGraphNode.mdx +2 -2
  16. package/api-docs/functions/createFrameCallbackRequest.mdx +10 -4
  17. package/api-docs/functions/createGainGraphNode.mdx +3 -1
  18. package/api-docs/functions/createMediaElementSourceGraphNode.mdx +1 -1
  19. package/api-docs/functions/createMediaStreamTrackInputProcessAdaptor.mdx +10 -0
  20. package/api-docs/functions/createReadWritableStreamFallbackInputProcessAdaptor.mdx +17 -0
  21. package/api-docs/functions/createReadWritableStreamInputProcessAdaptor.mdx +10 -0
  22. package/api-docs/functions/createSegmenter.mdx +1 -1
  23. package/api-docs/functions/createStreamDestinationGraphNode.mdx +1 -1
  24. package/api-docs/functions/createStreamSourceGraphNode.mdx +1 -1
  25. package/api-docs/functions/createVADetector.mdx +3 -3
  26. package/api-docs/functions/createVideoProcessor.mdx +3 -3
  27. package/api-docs/functions/createVoiceDetectorFromProbability.mdx +1 -1
  28. package/api-docs/functions/createVoiceDetectorFromTimeData.mdx +3 -1
  29. package/api-docs/functions/createWindowedStats.mdx +2 -2
  30. package/api-docs/functions/getBezierCurveControlPoints.mdx +3 -1
  31. package/api-docs/functions/getDefaultInputProcessAdaptor.mdx +17 -0
  32. package/api-docs/functions/isMediaStreamVideoTrack.mdx +13 -0
  33. package/api-docs/functions/labelComponents.mdx +3 -1
  34. package/api-docs/functions/loadScript.mdx +1 -1
  35. package/api-docs/functions/loadWasms.mdx +1 -1
  36. package/api-docs/functions/nearestPowerOfTwo.mdx +1 -1
  37. package/api-docs/functions/playVideo.mdx +7 -5
  38. package/api-docs/functions/processAverageVolume.mdx +1 -1
  39. package/api-docs/functions/rms.mdx +1 -1
  40. package/api-docs/functions/subscribeWorkletNode.mdx +1 -1
  41. package/api-docs/functions/sum.mdx +1 -1
  42. package/api-docs/interfaces/Analyzer.mdx +4 -0
  43. package/api-docs/interfaces/AnalyzerSubscribableOptions.mdx +5 -3
  44. package/api-docs/interfaces/AudioGraph.mdx +2 -2
  45. package/api-docs/interfaces/AudioNodeInit.mdx +10 -6
  46. package/api-docs/interfaces/AudioNodeProps.mdx +3 -3
  47. package/api-docs/interfaces/Benchmark.mdx +17 -3
  48. package/api-docs/interfaces/Clock.mdx +1 -1
  49. package/api-docs/interfaces/Denoise.mdx +2 -2
  50. package/api-docs/interfaces/FrameTransformStats.mdx +9 -0
  51. package/api-docs/interfaces/Gain.mdx +4 -0
  52. package/api-docs/interfaces/ImageSegmenterOptions.mdx +0 -2
  53. package/api-docs/interfaces/InputProcessAdaptor.mdx +32 -0
  54. package/api-docs/interfaces/MPMask.mdx +1 -1
  55. package/api-docs/interfaces/Process.mdx +12 -7
  56. package/api-docs/interfaces/ProcessEventMute.mdx +6 -0
  57. package/api-docs/interfaces/ProcessWorkerDebugMessage.mdx +1 -1
  58. package/api-docs/interfaces/ProcessWorkerEventClosed.mdx +5 -0
  59. package/api-docs/interfaces/ProcessWorkerEventOpened.mdx +7 -0
  60. package/api-docs/interfaces/ProcessWorkerEventStats.mdx +6 -0
  61. package/api-docs/interfaces/ProcessWorkerEventUpdated.mdx +7 -0
  62. package/api-docs/interfaces/ProcessorEvent.mdx +3 -2
  63. package/api-docs/interfaces/ProcessorOptions.mdx +0 -1
  64. package/api-docs/interfaces/ProcessorProcessOptions.mdx +3 -1
  65. package/api-docs/interfaces/ProcessorUpdateOptions.mdx +17 -0
  66. package/api-docs/interfaces/ReadWritableStream.mdx +12 -0
  67. package/api-docs/interfaces/RenderEventHandlers.mdx +3 -3
  68. package/api-docs/interfaces/Renderer.mdx +5 -3
  69. package/api-docs/interfaces/RendererOptions.mdx +5 -9
  70. package/api-docs/interfaces/Runner.mdx +3 -3
  71. package/api-docs/interfaces/Segmentation.mdx +1 -1
  72. package/api-docs/interfaces/Segmenter.mdx +115 -16
  73. package/api-docs/interfaces/SegmenterOptions.mdx +0 -1
  74. package/api-docs/interfaces/VideoFrameLike.mdx +1 -1
  75. package/api-docs/interfaces/VideoProcessor.mdx +52 -8
  76. package/api-docs/interfaces/WorkletMessagePortOptions.mdx +2 -2
  77. package/api-docs/type-aliases/AsyncCallback.mdx +1 -1
  78. package/api-docs/type-aliases/Callback.mdx +2 -2
  79. package/api-docs/type-aliases/ExtractMessageEventType.mdx +1 -1
  80. package/api-docs/type-aliases/IncludeMessageEventDataType.mdx +1 -1
  81. package/api-docs/type-aliases/Logger.mdx +12 -0
  82. package/api-docs/type-aliases/OptionalKeys.mdx +1 -1
  83. package/api-docs/type-aliases/ProcessEvents.mdx +1 -0
  84. package/api-docs/type-aliases/ProcessInputType.mdx +3 -1
  85. package/api-docs/type-aliases/ProcessWorkerEvents.mdx +7 -4
  86. package/api-docs/type-aliases/ProcessorWorkerEvents.mdx +1 -1
  87. package/api-docs/type-aliases/RunnerCreator.mdx +3 -3
  88. package/api-docs/type-aliases/Struct.mdx +9 -0
  89. package/api-docs/type-aliases/TupleOf.mdx +1 -1
  90. package/api-docs/variables/FRAME_RATE.mdx +1 -1
  91. package/api-docs/variables/ImageFetchError.mdx +3 -0
  92. package/api-docs/variables/MediaStreamTrackTransferable.mdx +5 -0
  93. package/api-docs/variables/RENDERER_OPTIONS_STRUCT.mdx +3 -0
  94. package/api-docs/variables/cloneImageRecord.mdx +21 -0
  95. package/api-docs/variables/compareImageRecords.mdx +18 -0
  96. package/api-docs/variables/createLazyProps.mdx +1 -1
  97. package/api-docs/variables/createObjectUpdater.mdx +2 -2
  98. package/api-docs/variables/createRemoteImageBitmap.mdx +5 -5
  99. package/api-docs/variables/handleWebGLContextLoss.mdx +1 -1
  100. package/api-docs/variables/isRenderOptionsKey.mdx +13 -0
  101. package/api-docs/variables/isValidGpuAPI.mdx +13 -0
  102. package/api-docs/variables/urls.mdx +2 -2
  103. package/dist/common/backends/webgl/renderer.js +2 -12
  104. package/dist/common/backends/webgl/texture.d.ts +1 -2
  105. package/dist/common/backends/webgl/texture.js +2 -2
  106. package/dist/common/backends/webgl/webglUtils.js +8 -4
  107. package/dist/common/backends/webgpu/renderer.js +2 -12
  108. package/dist/common/backends/webgpu/tentBlur.js +1 -1
  109. package/dist/common/backends/webgpu/texture.d.ts +1 -2
  110. package/dist/common/backends/webgpu/texture.js +6 -2
  111. package/dist/common/constants.d.ts +3 -0
  112. package/dist/common/constants.js +4 -0
  113. package/dist/common/index.d.ts +1 -0
  114. package/dist/common/index.js +1 -0
  115. package/dist/common/tsconfig.tsbuildinfo +1 -1
  116. package/dist/common/typeGuards.d.ts +2 -0
  117. package/dist/common/typeGuards.js +7 -0
  118. package/dist/common/types/media.d.ts +5 -1
  119. package/dist/common/types/messageEvents.d.ts +34 -4
  120. package/dist/common/types/processor.d.ts +7 -4
  121. package/dist/common/types/render.d.ts +5 -2
  122. package/dist/common/types/render.js +23 -1
  123. package/dist/common/types/segmentation.d.ts +0 -12
  124. package/dist/common/utils.d.ts +13 -2
  125. package/dist/common/utils.js +54 -10
  126. package/dist/main/audio.js +3 -3
  127. package/dist/main/benchUtils.d.ts +2 -2
  128. package/dist/main/benchUtils.js +4 -4
  129. package/dist/main/index.d.ts +1 -1
  130. package/dist/main/index.js +1 -1
  131. package/dist/main/tsconfig.tsbuildinfo +1 -1
  132. package/dist/main/types.d.ts +0 -6
  133. package/dist/main/utils.d.ts +4 -0
  134. package/dist/main/utils.js +31 -0
  135. package/dist/main/video/constants.d.ts +1 -4
  136. package/dist/main/video/constants.js +1 -5
  137. package/dist/main/video/index.d.ts +2 -3
  138. package/dist/main/video/index.js +2 -3
  139. package/dist/main/video/inputProcessAdaptor.d.ts +30 -0
  140. package/dist/main/video/inputProcessAdaptor.js +198 -0
  141. package/dist/main/video/segmenter.d.ts +42 -0
  142. package/dist/main/video/{segmenters/mediapipe.js → segmenter.js} +130 -75
  143. package/dist/main/video/typeGuards.d.ts +2 -0
  144. package/dist/main/video/typeGuards.js +8 -1
  145. package/dist/main/video/types.d.ts +37 -17
  146. package/dist/main/video/utils.d.ts +5 -4
  147. package/dist/main/video/utils.js +49 -44
  148. package/dist/main/video/video.d.ts +30 -8
  149. package/dist/main/video/video.js +338 -32
  150. package/dist/workers/mediaWorker.js +24 -24
  151. package/dist/workers/tsconfig.tsbuildinfo +1 -1
  152. package/dist/worklets/tsconfig.tsbuildinfo +1 -1
  153. package/package.json +8 -8
  154. package/api-docs/functions/createCanvasTransform.mdx +0 -14
  155. package/api-docs/functions/createVideoTrackProcessor.mdx +0 -9
  156. package/api-docs/functions/createVideoTrackProcessorWithFallback.mdx +0 -15
  157. package/api-docs/interfaces/Detector.mdx +0 -81
  158. package/api-docs/interfaces/SegmentationParams.mdx +0 -35
  159. package/api-docs/interfaces/Transform.mdx +0 -62
  160. package/api-docs/type-aliases/ProcessVideoTrack.mdx +0 -15
  161. package/api-docs/type-aliases/SegmentationTransform.mdx +0 -3
  162. package/dist/main/transformer.d.ts +0 -1
  163. package/dist/main/transformer.js +0 -4
  164. package/dist/main/video/canvasTransform.d.ts +0 -17
  165. package/dist/main/video/canvasTransform.js +0 -341
  166. package/dist/main/video/segmenters/mediapipe.d.ts +0 -22
  167. package/dist/main/video/transformer.d.ts +0 -9
  168. package/dist/main/video/transformer.js +0 -68
  169. package/dist/main/video/videoStreamTrackProcessor.d.ts +0 -20
  170. package/dist/main/video/videoStreamTrackProcessor.js +0 -86
@@ -1,10 +1,6 @@
1
1
  Options controlling the rendering and effects for person/background segmentation.
2
2
  All values are stable per-frame and can be safely updated in real-time.
3
3
 
4
- ## Extended by
5
-
6
- - [`SegmentationParams`](SegmentationParams.mdx)
7
-
8
4
  ## Properties
9
5
 
10
6
  | Property | Type | Description |
@@ -12,16 +8,16 @@ All values are stable per-frame and can be safely updated in real-time.
12
8
  | <a id="backgroundimageurl"></a> `backgroundImageUrl` | `string` | URL or Data URI for the virtual background image (used in "overlay" effect). |
13
9
  | <a id="backgroundbluramount"></a> `backgroundBlurAmount` | `number` | Amount of background blur (radius in px): [0,9]. Recommend: 3–6 for portraits. Higher may be slow and over-blurred. **Default** `3` |
14
10
  | <a id="edgebluramount"></a> `edgeBlurAmount` | `number` | Edge blur for mask boundary antialiasing (radius in px): [0,9]. Small values (1–5) smooth mask stair-steps; large values soften edges more visibly. **Default** `4` |
15
- | <a id="effects"></a> `effects` | `"blur"` \| `"none"` \| `"overlay"` | Effects to apply: "none", "blur", or "overlay". "blur" = background blur. "overlay" = replace BG with backgroundImageUrl. |
16
- | <a id="backend"></a> `backend` | `"webgl"` \| `"webgpu"` | Backend to render background effects |
17
- | <a id="foregroundthreshold"></a> `foregroundThreshold` | `number` | [0,1] Upper mask confidence: all mask pixels >= this are considered definite foreground. Adjust to make mask edges tighter or more permissive for foreground inclusion. Example: 0.8 ("mask > 0.8 = sure foreground"). Must always be >= backgroundThreshold. **Default** `0.85` |
18
- | <a id="backgroundthreshold"></a> `backgroundThreshold` | `number` | [0,1] Lower mask confidence: all mask pixels <= this are considered definite background. Adjust to make mask edges tighter or more permissive for background inclusion. Example: 0.3 ("mask < 0.3 = sure background"). **Default** `0.35` |
11
+ | <a id="effects"></a> `effects` | `"blur" \| "none" \| "overlay"` | Effects to apply: "none", "blur", or "overlay". "blur" = background blur. "overlay" = replace BG with backgroundImageUrl. |
12
+ | <a id="backend"></a> `backend` | `"webgl" \| "webgpu"` | Backend to render background effects |
13
+ | <a id="foregroundthreshold"></a> `foregroundThreshold` | `number` | [0,1] Upper mask confidence: all mask pixels \>= this are considered definite foreground. Adjust to make mask edges tighter or more permissive for foreground inclusion. Example: 0.8 ("mask \> 0.8 = sure foreground"). Must always be \>= backgroundThreshold. **Default** `0.85` |
14
+ | <a id="backgroundthreshold"></a> `backgroundThreshold` | `number` | [0,1] Lower mask confidence: all mask pixels \<= this are considered definite background. Adjust to make mask edges tighter or more permissive for background inclusion. Example: 0.3 ("mask \< 0.3 = sure background"). **Default** `0.35` |
19
15
  | <a id="sigmaspace"></a> `sigmaSpace` | `number` | Bilateral filter: sigma in pixel space for mask edge snapping. Controls the neighborhood/pixel distance—higher is larger window (5–10 typical). **Default** `5` |
20
16
  | <a id="sigmarangelo"></a> `sigmaRangeLo` | `number` | Bilateral filter: minimum sigma in color/luma (for mask interiors), [0,1]. Controls how little color difference is needed to cross-mask regions away from edge. Lower = sharper edge preservation in mask interiors. Example: 0.2 **Default** `0.2` |
21
17
  | <a id="sigmarangehi"></a> `sigmaRangeHi` | `number` | Bilateral filter: maximum sigma in color/luma (for mask uncertain zones), [0,1]. Controls how much color similarity is required at uncertain/edge mask locations. Higher = more mask smoothing at edges. Example: 0.8 **Default** `0.8` |
22
18
  | <a id="maskcombineratio"></a> `maskCombineRatio` | `number` | Ratio for mask smoothing (how much uncertainty enables temporal blend), [0,1]. Higher = more frame-to-frame blending, more stability but more trailing ghosts. Typical: 0.6–0.85. **Default** `0.8` |
23
19
  | <a id="excludebystanders"></a> `excludeBystanders` | `boolean` | **`Experimental`** Whether to exclude bystanders/connected people from the output mask. The main person instance (closest to personCenter OR largest blob) is kept in the output mask. All other bystanders/connected people are suppressed (bystander removal). **Default** `false (no bystander removal, all detected people are included in the mask). @experimental This feature is experimental and only works in WebGL backend.` |
24
- | <a id="personcenter"></a> `personCenter` | \[`number`, `number`\] | **`Experimental`** Person center: normalized (x, y) in [0,1] image coordinates for main subject selection. Used by the CCL/bias filter to select the main person blob. **Default** `[0.5, 0.42] (= center, slightly above vertical midpoint). @experimental This feature is experimental and only works in WebGL backend.` |
20
+ | <a id="personcenter"></a> `personCenter` | `[number, number]` | **`Experimental`** Person center: normalized (x, y) in [0,1] image coordinates for main subject selection. Used by the CCL/bias filter to select the main person blob. **Default** `[0.5, 0.42] (= center, slightly above vertical midpoint). @experimental This feature is experimental and only works in WebGL backend.` |
25
21
  | <a id="morpheroderadiuspx"></a> `morphErodeRadiusPx` | `number` | **`Experimental`** Morphological erosion: radius in pixels [1,12]. Sets kernel size for bridge-breaking. Larger values break thicker bridges but may erode fine details. **Default** `5 @experimental This feature is experimental and only works in WebGL backend.` |
26
22
  | <a id="morphpass"></a> `morphPass` | `number` | **`Experimental`** Morphological pass: number of separable passes [1,10]. More passes increase the effective span. **Default** `4 @experimental This feature is experimental and only works in WebGL backend.` |
27
23
  | <a id="morphdilateradiuspx"></a> `morphDilateRadiusPx` | `number` | **`Experimental`** Geodesic dilation: radius in pixels [1,12]. Must match erosion for good reconstruction. **Default** `6 @experimental This feature is experimental and only works in WebGL backend.` |
@@ -2,7 +2,7 @@
2
2
 
3
3
  | Type Parameter |
4
4
  | ------ |
5
- | `P` *extends* `unknown`[] |
5
+ | `P extends unknown[]` |
6
6
 
7
7
  ## Properties
8
8
 
@@ -22,11 +22,11 @@ start(...params): Promise<void>;
22
22
 
23
23
  | Parameter | Type |
24
24
  | ------ | ------ |
25
- | ...`params` | `P` |
25
+ | `...params` | `P` |
26
26
 
27
27
  #### Returns
28
28
 
29
- `Promise`\<`void`\>
29
+ `Promise<void>`
30
30
 
31
31
  ***
32
32
 
@@ -2,4 +2,4 @@
2
2
 
3
3
  | Property | Type |
4
4
  | ------ | ------ |
5
- | <a id="canvas"></a> `canvas` | `OffscreenCanvas` \| `undefined` |
5
+ | <a id="canvas"></a> `canvas` | `OffscreenCanvas \| undefined` |
@@ -1,12 +1,14 @@
1
1
  ## Extends
2
2
 
3
- - [`Process`](Process.mdx)
3
+ ```ts
4
+ - Process<Partial<RendererOptions>>
5
+ ```
4
6
 
5
7
  ## Properties
6
8
 
7
9
  | Property | Type | Inherited from |
8
10
  | ------ | ------ | ------ |
9
- | <a id="status"></a> `status` | \| `"closed"` \| `"closing"` \| `"Error"` \| `"destroyed"` \| `"destroying"` \| `"idle"` \| `"new"` \| `"opened"` \| `"opening"` \| `"processing"` \| `"updated"` \| `"updating"` | [`Process`](Process.mdx).[`status`](Process.mdx#status) |
11
+ | <a id="status"></a> `status` | `\| "closed" \| "closing" \| "Error" \| "destroyed" \| "destroying" \| "idle" \| "new" \| "opened" \| "opening" \| "processing" \| "updated" \| "updating"` | [`Process`](Process.mdx).[`status`](Process.mdx#status) |
10
12
  | <a id="modelasset"></a> `modelAsset` | [`SegmentationModelAsset`](SegmentationModelAsset.mdx) | - |
11
13
  | <a id="backgroundimage"></a> `backgroundImage?` | [`BackgroundImage`](BackgroundImage.mdx) | - |
12
14
 
@@ -15,12 +17,12 @@
15
17
  ### close()
16
18
 
17
19
  ```ts
18
- close(): void;
20
+ close(): Promise<void>;
19
21
  ```
20
22
 
21
23
  #### Returns
22
24
 
23
- `void`
25
+ `Promise<void>`
24
26
 
25
27
  #### Inherited from
26
28
 
@@ -36,7 +38,7 @@ destroy(): Promise<void>;
36
38
 
37
39
  #### Returns
38
40
 
39
- `Promise`\<`void`\>
41
+ `Promise<void>`
40
42
 
41
43
  #### Inherited from
42
44
 
@@ -47,9 +49,12 @@ destroy(): Promise<void>;
47
49
  ### open()
48
50
 
49
51
  ```ts
50
- open(options?): Promise<void>;
52
+ open(options?): Promise<Partial<RendererOptions>>;
51
53
  ```
52
54
 
55
+ Initialize the Segmenter as well as the underlying worker.
56
+ It is expected to be called once.
57
+
53
58
  #### Parameters
54
59
 
55
60
  | Parameter | Type |
@@ -58,7 +63,9 @@ open(options?): Promise<void>;
58
63
 
59
64
  #### Returns
60
65
 
61
- `Promise`\<`void`\>
66
+ ```ts
67
+ Promise<Partial<RendererOptions>>
68
+ ```
62
69
 
63
70
  #### Overrides
64
71
 
@@ -69,9 +76,11 @@ open(options?): Promise<void>;
69
76
  ### update()
70
77
 
71
78
  ```ts
72
- update(options): Promise<void>;
79
+ update(options): Promise<Partial<RendererOptions>>;
73
80
  ```
74
81
 
82
+ Update the processor options
83
+
75
84
  #### Parameters
76
85
 
77
86
  | Parameter | Type |
@@ -80,26 +89,110 @@ update(options): Promise<void>;
80
89
 
81
90
  #### Returns
82
91
 
83
- `Promise`\<`void`\>
92
+ ```ts
93
+ Promise<Partial<RendererOptions>>
94
+ ```
84
95
 
85
96
  ***
86
97
 
87
- ### process()
98
+ ### mute()
88
99
 
89
100
  ```ts
90
- process(input, options?): Promise<VideoFrameLike | undefined>;
101
+ mute(muted): void;
91
102
  ```
92
103
 
104
+ Mute/unmute the track in the worker
105
+
93
106
  #### Parameters
94
107
 
95
108
  | Parameter | Type |
96
109
  | ------ | ------ |
97
- | `input` | [`VideoFrameLike`](VideoFrameLike.mdx) |
98
- | `options?` | [`RendererOptions`](RendererOptions.mdx) |
110
+ | `muted` | `boolean` |
99
111
 
100
112
  #### Returns
101
113
 
102
- `Promise`\<[`VideoFrameLike`](VideoFrameLike.mdx) \| `undefined`\>
114
+ `void`
115
+
116
+ ***
117
+
118
+ ### process()
119
+
120
+ #### Call Signature
121
+
122
+ ```ts
123
+ process(input, options?): Promise<MediaStreamTrack>;
124
+ ```
125
+
126
+ Process provided input
127
+
128
+ ##### Parameters
129
+
130
+ | Parameter | Type |
131
+ | ------ | ------ |
132
+ | `input` | `MediaStreamTrack` |
133
+ | `options?` | [`RendererOptions`](RendererOptions.mdx) |
134
+
135
+ ##### Returns
136
+
137
+ `Promise<MediaStreamTrack>`
138
+
139
+ #### Call Signature
140
+
141
+ ```ts
142
+ process(input, options?): Promise<
143
+ | ReadWritableStream<VideoFrame>
144
+ | undefined>;
145
+ ```
146
+
147
+ ##### Parameters
148
+
149
+ | Parameter | Type |
150
+ | ------ | ------ |
151
+ | `input` | [`ReadWritableStream<VideoFrame>`](ReadWritableStream.mdx) |
152
+ | `options?` | [`RendererOptions`](RendererOptions.mdx) |
153
+
154
+ ##### Returns
155
+
156
+ ```ts
157
+ Promise<
158
+ ```
159
+ ```ts
160
+ | ReadWritableStream<VideoFrame>
161
+ ```
162
+ ```ts
163
+ | undefined>
164
+ ```
165
+
166
+ #### Call Signature
167
+
168
+ ```ts
169
+ process(input, options?): Promise<
170
+ | MediaStreamTrack
171
+ | ReadWritableStream<VideoFrame>
172
+ | undefined>;
173
+ ```
174
+
175
+ ##### Parameters
176
+
177
+ | Parameter | Type |
178
+ | ------ | ------ |
179
+ | `input` | \| `MediaStreamTrack` \| [`ReadWritableStream<VideoFrame>`](ReadWritableStream.mdx) |
180
+ | `options?` | [`RendererOptions`](RendererOptions.mdx) |
181
+
182
+ ##### Returns
183
+
184
+ ```ts
185
+ Promise<
186
+ ```
187
+ ```ts
188
+ | MediaStreamTrack
189
+ ```
190
+ ```ts
191
+ | ReadWritableStream<VideoFrame>
192
+ ```
193
+ ```ts
194
+ | undefined>
195
+ ```
103
196
 
104
197
  ***
105
198
 
@@ -109,13 +202,19 @@ process(input, options?): Promise<VideoFrameLike | undefined>;
109
202
  subscribe(event, callback): Unsubscribe;
110
203
  ```
111
204
 
205
+ Subscribe rendering events,
206
+
112
207
  #### Parameters
113
208
 
114
209
  | Parameter | Type |
115
210
  | ------ | ------ |
116
- | `event` | \| `"Error"` \| `"ContextCreationError"` \| `"ContextLost"` \| `"ContextRestored"` \| `"ProcessorRestarted"` \| `"SamplingError"` |
117
- | `callback` | `Callback`\<`void`\> |
211
+ | `event` | `\| "Error" \| "ContextCreationError" \| "ContextLost" \| "ContextRestored" \| "ProcessorRestarted" \| "SamplingError"` |
212
+ | `callback` | `Callback<void>` |
118
213
 
119
214
  #### Returns
120
215
 
121
216
  `Unsubscribe`
217
+
218
+ #### See
219
+
220
+ RenderingEvents
@@ -7,7 +7,6 @@
7
7
  | Property | Type |
8
8
  | ------ | ------ |
9
9
  | <a id="basepath"></a> `basePath?` | `string` |
10
- | <a id="output"></a> `output?` | `OffscreenCanvas` \| `null` |
11
10
  | <a id="processingwidth"></a> `processingWidth?` | `number` |
12
11
  | <a id="processingheight"></a> `processingHeight?` | `number` |
13
12
  | <a id="imagesegmenteroptions"></a> `imageSegmenterOptions?` | [`ImageSegmenterOptions`](ImageSegmenterOptions.mdx) |
@@ -2,7 +2,7 @@
2
2
 
3
3
  | Property | Type |
4
4
  | ------ | ------ |
5
- | <a id="frame"></a> `frame` | `ImageBitmap` \| `VideoFrame` |
5
+ | <a id="frame"></a> `frame` | `ImageBitmap \| VideoFrame` |
6
6
  | <a id="timestamp"></a> `timestamp` | `number` |
7
7
  | <a id="width"></a> `width` | `number` |
8
8
  | <a id="height"></a> `height` | `number` |
@@ -1,9 +1,13 @@
1
1
  ## Properties
2
2
 
3
- | Property | Type | Description |
4
- | ------ | ------ | ------ |
5
- | <a id="process"></a> `process` | (`source`) => `Promise`\<`MediaStream`\> | Process the video and return a MediaStream |
6
- | <a id="destroy"></a> `destroy` | () => `Promise`\<`void`\> | Destroy the segmentation wasm instance |
3
+ | Property | Modifier | Type | Description |
4
+ | ------ | ------ | ------ | ------ |
5
+ | <a id="status"></a> `status` | `readonly` | `\| "closed" \| "closing" \| "Error" \| "destroyed" \| "destroying" \| "idle" \| "new" \| "opened" \| "opening" \| "processing" \| "updated" \| "updating"` | - |
6
+ | <a id="process"></a> `process` | `public` | `(source) => Promise<MediaStreamTrack>` | Process the video and return a MediaStream |
7
+ | <a id="destroy"></a> `destroy` | `public` | `() => Promise<void>` | Destroy the segmentation wasm instance |
8
+ | <a id="renderoptions"></a> `renderOptions` | `readonly` | [`RendererOptions`](RendererOptions.mdx) | Current renderer options |
9
+ | <a id="processingwidth"></a> `processingWidth` | `readonly` | `number` | Current processing width |
10
+ | <a id="processingheight"></a> `processingHeight` | `readonly` | `number` | Current processing height |
7
11
 
8
12
  ## Methods
9
13
 
@@ -13,26 +17,66 @@
13
17
  open(options?): Promise<void>;
14
18
  ```
15
19
 
20
+ Initialize the video processor and related
21
+
22
+ #### Parameters
23
+
24
+ | Parameter | Type |
25
+ | ------ | ------ |
26
+ | `options?` | [`ProcessorUpdateOptions`](ProcessorUpdateOptions.mdx) |
27
+
28
+ #### Returns
29
+
30
+ `Promise<void>`
31
+
32
+ ***
33
+
34
+ ### update()
35
+
36
+ ```ts
37
+ update(options): Promise<void>;
38
+ ```
39
+
40
+ Update the video processor with provided options
41
+
16
42
  #### Parameters
17
43
 
18
44
  | Parameter | Type |
19
45
  | ------ | ------ |
20
- | `options?` | [`ProcessorOptions`](ProcessorOptions.mdx) |
46
+ | `options` | [`ProcessorUpdateOptions`](ProcessorUpdateOptions.mdx) |
21
47
 
22
48
  #### Returns
23
49
 
24
- `Promise`\<`void`\>
50
+ `Promise<void>`
51
+
52
+ ***
53
+
54
+ ### mute()
55
+
56
+ ```ts
57
+ mute(muted): void;
58
+ ```
59
+
60
+ #### Parameters
61
+
62
+ | Parameter | Type |
63
+ | ------ | ------ |
64
+ | `muted` | `boolean` |
65
+
66
+ #### Returns
67
+
68
+ `void`
25
69
 
26
70
  ***
27
71
 
28
72
  ### close()
29
73
 
30
74
  ```ts
31
- close(): void;
75
+ close(): Promise<void>;
32
76
  ```
33
77
 
34
78
  Stop the process of video segmentation
35
79
 
36
80
  #### Returns
37
81
 
38
- `void`
82
+ `Promise<void>`
@@ -12,5 +12,5 @@
12
12
 
13
13
  | Property | Type |
14
14
  | ------ | ------ |
15
- | <a id="messagehandler"></a> `messageHandler` | (`message`) => `void` |
16
- | <a id="errorhandler"></a> `errorHandler?` | (`event`) => `void` |
15
+ | <a id="messagehandler"></a> `messageHandler` | `(message) => void` |
16
+ | <a id="errorhandler"></a> `errorHandler?` | `(event) => void` |
@@ -4,4 +4,4 @@ type AsyncCallback = () => Promise<void>;
4
4
 
5
5
  ## Returns
6
6
 
7
- `Promise`\<`void`\>
7
+ `Promise<void>`
@@ -7,13 +7,13 @@ type Callback<R, T> = (...params) => R;
7
7
  | Type Parameter |
8
8
  | ------ |
9
9
  | `R` |
10
- | `T` *extends* `unknown`[] |
10
+ | `T extends unknown[]` |
11
11
 
12
12
  ## Parameters
13
13
 
14
14
  | Parameter | Type |
15
15
  | ------ | ------ |
16
- | ...`params` | `T` |
16
+ | `...params` | `T` |
17
17
 
18
18
  ## Returns
19
19
 
@@ -6,4 +6,4 @@ type ExtractMessageEventType<T> = T extends object ? O : never;
6
6
 
7
7
  | Type Parameter |
8
8
  | ------ |
9
- | `T` *extends* `object` |
9
+ | `T extends object` |
@@ -6,5 +6,5 @@ type IncludeMessageEventDataType<E, I> = E extends object ? A extends I ? D : ne
6
6
 
7
7
  | Type Parameter |
8
8
  | ------ |
9
- | `E` *extends* `object` |
9
+ | `E extends object` |
10
10
  | `I` |
@@ -0,0 +1,12 @@
1
+ ```ts
2
+ type Logger = object;
3
+ ```
4
+
5
+ ## Properties
6
+
7
+ | Property | Type |
8
+ | ------ | ------ |
9
+ | <a id="debug"></a> `debug` | `LogMethod` |
10
+ | <a id="info"></a> `info` | `LogMethod` |
11
+ | <a id="warn"></a> `warn` | `LogMethod` |
12
+ | <a id="error"></a> `error` | `LogMethod` |
@@ -7,4 +7,4 @@ type OptionalKeys<T, K> = Omit<T, K> & Partial<Pick<T, K>>;
7
7
  | Type Parameter |
8
8
  | ------ |
9
9
  | `T` |
10
- | `K` *extends* keyof `T` |
10
+ | `K extends keyof T` |
@@ -4,6 +4,7 @@ type ProcessEvents<T, I> =
4
4
  | ProcessEventProcess<I>
5
5
  | ProcessEventUpdate<T>
6
6
  | ProcessEventClose
7
+ | ProcessEventMute
7
8
  | ProcessEventDestroy;
8
9
  ```
9
10
 
@@ -1,3 +1,5 @@
1
1
  ```ts
2
- type ProcessInputType = VideoFrame | ImageData | OffscreenCanvas | ImageBitmap;
2
+ type ProcessInputType =
3
+ | MediaStreamTrack
4
+ | ReadWritableStream<VideoFrame>;
3
5
  ```
@@ -1,10 +1,12 @@
1
1
  ```ts
2
- type ProcessWorkerEvents<T, E, D> =
2
+ type ProcessWorkerEvents<T, E, D, U> =
3
3
  | ProcessWorkerEventProcessed<T>
4
- | ProcessWorkerEventOpened
5
- | ProcessWorkerEventUpdated
4
+ | ProcessWorkerEventOpened<U>
5
+ | ProcessWorkerEventUpdated<U>
6
+ | ProcessWorkerEventClosed
6
7
  | ProcessWorkerEvent<E>
7
- | ProcessWorkerEventDebug<D>;
8
+ | ProcessWorkerEventDebug<D>
9
+ | ProcessWorkerEventStats;
8
10
  ```
9
11
 
10
12
  Message events returned from the processor
@@ -16,3 +18,4 @@ Message events returned from the processor
16
18
  | `T` |
17
19
  | `E` |
18
20
  | `D` |
21
+ | `U` |
@@ -1,3 +1,3 @@
1
1
  ```ts
2
- type ProcessorWorkerEvents = ProcessWorkerEvents<VideoFrameLike, ProcessorEvent, ProcessWorkerDebugMessage>;
2
+ type ProcessorWorkerEvents = ProcessWorkerEvents<MediaStreamTrack, ProcessorEvent, ProcessWorkerDebugMessage, Partial<RendererOptions>>;
3
3
  ```
@@ -6,16 +6,16 @@ type RunnerCreator<P, R> = (callback, frameRate) => Runner<P>;
6
6
 
7
7
  | Type Parameter |
8
8
  | ------ |
9
- | `P` *extends* `unknown`[] |
9
+ | `P extends unknown[]` |
10
10
  | `R` |
11
11
 
12
12
  ## Parameters
13
13
 
14
14
  | Parameter | Type |
15
15
  | ------ | ------ |
16
- | `callback` | [`Callback`](Callback.mdx)\<`R`, `P`\> |
16
+ | `callback` | [`Callback<R, P>`](Callback.mdx) |
17
17
  | `frameRate` | `number` |
18
18
 
19
19
  ## Returns
20
20
 
21
- [`Runner`](../interfaces/Runner.mdx)\<`P`\>
21
+ [`Runner<P>`](../interfaces/Runner.mdx)
@@ -0,0 +1,9 @@
1
+ ```ts
2
+ type Struct<Type> = { [Key in keyof Type]: "number" | "boolean" | "string" | "object" };
3
+ ```
4
+
5
+ ## Type Parameters
6
+
7
+ | Type Parameter |
8
+ | ------ |
9
+ | `Type` |
@@ -9,4 +9,4 @@ From https://github.com/Microsoft/TypeScript/issues/26223#issuecomment-674500430
9
9
  | Type Parameter |
10
10
  | ------ |
11
11
  | `T` |
12
- | `N` *extends* `number` |
12
+ | `N extends number` |
@@ -1,3 +1,3 @@
1
1
  ```ts
2
- const FRAME_RATE: 20 = 20;
2
+ const FRAME_RATE: 30 = 30;
3
3
  ```
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const ImageFetchError: "ImageFetchError" = "ImageFetchError";
3
+ ```
@@ -0,0 +1,5 @@
1
+ ```ts
2
+ const MediaStreamTrackTransferable: boolean;
3
+ ```
4
+
5
+ Result of the feature detection if `MediaStreamTrack` is `Transferable`
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const RENDERER_OPTIONS_STRUCT: Struct<RendererOptions>;
3
+ ```
@@ -0,0 +1,21 @@
1
+ ```ts
2
+ const cloneImageRecord: (image) => Promise<{
3
+ image: ImageBitmap;
4
+ key: string;
5
+ }>;
6
+ ```
7
+
8
+ ## Parameters
9
+
10
+ | Parameter | Type |
11
+ | ------ | ------ |
12
+ | `image` | [`ImageRecord`](../interfaces/ImageRecord.mdx) |
13
+
14
+ ## Returns
15
+
16
+ ```ts
17
+ Promise<{
18
+ ```
19
+ `image`: `ImageBitmap`;
20
+ `key`: `string`;
21
+ \}\>
@@ -0,0 +1,18 @@
1
+ ```ts
2
+ const compareImageRecords: (a, b) => boolean;
3
+ ```
4
+
5
+ Compare provided ImageRecord
6
+
7
+ ## Parameters
8
+
9
+ | Parameter | Type |
10
+ | ------ | ------ |
11
+ | `a` | [`ImageRecord`](../interfaces/ImageRecord.mdx) |
12
+ | `b` | [`ImageRecord`](../interfaces/ImageRecord.mdx) \| `undefined` |
13
+
14
+ ## Returns
15
+
16
+ `boolean`
17
+
18
+ true if the two records have the same key and image, false otherwise
@@ -6,7 +6,7 @@ const createLazyProps: <T>(stateBuilder) => T;
6
6
 
7
7
  | Type Parameter |
8
8
  | ------ |
9
- | `T` *extends* `Record`\<`string`, `unknown`\> |
9
+ | `T extends Record<string, unknown>` |
10
10
 
11
11
  ## Parameters
12
12
 
@@ -6,7 +6,7 @@ const createObjectUpdater: <T>(original) => (another) => void;
6
6
 
7
7
  | Type Parameter |
8
8
  | ------ |
9
- | `T` *extends* `{ [K in keyof T]: unknown }` |
9
+ | `T extends { [K in keyof T]: unknown }` |
10
10
 
11
11
  ## Parameters
12
12
 
@@ -24,7 +24,7 @@ const createObjectUpdater: <T>(original) => (another) => void;
24
24
 
25
25
  | Parameter | Type |
26
26
  | ------ | ------ |
27
- | `another` | `Partial`\<`T`\> |
27
+ | `another` | `Partial<T>` |
28
28
 
29
29
  ### Returns
30
30
 
@@ -14,8 +14,8 @@ const createRemoteImageBitmap: (map?) => object;
14
14
 
15
15
  | Name | Type |
16
16
  | ------ | ------ |
17
- | `tryFetchingImage()` | (`uri`) => `Promise`\<`ImageBitmap` \| `null`\> |
18
- | `setImage()` | (`uri`, `image`) => `void` |
19
- | `getImage()` | (`uri`) => `ImageBitmap` \| `null` |
20
- | `removeImage()` | (`uri`) => `boolean` |
21
- | `clear()` | () => `void` |
17
+ | `tryFetchingImage()` | `(uri, abortSignal) => Promise<ImageBitmap` | null | undefined\>` |
18
+ | `setImage()` | `(uri, image) => void` |
19
+ | `getImage()` | `(uri) => ImageBitmap \| null` |
20
+ | `removeImage()` | `(uri) => boolean` |
21
+ | `clear()` | `() => void` |