@tradalab/mediakit 1.3.0 → 2.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.
- package/README.md +352 -0
- package/dist/{chunk-WRKQ2NFI.js → chunk-TBMYRKXR.js} +98 -3
- package/dist/chunk-TBMYRKXR.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/lut.d.ts +38 -0
- package/dist/lut.js +176 -0
- package/dist/lut.js.map +1 -0
- package/dist/mediakit.wasm +0 -0
- package/dist/recipe.d.ts +47 -1
- package/dist/recipe.js +5 -1
- package/dist/worker.js +3826 -3136
- package/dist/worker.js.map +1 -1
- package/package.json +7 -3
- package/dist/chunk-WRKQ2NFI.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
# @tradalab/mediakit
|
|
2
|
+
|
|
3
|
+
Realtime camera processing in the browser: a camera track goes in, a processed camera track
|
|
4
|
+
comes out. Background replacement and blur, skin smoothing, colour adjustment, autoframing and
|
|
5
|
+
face retouching.
|
|
6
|
+
|
|
7
|
+
The examples named below live in the repository under `web/example/`; `make example` serves them.
|
|
8
|
+
|
|
9
|
+
### Upgrading to 2.0
|
|
10
|
+
|
|
11
|
+
2.0 moves to `@mediapipe/tasks-vision` 1.1.1. Install `@mediapipe/tasks-vision@~1.1.1` and serve
|
|
12
|
+
its `wasm/` files under `/mediakit/mp/`: the worker carries 1.1.1 and its wasm must match. The
|
|
13
|
+
TypeScript API is unchanged.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
pnpm add @tradalab/mediakit @mediapipe/tasks-vision@~1.1.1
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`@mediapipe/tasks-vision` is a peer dependency, `~1.1.1`: your bundler provides it for the main
|
|
22
|
+
thread, and the worker carries its own 1.1.1 copy inside `dist/worker.js`. The wasm you serve
|
|
23
|
+
under `/mediakit/mp/` comes from your install, so it has to be 1.1.x too - the worker's JS and
|
|
24
|
+
the wasm must be the same release.
|
|
25
|
+
|
|
26
|
+
## Serve the assets first
|
|
27
|
+
|
|
28
|
+
Nothing works until these are reachable on **your own origin**, under `/mediakit/`. Nothing is
|
|
29
|
+
ever fetched from a third party while a frame is being processed.
|
|
30
|
+
|
|
31
|
+
| URL | Copy from | Needed when |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| `/mediakit/mediakit.wasm` | this package's `dist/` | always |
|
|
34
|
+
| `/mediakit/wasm_exec.js` | this package's `dist/` | always, and it must stay with that `.wasm` |
|
|
35
|
+
| `/mediakit/worker.js` | this package's `dist/` | to get the worker transport |
|
|
36
|
+
| `/mediakit/mp/` | the files inside `@mediapipe/tasks-vision/wasm/`, flat, from the same 1.1.x release | any recipe where `needsMask()` or `needsFace()` is true |
|
|
37
|
+
| `/mediakit/selfie_segmenter.tflite` | MediaPipe model | `needsMask()` is true |
|
|
38
|
+
| `/mediakit/face_landmarker.task` | MediaPipe model | `needsFace()` is true |
|
|
39
|
+
| `/mediakit/whiten_pink.png` | this package's `dist/` | `whitenStyle: "pink"` |
|
|
40
|
+
| `/mediakit/selfie_multiclass_256x256.tflite` | MediaPipe model, 16 MB | `needsSkinClasses()` is true; without it those recipes fall back to skin measured on the face |
|
|
41
|
+
|
|
42
|
+
`worker.js` is **fetched**, not imported, so no bundler will pick it up for you. The models are
|
|
43
|
+
not shipped in the package; fetch them once and serve them yourself.
|
|
44
|
+
|
|
45
|
+
## Run it
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { VideoPipeline } from "@tradalab/mediakit"
|
|
49
|
+
import { NO_EFFECTS } from "@tradalab/mediakit/recipe"
|
|
50
|
+
|
|
51
|
+
const pipeline = new VideoPipeline({ kind: "blur", blurRadius: 12 }, NO_EFFECTS)
|
|
52
|
+
await pipeline.start(cameraTrack) // a MediaStreamTrack
|
|
53
|
+
videoEl.srcObject = new MediaStream([pipeline.processedTrack!])
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Changing a setting does **not** rebuild the pipeline, so dragging a slider does not flash:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
await pipeline.switchTo({ kind: "image", imagePath: "/backgrounds/office.png" })
|
|
60
|
+
await pipeline.setEffects({ ...NO_EFFECTS, beautify: 0.4, warmth: 0.2 })
|
|
61
|
+
await pipeline.stop()
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Import the vocabulary from `@tradalab/mediakit/recipe`, not from the root, anywhere that does
|
|
65
|
+
not process a frame - a preset list, a settings panel, a storage key. The root pulls in the
|
|
66
|
+
engine, the wasm loader and the MediaPipe bindings; `/recipe` is 1.5 kB and pulls in nothing.
|
|
67
|
+
|
|
68
|
+
## The background
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
type BgFilter =
|
|
72
|
+
| { kind: "none" }
|
|
73
|
+
| { kind: "blur"; blurRadius: number } // 0 < r <= 32; above 32 is clamped, 0 means none
|
|
74
|
+
| { kind: "image"; imagePath: string } // any URL, including a data URL
|
|
75
|
+
| { kind: "cutout" } // transparent background, for a Scene
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`cutout` writes the person's mask into the output's alpha. It only means something to a
|
|
79
|
+
consumer that reads alpha - a `Scene` layer, or an `Engine` created with `alpha: true` - since a
|
|
80
|
+
video track has none.
|
|
81
|
+
|
|
82
|
+
An image of any aspect ratio is safe: it is cover-cropped to the frame once, when you set it,
|
|
83
|
+
not per frame. An SVG works on the main thread but **not** inside the worker - see the limits
|
|
84
|
+
below.
|
|
85
|
+
|
|
86
|
+
## The effects
|
|
87
|
+
|
|
88
|
+
Every field is independent and defaults to off. `NO_EFFECTS` is that default; spread it rather
|
|
89
|
+
than building the object by hand, so a new field cannot arrive as `undefined`.
|
|
90
|
+
|
|
91
|
+
| Field | Range | Does |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| `exposure` | -1 … 1 | Brightness. Positive lifts shadows more than highlights, so a backlit face recovers without blowing out the window behind it. |
|
|
94
|
+
| `contrast` | -1 … 1 | Contrast. |
|
|
95
|
+
| `saturation` | -1 … 1 | Colour intensity. |
|
|
96
|
+
| `warmth` | -1 … 1 | Positive warm, negative cool. |
|
|
97
|
+
| `tint` | -1 … 1 | Positive magenta, negative green: with `warmth`, a white balance. GPUPixel's tint, a shift along YIQ's Q axis, so brightness does not move. |
|
|
98
|
+
| `vibrance` | -1 … 1 | Saturation that moves dull colours more than vivid ones and skin least. Measured at 1: a dull blue +84 %, skin +20 % - where `saturation: 0.5` takes skin +50 % and turns faces orange first. |
|
|
99
|
+
| `grain` | 0 … 1 | Film grain: luminance noise, a new pattern every frame, strongest in the midtones, none at black or white. About 6 levels at 1. Noise is what an encoder spends the most bits on; keep it low on a live stream. |
|
|
100
|
+
| `autoLight` | boolean | Lifts exposure when the room is dark, on top of `exposure`, and only ever brightens. Measures the person when a mask exists, the centre of the frame otherwise. Moves over about a second, so a lamp switching on does not flash the picture. |
|
|
101
|
+
| `mirror` | boolean | Flips the finished picture left to right, as a selfie preview shows it. Only the last pass flips, so face tracking, masks and autoframe still see the camera as it is; free on top of any other effect, one pass on its own. Off by default: a mirrored whiteboard reads backwards to everyone else. |
|
|
102
|
+
| `beautify` | 0 … 1 | Skin smoothing in two bands: uneven colour (redness, marks, patches) evened hard, fine texture (pores) only eased, so skin stays skin; features - eyes, brows, the lip line - keep both, and small dark spots are lifted. The radius follows the face's size when landmarks run. With the multiclass segmenter loaded it keeps to the skin it labels; otherwise to the person's skin-coloured pixels. |
|
|
103
|
+
| `whiten` | 0 … 1 | Brightens the skin as a brighter light would - one gain per patch, from the smoothed skin along a gamma curve, chroma kept, highlights rolled off - and cools only its yellow. Not a fade to white: that greyed dark skin, chalked light skin and flattened the face's form. Loads the **multiclass segmenter** (16 MB), which labels face skin, body skin, hair, clothes and held objects apart: the face, neck, chest, arms and hands are whitened, clothes and a product in the hand are not, whatever their colour. Until that model is up - or if it never loads - it falls back to the faces and the throats below them, measured against this person's skin colour sampled off their face. Needs landmarks too. Eyes, brows and teeth are left alone. |
|
|
104
|
+
| `whitenStyle` | `"natural"`, `"pink"` | `pink` is the "fair and rosy" look of East Asian beauty apps: GPUPixel's tuned skin tables (Apache-2.0, `dist/NOTICE`), served as `/mediakit/whiten_pink.png` and loaded the first time it is asked for. It takes over on light and medium skin and hands back to `natural` on dark skin, by the skin measured on each face - those tables were not tuned for it and came out mottled. |
|
|
105
|
+
| `skinLight` | 0 … 1 | The same relighting without the cooling: brightness on that same skin, its colour and shading kept. `exposure` stays whole-frame. |
|
|
106
|
+
| `clarity` | 0 … 1 | Local contrast on the faces: the detail `beautify` separates out, added on top. Its own knob - `beautify` gives back only what it took. Needs landmarks; kept off the cut-out edge, where it would draw a rim. Dropped with `beautify` when the governor is short of time. |
|
|
107
|
+
| `skinScope` | `"person"`, `"face"` | Where smoothing (and the two above, already held to the face) may land. `person`, the default, is skin anywhere on the person, hands included; `face` keeps smoothing to faces and necks, so a hand holding a product - or a lipstick swatch on the back of it - is left alone. With no face found, `face` lands nowhere. |
|
|
108
|
+
| `autoframe` | boolean | Keeps the person framed, with headroom. Moves by time, not by frame, so it looks the same at 24fps and 60fps. |
|
|
109
|
+
| `teeth` | 0 … 1 | Whitens teeth. |
|
|
110
|
+
| `eyeBright` | 0 … 1 | Brightens the whites of the eyes and adds clarity to the iris. |
|
|
111
|
+
| `underEye` | 0 … 1 | Reduces under-eye shadow, keeping the skin's own tone. |
|
|
112
|
+
| `smileLines` | 0 … 1 | Softens the nasolabial folds by filling the crease from the skin either side of it. |
|
|
113
|
+
| `lips`, `lipColor` | 0 … 1, `[r, g, b]` | Lip tint, drawn against the lip contour itself; the teeth and the inside of the mouth stay untouched. The lip's mean brightness maps to the colour's own, so a dark shade stays dark while the lip's texture and highlights show through. |
|
|
114
|
+
| `blush`, `blushColor` | 0 … 1, `[r, g, b]` | A wide, faint flush on the apples of the cheeks, held inside the face outline. |
|
|
115
|
+
| `rosy`, `rosyColor` | 0 … 1, `[r, g, b]` | A flush over the skin of the whole face, capped at 0.3 opacity. Fills the face outline, so it needs landmarks but not the mesh. |
|
|
116
|
+
| `eyeShadow`, `eyeShadowColor` | 0 … 1, `[r, g, b]` | Multiplied into the lower part of the lid-to-brow band, deepest at the outer corner and fading up. |
|
|
117
|
+
| `lipGloss` | 0 … 1 | A white highlight across the middle of the lower lip, a quarter of its width. Matte is 0; works with `lips` at 0 too. |
|
|
118
|
+
| `iris`, `irisColor` | 0 … 1, `[r, g, b]` | Iris colour: the ring only, clipped by the eyelids, pupil and catchlights left alone. |
|
|
119
|
+
| `lut`, `grade` | URL, 0 … 1 | A colour LUT and its strength, applied last. See below. |
|
|
120
|
+
| `gradeScope` | `"frame"`, `"person"`, `"skin"` | Where the LUT lands. `person` keeps it off the background and - with the multiclass segmenter, which this loads - off a product held up, which it labels apart from the person; clothes worn are the person, and take it. `skin` is the skin the segmenter labels, falling back to faces and throats as for `whiten`. Anything but `frame` needs the person mask. |
|
|
121
|
+
| `chromaKey` | boolean | Takes the person mask from a green or blue screen instead of segmentation: MediaPipe is never loaded, and hair and edges come out cleaner. Removes the screen's colour cast from the person too. Pair it with a `blur` or `image` background. |
|
|
122
|
+
| `keyColor`, `keyTolerance` | `[r, g, b]`, -1 … 1 | The screen's colour - `[0, 0, 0]`, the default, finds it from the frame's border and follows it as the camera's white balance drifts. `keyTolerance` widens (+) or narrows (-) what counts as screen. |
|
|
123
|
+
| `slimFace` | 0 … 1 | Narrows the jawline. Capped internally at a subtle maximum. |
|
|
124
|
+
| `enlargeEyes` | 0 … 1 | Enlarges the eyes. Same cap. |
|
|
125
|
+
| `noseSlim` | 0 … 1 | Narrows the nose, mostly at the wings. Same cap. |
|
|
126
|
+
| `chin` | -1 … 1 | Shortens or lengthens the chin; the mouth stays where it is. Same cap. |
|
|
127
|
+
| `jaw`, `cheekbone` | 0 … 1 | Narrow the lower jaw towards a V-line, or the cheekbones. Unlike the reshaping above, which pushes an ellipse, these move the face's own outline - its 36 contour landmarks - so the jaw that narrows is this person's. Capped; reads the landmark mesh. |
|
|
128
|
+
| `forehead` | -1 … 1 | A smaller (-) or fuller (+) forehead, by the same contour. |
|
|
129
|
+
| `brow`, `browColor` | 0 … 1, `[r, g, b]` | Fills and darkens the brows, multiplied in so the hairs show; lighter at the inner end. |
|
|
130
|
+
| `contour` | 0 … 1 | Shades under the cheekbones, along the jaw and beside the nose. |
|
|
131
|
+
| `highlight` | 0 … 1 | Lifts the nose bridge, cheekbone tops, mid forehead and chin. |
|
|
132
|
+
|
|
133
|
+
Values outside the range are clamped, not rejected. Every face region follows head tilt, and up
|
|
134
|
+
to three faces are tracked and retouched at once, each with its own smoothing. The smoothing lets
|
|
135
|
+
go as a face moves, and between detections - which run every second frame or less - the regions
|
|
136
|
+
are carried along the face's velocity, so makeup keeps up with a turning head (measured: 22 px
|
|
137
|
+
behind on a moving head before, under 4 after). Recipes that stretch gradients - whitening, skin
|
|
138
|
+
light, clarity, a scoped grade - dither by half a level, so no banding shows. A face that has
|
|
139
|
+
just appeared takes reshaping and face colour at a growing share of their strength, reaching all
|
|
140
|
+
of it after 0.3 s; one that leaves loses them at once, since fading over a frame with no face in
|
|
141
|
+
it reads as a rendering fault.
|
|
142
|
+
|
|
143
|
+
### Colour LUTs
|
|
144
|
+
|
|
145
|
+
`lut` is a URL your app serves, decoded once when it changes - not per frame. The layout is the
|
|
146
|
+
common 512x512 "lookup" PNG: 64 levels per channel, the blue axis laid out as 8x8 tiles of red
|
|
147
|
+
(across) by green (down), row 0 at the top. Most grading tools export it; an identity one is a
|
|
148
|
+
plain gradient, so you can also generate your own. Run the identity one at `grade: 1` first: the
|
|
149
|
+
picture must not change, and if it does, the file is laid out differently.
|
|
150
|
+
|
|
151
|
+
`@tradalab/mediakit/lut` bakes one without an image file, and without pulling the engine in:
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import { chain, curve, levels, lutDataUrl, parseCube, vibrance, whiteBalance } from "@tradalab/mediakit/lut"
|
|
155
|
+
|
|
156
|
+
const film = lutDataUrl(chain(whiteBalance(0.15, -0.05), curve([[0, 0], [0.5, 0.48], [1, 1]]), levels(0, 1, 1, 0.08, 1)))
|
|
157
|
+
const designer = lutDataUrl(parseCube(await (await fetch("/looks/warm.cube")).text()))
|
|
158
|
+
await pipeline.setEffects({ ...NO_EFFECTS, lut: film, grade: 0.6, gradeScope: "person" })
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
- `parseCube` reads a `.cube` file (3D, any size, trilinear; or 1D per channel).
|
|
162
|
+
- `curve` is a curves panel: monotone cubic through the points, all channels or one.
|
|
163
|
+
- `levels` sets input black/white, gamma, output black/white.
|
|
164
|
+
- `whiteBalance` and `vibrance` do what `warmth`/`tint` and `vibrance` do live.
|
|
165
|
+
- `lutPixels` gives the raw RGBA when there is no DOM to bake on.
|
|
166
|
+
|
|
167
|
+
`lutDataUrl` runs the function 262 144 times; cache the result. Grain cannot live in a LUT: it is
|
|
168
|
+
noise in time, so a film look sets `grain` beside it.
|
|
169
|
+
|
|
170
|
+
### Storing a recipe
|
|
171
|
+
|
|
172
|
+
`EFFECTS_SCHEMA` gives every field's kind and range (`amount` 0..1, `signed` -1..1, `color`,
|
|
173
|
+
`choice` with its values, `bool`, `url`), the same ranges the core clamps to. `normalizeEffects`
|
|
174
|
+
turns anything - a stored recipe, one from an older build, a server's - into a valid `Effects`:
|
|
175
|
+
out-of-range numbers clamped, missing or malformed fields set to `NO_EFFECTS`, unknown ones dropped.
|
|
176
|
+
Both are in `@tradalab/mediakit/recipe`.
|
|
177
|
+
|
|
178
|
+
### One knob instead of five
|
|
179
|
+
|
|
180
|
+
`touchUp(amount)` sets `beautify`, `eyeBright`, `underEye`, `smileLines` and `teeth` together,
|
|
181
|
+
in proportions tuned to read as rested rather than filtered at 1. Spread it into the effects;
|
|
182
|
+
`touchUpAmount(effects)` reads a stored recipe back into the knob's position.
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
import { NO_EFFECTS, touchUp } from "@tradalab/mediakit/recipe"
|
|
186
|
+
const effects = { ...NO_EFFECTS, ...touchUp(0.5) }
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
`web/example/beauty.html` (`make example`, then `/example/beauty.html`) puts every effect behind a
|
|
190
|
+
phone-style beauty panel: tabs, one slider for the selected item, colour swatches for makeup,
|
|
191
|
+
filter thumbnails made from your own camera, and hold-to-compare. It is the shape to copy for a
|
|
192
|
+
selfie or short-video app.
|
|
193
|
+
|
|
194
|
+
`web/example/bench.html` measures the beauty filter on this machine's GPU: quality on seven
|
|
195
|
+
portraits (how much skin whitening reaches, how much leaks onto clothes and products, texture and
|
|
196
|
+
blotchiness left after smoothing), makeup lag on a swaying head, and frame cost per recipe with the
|
|
197
|
+
real governor. `make example` fetches the portraits; their licences are listed on the page.
|
|
198
|
+
|
|
199
|
+
`web/example/studio.html` is the beauty panel of a livestream studio - four levels, eight
|
|
200
|
+
makeup sets, seven tones and a "keep product colour" switch - built for CALIBRATION: its source
|
|
201
|
+
can be a still image (upload one, or `?img=<url>`) so numbers change against a fixed picture, and
|
|
202
|
+
it exports the frame as PNG with the recipe that made it. Every number on it is that product's,
|
|
203
|
+
not the package's.
|
|
204
|
+
|
|
205
|
+
### What each one costs
|
|
206
|
+
|
|
207
|
+
The two detectors are separate downloads and separate per-frame costs, and each loads only
|
|
208
|
+
when a recipe first needs it:
|
|
209
|
+
|
|
210
|
+
| | Pulled in by | Cost |
|
|
211
|
+
|---|---|---|
|
|
212
|
+
| **person mask** | any background other than `none`, `beautify`, `whiten`, `skinLight`, `clarity`, `autoframe`, a `gradeScope` other than `frame` | MediaPipe runtime plus a 244 kB model |
|
|
213
|
+
| **face landmarks** | `teeth`, `eyeBright`, `underEye`, `smileLines`, `lips`, `blush`, `iris`, `rosy`, `eyeShadow`, `lipGloss`, `brow`, `contour`, `highlight`, `whiten`, `skinLight`, `clarity`, `gradeScope: "skin"`, `slimFace`, `enlargeEyes`, `noseSlim`, `chin`, `jaw`, `cheekbone`, `forehead`, and `skinScope: "face"` with `beautify` | a 3.7 MB model, fifteen times the other |
|
|
214
|
+
| **skin classes** | `whiten`, `skinLight`, a `gradeScope` other than `frame` (`needsSkinClasses()`) | a second, multiclass segmenter: 16 MB, float32 only. Loaded beside the person one; until it is up those recipes fall back as described above |
|
|
215
|
+
|
|
216
|
+
`autoLight` needs neither: it reads the frame's brightness from a 32x18 grid. `chromaKey` turns
|
|
217
|
+
the person mask's cost into one shader pass - `needsSegmentation()` says whether MediaPipe has to
|
|
218
|
+
be loaded at all.
|
|
219
|
+
|
|
220
|
+
A colour-only recipe needs neither, and then the pipeline skips MediaPipe entirely. Ask before
|
|
221
|
+
you commit to a recipe:
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
import { needsMask, needsFace } from "@tradalab/mediakit/recipe"
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
A user who turns nothing on downloads **nothing** - the wasm core itself is only fetched on the
|
|
228
|
+
first active recipe.
|
|
229
|
+
|
|
230
|
+
## Reading what it is doing
|
|
231
|
+
|
|
232
|
+
`pipeline.stats` returns the last frame's numbers, or `null` before the first one. Poll it a
|
|
233
|
+
few times a second; reading it per frame costs more than it tells you.
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
const s = pipeline.stats
|
|
237
|
+
// s.totalMs, s.segMs, s.glCalls, s.segmented, s.maskScale, s.workScale,
|
|
238
|
+
// s.cropCX, s.cropCY, s.cropZoom, s.needsMask, s.faceFound, s.faceSize, s.needsFace
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
`pipeline.transportName` says which of the three paths is running: `worker`, `insertable` or
|
|
242
|
+
`canvas`. It is chosen automatically and falls back on its own, so treat it as a diagnostic,
|
|
243
|
+
not a setting.
|
|
244
|
+
|
|
245
|
+
## Health, fallback and several consumers
|
|
246
|
+
|
|
247
|
+
```ts
|
|
248
|
+
const pipeline = new VideoPipeline(filter, effects, {
|
|
249
|
+
alpha: true, // keep alpha for subscribeFrames + cutout
|
|
250
|
+
onStall: ({ transport, sinceMs }) => report(transport, sinceMs),
|
|
251
|
+
onTrackReplaced: (track) => sender.replaceTrack(track),
|
|
252
|
+
})
|
|
253
|
+
const stop = pipeline.subscribeFrames((frame) => { draw(frame); frame.close() })
|
|
254
|
+
pipeline.health // { transport, frames, sinceMs, stalled }
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
- No frame for two seconds fires `onStall` (a machine too slow for the recipe, or a hang). A worker
|
|
258
|
+
that fails, or stays silent for eight seconds, AFTER the host published its track is taken for
|
|
259
|
+
dead and the work moves to the main thread on its own; `onTrackReplaced` hands the host the new
|
|
260
|
+
track. A detector loading - seconds for the 16 MB model - counts as neither.
|
|
261
|
+
- `subscribeFrames` gives every processed frame, alpha kept when asked, one clone per subscriber
|
|
262
|
+
- one processing for a host that composites the camera into several outputs.
|
|
263
|
+
- On Safari the worker path takes a clone of the camera track into the worker (untested on Safari
|
|
264
|
+
so far); anything that fails falls back to the canvas transport.
|
|
265
|
+
|
|
266
|
+
## Lower level
|
|
267
|
+
|
|
268
|
+
`Engine` takes one frame and draws one canvas, for a host that already owns its frame loop:
|
|
269
|
+
|
|
270
|
+
```ts
|
|
271
|
+
import { Engine } from "@tradalab/mediakit"
|
|
272
|
+
|
|
273
|
+
const engine = await Engine.on(canvas, filter, effects)
|
|
274
|
+
const drew = engine.render(videoOrFrame, timestampMicros)
|
|
275
|
+
if (drew) out.enqueue(engine.capture(timestampMicros))
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
`render` returning `false` means nothing was drawn - no mask yet, or the recipe is inactive.
|
|
279
|
+
Forward the source frame when that happens; dropping it freezes the picture.
|
|
280
|
+
|
|
281
|
+
## Scenes: layering sources
|
|
282
|
+
|
|
283
|
+
`Scene` puts several sources on one output, the way OBS does: cameras (each with its own recipe),
|
|
284
|
+
screen shares, video files, images, text and any canvas, placed, shaped and blended as layers,
|
|
285
|
+
with animated edits and transitions between layouts.
|
|
286
|
+
|
|
287
|
+
```ts
|
|
288
|
+
import { Scene, layouts } from "@tradalab/mediakit"
|
|
289
|
+
|
|
290
|
+
const scene = await Scene.create({ width: 1280, height: 720, background: "#0b1220" })
|
|
291
|
+
await scene.addSource("cam", { kind: "camera", track: camTrack, filter: { kind: "cutout" } })
|
|
292
|
+
await scene.addSource("screen", { kind: "track", track: screenTrack })
|
|
293
|
+
await scene.addSource("name", { kind: "text", text: "Nguyen Van A", style: { background: "#000a", padding: 20 } })
|
|
294
|
+
|
|
295
|
+
const p = layouts.presenter("right")
|
|
296
|
+
scene.setLayers([
|
|
297
|
+
{ id: 1, source: "screen", ...p.content, fit: "contain", shape: "rounded", radius: 0.03 },
|
|
298
|
+
{ id: 2, source: "cam", ...p.person, fit: "contain" },
|
|
299
|
+
{ id: 3, source: "name", ...layouts.lowerThird(), fit: "contain" },
|
|
300
|
+
])
|
|
301
|
+
scene.start()
|
|
302
|
+
const track = scene.captureStream().getVideoTracks()[0]
|
|
303
|
+
|
|
304
|
+
// Later: glide a layer somewhere else, or change the whole layout through a transition.
|
|
305
|
+
scene.setLayers(next, { animate: 300 })
|
|
306
|
+
scene.switchTo(other, { kind: "iris", duration: 600 })
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
A layer is a rect in fractions of the output, origin top left, plus any of:
|
|
310
|
+
|
|
311
|
+
| Field | Values |
|
|
312
|
+
|---|---|
|
|
313
|
+
| `source` / `color` / `color2` | a source id; or a fill colour; or a gradient from `color` to `color2` along `gradientAngle` |
|
|
314
|
+
| `fit` | `cover` (default), `contain` (the rect shrinks to the picture), `stretch` |
|
|
315
|
+
| `crop`, `flipX`, `flipY`, `rotation` | fractions of the source; mirror; degrees clockwise |
|
|
316
|
+
| `opacity`, `hidden` | 0..1 (default 1) |
|
|
317
|
+
| `shape`, `radius` | `rect`, `rounded` (radius as a share of the shorter side), `ellipse` |
|
|
318
|
+
| `border`, `shadow` | width and colour; softness, offset and opacity, all in output heights |
|
|
319
|
+
| `blend` | `normal`, `add`, `screen`, `multiply`, `overlay`, `darken`, `lighten` |
|
|
320
|
+
| `tone` | `exposure`, `contrast`, `saturation`, `warmth`, -1..1, as in the camera recipe (not `tint`, `vibrance` or `grain`) |
|
|
321
|
+
| `key` | remove a colour from the source, e.g. a green-screen clip |
|
|
322
|
+
|
|
323
|
+
Layers draw in array order, first at the bottom; at most 16, and 8 sources. Each layer costs one
|
|
324
|
+
full-frame pass. `id` is what an animation follows: with `animate`, a layer with the same id
|
|
325
|
+
glides from where it is, a new id fades in, a dropped one fades out.
|
|
326
|
+
|
|
327
|
+
Transitions: `cut`, `fade`, `fadeThrough`, `slideLeft`/`Right`/`Up`/`Down`, `pushLeft`/`Right`,
|
|
328
|
+
`wipeLeft`/`Right`, `iris`, `zoom`. During one, both layouts are drawn, so it costs every layer
|
|
329
|
+
twice for its duration.
|
|
330
|
+
|
|
331
|
+
Also: `layerAt(x, y)` for picking and dragging, `updateSource` (new text, a new camera recipe),
|
|
332
|
+
`snapshot()` to PNG, `startRecording()`/`stopRecording()` to WebM. `layouts` has `full`, `pip`,
|
|
333
|
+
`columns`, `grid`, `lowerThird` and `presenter`; the layout vocabulary is also its own entry,
|
|
334
|
+
`@tradalab/mediakit/layout`, so a layout picker does not pull the wasm loader in.
|
|
335
|
+
|
|
336
|
+
`web/example/scene.html` (`make example`, then `/example/scene.html`) is a working editor.
|
|
337
|
+
|
|
338
|
+
## Limits worth knowing before you design around them
|
|
339
|
+
|
|
340
|
+
- **A Scene runs on the main thread**, and its loop is a timer: a hidden tab slows it to the
|
|
341
|
+
browser's background timer rate.
|
|
342
|
+
- **Every processed camera in a Scene is its own WebGL context.** Browsers keep 8-16 alive and
|
|
343
|
+
reclaim the oldest past that, so keep processed cameras to a handful. A camera with no filter
|
|
344
|
+
and no effects uses none.
|
|
345
|
+
|
|
346
|
+
- **SVG backgrounds fall back to the main thread.** There is no `Image` in a worker, so the
|
|
347
|
+
pipeline switches transport for those recipes. The picture is correct, the worker benefit is
|
|
348
|
+
not. Raster backgrounds keep the worker.
|
|
349
|
+
- **Safari hands the camera track to the worker**, because it exposes the breakout-box APIs only
|
|
350
|
+
there; where that fails it runs on the `canvas` transport.
|
|
351
|
+
- **`crossOrigin` is set on background images.** A cross-origin background without CORS headers
|
|
352
|
+
fails to load rather than silently tainting the canvas.
|
|
@@ -5,6 +5,9 @@ var NO_EFFECTS = {
|
|
|
5
5
|
contrast: 0,
|
|
6
6
|
saturation: 0,
|
|
7
7
|
warmth: 0,
|
|
8
|
+
tint: 0,
|
|
9
|
+
vibrance: 0,
|
|
10
|
+
grain: 0,
|
|
8
11
|
autoframe: false,
|
|
9
12
|
teeth: 0,
|
|
10
13
|
eyeBright: 0,
|
|
@@ -49,8 +52,95 @@ var NO_EFFECTS = {
|
|
|
49
52
|
makeupBlend: "softLight",
|
|
50
53
|
whitenStyle: "natural"
|
|
51
54
|
};
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
var amount = { kind: "amount" };
|
|
56
|
+
var signed = { kind: "signed" };
|
|
57
|
+
var bool = { kind: "bool" };
|
|
58
|
+
var color = { kind: "color" };
|
|
59
|
+
var url = { kind: "url" };
|
|
60
|
+
var EFFECTS_SCHEMA = {
|
|
61
|
+
beautify: amount,
|
|
62
|
+
exposure: signed,
|
|
63
|
+
contrast: signed,
|
|
64
|
+
saturation: signed,
|
|
65
|
+
warmth: signed,
|
|
66
|
+
tint: signed,
|
|
67
|
+
vibrance: signed,
|
|
68
|
+
grain: amount,
|
|
69
|
+
autoframe: bool,
|
|
70
|
+
teeth: amount,
|
|
71
|
+
eyeBright: amount,
|
|
72
|
+
underEye: amount,
|
|
73
|
+
smileLines: amount,
|
|
74
|
+
lips: amount,
|
|
75
|
+
lipColor: color,
|
|
76
|
+
blush: amount,
|
|
77
|
+
blushColor: color,
|
|
78
|
+
iris: amount,
|
|
79
|
+
irisColor: color,
|
|
80
|
+
eyeShadow: amount,
|
|
81
|
+
eyeShadowColor: color,
|
|
82
|
+
lipGloss: amount,
|
|
83
|
+
rosy: amount,
|
|
84
|
+
rosyColor: color,
|
|
85
|
+
whiten: amount,
|
|
86
|
+
whitenStyle: { kind: "choice", values: ["natural", "pink"] },
|
|
87
|
+
skinLight: amount,
|
|
88
|
+
clarity: amount,
|
|
89
|
+
skinScope: { kind: "choice", values: ["person", "face"] },
|
|
90
|
+
lut: url,
|
|
91
|
+
grade: amount,
|
|
92
|
+
gradeScope: { kind: "choice", values: ["frame", "person", "skin"] },
|
|
93
|
+
chromaKey: bool,
|
|
94
|
+
keyColor: color,
|
|
95
|
+
keyTolerance: signed,
|
|
96
|
+
autoLight: bool,
|
|
97
|
+
mirror: bool,
|
|
98
|
+
slimFace: amount,
|
|
99
|
+
enlargeEyes: amount,
|
|
100
|
+
noseSlim: amount,
|
|
101
|
+
chin: signed,
|
|
102
|
+
jaw: amount,
|
|
103
|
+
cheekbone: amount,
|
|
104
|
+
forehead: signed,
|
|
105
|
+
brow: amount,
|
|
106
|
+
browColor: color,
|
|
107
|
+
contour: amount,
|
|
108
|
+
highlight: amount,
|
|
109
|
+
makeupTexture: url,
|
|
110
|
+
makeup: amount,
|
|
111
|
+
makeupBlend: { kind: "choice", values: ["softLight", "multiply", "overlay", "hardLight", "normal"] }
|
|
112
|
+
};
|
|
113
|
+
function normalizeEffects(raw) {
|
|
114
|
+
const src = raw && typeof raw === "object" ? raw : {};
|
|
115
|
+
const out = {};
|
|
116
|
+
for (const [key, spec] of Object.entries(EFFECTS_SCHEMA)) {
|
|
117
|
+
const v = src[key];
|
|
118
|
+
const fallback = NO_EFFECTS[key];
|
|
119
|
+
switch (spec.kind) {
|
|
120
|
+
case "amount":
|
|
121
|
+
case "signed": {
|
|
122
|
+
const lo = spec.kind === "amount" ? 0 : -1;
|
|
123
|
+
out[key] = typeof v === "number" && Number.isFinite(v) ? Math.min(1, Math.max(lo, v)) : fallback;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
case "bool":
|
|
127
|
+
out[key] = typeof v === "boolean" ? v : fallback;
|
|
128
|
+
break;
|
|
129
|
+
case "color":
|
|
130
|
+
out[key] = Array.isArray(v) && v.length === 3 && v.every((x) => typeof x === "number" && Number.isFinite(x)) ? v.map((x) => Math.min(1, Math.max(0, x))) : [...fallback];
|
|
131
|
+
break;
|
|
132
|
+
case "choice":
|
|
133
|
+
out[key] = typeof v === "string" && spec.values.includes(v) ? v : fallback;
|
|
134
|
+
break;
|
|
135
|
+
case "url":
|
|
136
|
+
out[key] = typeof v === "string" ? v : fallback;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return out;
|
|
141
|
+
}
|
|
142
|
+
function touchUp(amount2) {
|
|
143
|
+
const a = Math.min(1, Math.max(0, amount2));
|
|
54
144
|
return {
|
|
55
145
|
beautify: a * TOUCH_UP.beautify,
|
|
56
146
|
eyeBright: a * TOUCH_UP.eyeBright,
|
|
@@ -117,6 +207,9 @@ function coreRecipe(f, e) {
|
|
|
117
207
|
contrast: e.contrast,
|
|
118
208
|
saturation: e.saturation,
|
|
119
209
|
warmth: e.warmth,
|
|
210
|
+
tint: e.tint ?? 0,
|
|
211
|
+
vibrance: e.vibrance ?? 0,
|
|
212
|
+
grain: e.grain ?? 0,
|
|
120
213
|
autoframe: e.autoframe,
|
|
121
214
|
teeth: e.teeth,
|
|
122
215
|
eyeBright: e.eyeBright,
|
|
@@ -163,6 +256,8 @@ function coreRecipe(f, e) {
|
|
|
163
256
|
|
|
164
257
|
export {
|
|
165
258
|
NO_EFFECTS,
|
|
259
|
+
EFFECTS_SCHEMA,
|
|
260
|
+
normalizeEffects,
|
|
166
261
|
touchUp,
|
|
167
262
|
TOUCH_UP,
|
|
168
263
|
touchUpAmount,
|
|
@@ -180,4 +275,4 @@ export {
|
|
|
180
275
|
needsFace,
|
|
181
276
|
coreRecipe
|
|
182
277
|
};
|
|
183
|
-
//# sourceMappingURL=chunk-
|
|
278
|
+
//# sourceMappingURL=chunk-TBMYRKXR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/recipe.ts"],"sourcesContent":["/**\n * The bridge between what the user picked and the recipe the Go core takes.\n *\n * Both halves live here because both map onto `core.Recipe` field for field: BgFilter carries\n * the background mode and its one parameter, Effects carries everything else. They are two\n * types rather than one because the UI edits them from two different places - a preset picker\n * and a slider panel - not because they belong to different layers.\n */\n\n/**\n * What replaces the background.\n *\n * `imagePath` is a URL the consuming app serves: a path under its own public root, or a data\n * URL for something the user uploaded. The Engine fetches it and cover-crops it to the frame\n * aspect, so any shape is safe to pass.\n */\nexport type BgFilter =\n | { kind: \"none\" }\n | { kind: \"blur\"; blurRadius: number }\n | { kind: \"image\"; imagePath: string }\n /**\n * The background becomes TRANSPARENT and the person stays: the output canvas carries the\n * mask as alpha. For a {@link Scene} to put the person over another source; a plain video\n * track has no alpha, so on its own this shows the person over black.\n */\n | { kind: \"cutout\" }\n\n/** A colour as red, green, blue, each 0..1. */\nexport type Rgb = [number, number, number]\n\n/** Where smoothing (`beautify`) may land. */\nexport type SkinScope = \"person\" | \"face\"\n\n/** Where the colour LUT lands. */\nexport type GradeScope = \"frame\" | \"person\" | \"skin\"\n\nexport interface Effects {\n /** Skin smoothing, 0..1. Needs the person mask, so it pulls in the segmentation cost. */\n beautify: number\n /** Exposure, -1..1. Positive lifts the shadows more than the highlights. */\n exposure: number\n /** Contrast, -1..1. */\n contrast: number\n /** Saturation, -1..1. */\n saturation: number\n /** Warm (positive) or cool (negative), -1..1. */\n warmth: number\n /** Magenta (positive) or green (negative), -1..1. */\n tint: number\n /** Saturation for dull colours more than vivid ones, skin least, -1..1. */\n vibrance: number\n /** Film grain, 0..1. Noise costs encoder bits: keep it low on a live stream. */\n grain: number\n /** Keep the person framed. Needs the person mask. */\n autoframe: boolean\n\n // ── Need FACE landmarks ──────────────────────────────────────────────────────────\n /** Teeth whitening, 0..1. */\n teeth: number\n /** Brighten the whites of the eyes, 0..1. */\n eyeBright: number\n /** Reduce under-eye shadow, 0..1. */\n underEye: number\n /** Soften the nasolabial folds, 0..1. */\n smileLines: number\n\n /**\n * Makeup, 0..1 each, in its colour. Drawn against the full landmark mesh, so the lip tint\n * follows the lip line rather than an ellipse. Not offered in meet, like reshaping.\n */\n lips: number\n lipColor: Rgb\n blush: number\n blushColor: Rgb\n /** Iris colour: the ring only, clipped by the eyelids, the pupil left black. */\n iris: number\n irisColor: Rgb\n /** Eye shadow, 0..1, multiplied into the lower part of the lid-to-brow band. */\n eyeShadow: number\n eyeShadowColor: Rgb\n /** A white highlight across the middle of the lower lip, 0..1. Matte is 0. */\n lipGloss: number\n /** A faint flush over the whole face's skin, 0..1 - the face, where `blush` is the cheeks. */\n rosy: number\n rosyColor: Rgb\n\n // ── Skin, beside beautify.\n /** Lift and cool the skin, 0..1: brighter, less yellow. */\n whiten: number\n /**\n * How `whiten` whitens. `natural` relights the skin and cools its yellow, keeping its colour.\n * `pink` is the \"fair and rosy\" look East Asian beauty apps ship - GPUPixel's tuned skin\n * tables (Apache-2.0, see NOTICE), served as `/mediakit/whiten_pink.png`; it fades out on\n * darker skin, which those tables were not tuned for.\n */\n whitenStyle: \"natural\" | \"pink\"\n /** Exposure on the skin only. */\n skinLight: number\n /** Local contrast on the face. */\n clarity: number\n /** Where smoothing may land. See {@link SkinScope}. */\n skinScope: SkinScope\n\n /**\n * A colour LUT: `lut` is a URL the host serves (a 512x512 \"lookup\" PNG, 64 levels, 8x8 tiles,\n * row 0 at the top), `grade` how strongly it applies. \"\" means none.\n */\n lut: string\n grade: number\n /** Where the LUT lands. See {@link GradeScope}. */\n gradeScope: GradeScope\n\n /**\n * Take the person mask from a coloured screen instead of segmentation. Cheaper - MediaPipe\n * is never loaded - and the edge keeps hair the model loses. `keyColor` is the screen's\n * colour; [0, 0, 0] means \"find it\" from the frame's border. `keyTolerance` widens (+) or\n * narrows (-) what counts as screen, -1..1 around a tuned default.\n */\n chromaKey: boolean\n keyColor: Rgb\n keyTolerance: number\n\n /**\n * Lift exposure when the room is dark, on top of `exposure`. Only ever brightens. Needs no\n * detector: it reads the frame's own brightness.\n */\n autoLight: boolean\n\n /**\n * Flip the picture left to right, as a selfie preview shows it. Costs nothing on top of any\n * other effect; on its own it is one pass. Text on a whiteboard then reads backwards to\n * everyone watching, which is why it is a choice and not the default.\n */\n mirror: boolean\n\n /**\n * Jawline slimming, 0..1.\n *\n * Deliberately NOT offered in meet: Zoom, Google Meet and Teams all ship without face\n * reshaping, and in a work setting it reads as unserious. The field is here because the\n * second consumer of mediakit is slate, where reshaping is ordinary.\n */\n slimFace: number\n /** Eye enlargement, 0..1. Withheld from meet for the same reason as slimFace. */\n enlargeEyes: number\n /** Nose narrowing, 0..1. Withheld from meet like slimFace. */\n noseSlim: number\n /** Chin length, -1 (shorter) .. 1 (longer). Withheld from meet like slimFace. */\n chin: number\n /** Reshaping along the face's own outline. */\n jaw: number\n cheekbone: number\n forehead: number\n /** Brow fill, 0..1, multiplied in so the hairs show; lighter at the inner end. */\n brow: number\n browColor: Rgb\n /** Shading under the cheekbones, along the jaw and beside the nose, 0..1. */\n contour: number\n /** Light on the nose bridge, cheekbone tops, mid forehead and chin, 0..1. */\n highlight: number\n /** A look painted as an image on the canonical face. */\n makeupTexture: string\n makeup: number\n /** How the makeup texture blends: soft light (default), multiply, overlay, hard light, normal. */\n makeupBlend: \"softLight\" | \"multiply\" | \"overlay\" | \"hardLight\" | \"normal\"\n}\n\nexport const NO_EFFECTS: Effects = {\n beautify: 0,\n exposure: 0,\n contrast: 0,\n saturation: 0,\n warmth: 0,\n tint: 0,\n vibrance: 0,\n grain: 0,\n autoframe: false,\n teeth: 0,\n eyeBright: 0,\n underEye: 0,\n smileLines: 0,\n lips: 0,\n lipColor: [0.55, 0.18, 0.24],\n blush: 0,\n blushColor: [0.9, 0.5, 0.42],\n iris: 0,\n irisColor: [0.3, 0.5, 0.75],\n eyeShadow: 0,\n eyeShadowColor: [0.55, 0.42, 0.37],\n lipGloss: 0,\n rosy: 0,\n rosyColor: [0.9, 0.42, 0.49],\n whiten: 0,\n skinLight: 0,\n clarity: 0,\n skinScope: \"person\",\n lut: \"\",\n grade: 0,\n gradeScope: \"frame\",\n chromaKey: false,\n keyColor: [0, 0, 0],\n keyTolerance: 0,\n autoLight: false,\n mirror: false,\n slimFace: 0,\n enlargeEyes: 0,\n noseSlim: 0,\n chin: 0,\n jaw: 0,\n cheekbone: 0,\n forehead: 0,\n brow: 0,\n browColor: [0.36, 0.27, 0.22],\n contour: 0,\n highlight: 0,\n makeupTexture: \"\",\n makeup: 0,\n makeupBlend: \"softLight\",\n whitenStyle: \"natural\",\n}\n\n/**\n * What an `Effects` field accepts: `amount` 0..1, `signed` -1..1, `color` an {@link Rgb},\n * `choice` one of `values`, `url` a string (\"\" is none). Ranges match `Recipe.Normalized` in Go.\n */\nexport type FieldSpec =\n | { kind: \"amount\" | \"signed\" }\n | { kind: \"bool\" }\n | { kind: \"color\" }\n | { kind: \"choice\"; values: readonly string[] }\n | { kind: \"url\" }\n\nconst amount = { kind: \"amount\" } as const\nconst signed = { kind: \"signed\" } as const\nconst bool = { kind: \"bool\" } as const\nconst color = { kind: \"color\" } as const\nconst url = { kind: \"url\" } as const\n\n// The spec a field of type T may have. [T] stops a union being checked member by member.\ntype SpecFor<T> = [T] extends [boolean]\n ? { kind: \"bool\" }\n : [T] extends [number]\n ? { kind: \"amount\" | \"signed\" }\n : [T] extends [Rgb]\n ? { kind: \"color\" }\n : string extends T\n ? { kind: \"url\" }\n : { kind: \"choice\"; values: readonly T[] }\n\n/** Every {@link Effects} field; a missing field or a wrong kind does not compile. */\nexport const EFFECTS_SCHEMA: { readonly [K in keyof Effects]-?: SpecFor<Effects[K]> } = {\n beautify: amount,\n exposure: signed,\n contrast: signed,\n saturation: signed,\n warmth: signed,\n tint: signed,\n vibrance: signed,\n grain: amount,\n autoframe: bool,\n teeth: amount,\n eyeBright: amount,\n underEye: amount,\n smileLines: amount,\n lips: amount,\n lipColor: color,\n blush: amount,\n blushColor: color,\n iris: amount,\n irisColor: color,\n eyeShadow: amount,\n eyeShadowColor: color,\n lipGloss: amount,\n rosy: amount,\n rosyColor: color,\n whiten: amount,\n whitenStyle: { kind: \"choice\", values: [\"natural\", \"pink\"] },\n skinLight: amount,\n clarity: amount,\n skinScope: { kind: \"choice\", values: [\"person\", \"face\"] },\n lut: url,\n grade: amount,\n gradeScope: { kind: \"choice\", values: [\"frame\", \"person\", \"skin\"] },\n chromaKey: bool,\n keyColor: color,\n keyTolerance: signed,\n autoLight: bool,\n mirror: bool,\n slimFace: amount,\n enlargeEyes: amount,\n noseSlim: amount,\n chin: signed,\n jaw: amount,\n cheekbone: amount,\n forehead: signed,\n brow: amount,\n browColor: color,\n contour: amount,\n highlight: amount,\n makeupTexture: url,\n makeup: amount,\n makeupBlend: { kind: \"choice\", values: [\"softLight\", \"multiply\", \"overlay\", \"hardLight\", \"normal\"] },\n}\n\n/**\n * Any value as a valid {@link Effects}: numbers clamped, missing or malformed fields from\n * {@link NO_EFFECTS}, unknown fields dropped.\n */\nexport function normalizeEffects(raw: unknown): Effects {\n const src = (raw && typeof raw === \"object\" ? raw : {}) as Record<string, unknown>\n const out: Record<string, unknown> = {}\n for (const [key, spec] of Object.entries(EFFECTS_SCHEMA) as [keyof Effects, FieldSpec][]) {\n const v = src[key]\n const fallback = NO_EFFECTS[key]\n switch (spec.kind) {\n case \"amount\":\n case \"signed\": {\n const lo = spec.kind === \"amount\" ? 0 : -1\n out[key] = typeof v === \"number\" && Number.isFinite(v) ? Math.min(1, Math.max(lo, v)) : fallback\n break\n }\n case \"bool\":\n out[key] = typeof v === \"boolean\" ? v : fallback\n break\n case \"color\":\n out[key] =\n Array.isArray(v) && v.length === 3 && v.every((x) => typeof x === \"number\" && Number.isFinite(x))\n ? v.map((x: number) => Math.min(1, Math.max(0, x)))\n : [...(fallback as Rgb)]\n break\n case \"choice\":\n out[key] = typeof v === \"string\" && spec.values.includes(v) ? v : fallback\n break\n case \"url\":\n out[key] = typeof v === \"string\" ? v : fallback\n break\n }\n }\n return out as unknown as Effects\n}\n\n/**\n * One knob for \"look a little fresher\": skin, eyes, under-eyes, smile lines and teeth, moved\n * together in proportions tuned to read as rested rather than filtered at 1.\n *\n * A host that shows this instead of five sliders gets the shape Zoom and TikTok ship - people\n * reach for one control, not five, and five half-understood knobs mostly get set too high. The\n * ratios live here, next to the fields they drive, so every host means the same thing by it.\n */\nexport function touchUp(amount: number): Pick<Effects, \"beautify\" | \"eyeBright\" | \"underEye\" | \"smileLines\" | \"teeth\"> {\n const a = Math.min(1, Math.max(0, amount))\n return {\n beautify: a * TOUCH_UP.beautify,\n eyeBright: a * TOUCH_UP.eyeBright,\n underEye: a * TOUCH_UP.underEye,\n smileLines: a * TOUCH_UP.smileLines,\n teeth: a * TOUCH_UP.teeth,\n }\n}\n\n/** What `touchUp(1)` sets. Exported so a host can read a stored recipe back into one knob. */\nexport const TOUCH_UP = {\n beautify: 0.6,\n eyeBright: 0.5,\n underEye: 0.45,\n smileLines: 0.5,\n teeth: 0.4,\n} as const\n\n/**\n * The touch-up position a recipe corresponds to: the LARGEST of its five fields relative to\n * `touchUp(1)`. A recipe whose fields were set one by one has no single answer, and reading one\n * field only would show 0 for a recipe still whitening teeth - a knob at 0 that cannot turn off\n * what is running. Taking the largest, any effect still on shows, and moving the knob rewrites\n * all five consistently.\n */\nexport function touchUpAmount(e: Effects): number {\n let a = 0\n for (const k of Object.keys(TOUCH_UP) as (keyof typeof TOUCH_UP)[]) {\n a = Math.max(a, (e[k] ?? 0) / TOUCH_UP[k])\n }\n return Math.min(1, a)\n}\n\n/** Go-side `BackgroundMode`. Must match `core/recipe.go`. */\nexport const MODE_NONE = 0\nexport const MODE_BLUR = 1\nexport const MODE_IMAGE = 2\nexport const MODE_CUTOUT = 3\n\n/** Go-side `SkinScope` and `Scope`. Must match `core/recipe.go`. */\nexport const SKIN_SCOPE = { person: 0, face: 1 } as const\nexport const MAKEUP_BLEND = { softLight: 0, multiply: 1, overlay: 2, hardLight: 3, normal: 4 } as const\nexport const GRADE_SCOPE = { frame: 0, person: 1, skin: 2 } as const\n\nexport function backgroundMode(f: BgFilter): number {\n switch (f.kind) {\n case \"blur\":\n return MODE_BLUR\n case \"image\":\n return MODE_IMAGE\n case \"cutout\":\n return MODE_CUTOUT\n default:\n return MODE_NONE\n }\n}\n\n/**\n * Whether this recipe needs the person mask.\n *\n * Must match `Recipe.NeedsMask` on the Go side. This is the single biggest saving in the\n * module: a colour-only recipe skips MediaPipe entirely - the most expensive part of a frame,\n * and 9 MB of wasm the user then never downloads.\n *\n * The Go version is authoritative; this one exists so the JS side knows whether to load the\n * segmenter at all, BEFORE it can ask Go.\n */\nexport function needsMask(f: BgFilter, e: Effects): boolean {\n return (\n f.kind !== \"none\" ||\n e.beautify > 0 ||\n e.autoframe ||\n hasSkin(e) ||\n (e.grade > 0 && (e.gradeScope ?? \"frame\") !== \"frame\")\n )\n}\n\nfunction hasSkin(e: Effects): boolean {\n return (e.whiten ?? 0) > 0 || (e.skinLight ?? 0) > 0 || (e.clarity ?? 0) > 0\n}\n\n/**\n * Whether this recipe needs the SEGMENTER: a mask, and not one a colour key already gives.\n * Must match `Recipe.NeedsSegmentation` on the Go side. This, not {@link needsMask}, decides\n * whether MediaPipe is loaded - with `chromaKey` on, its 9 MB are never fetched.\n */\nexport function needsSegmentation(f: BgFilter, e: Effects): boolean {\n return needsMask(f, e) && !e.chromaKey\n}\n\n/** Whether this recipe is better served by the multiclass segmenter. */\nexport function needsSkinClasses(_f: BgFilter, e: Effects): boolean {\n return (e.whiten ?? 0) > 0 || (e.skinLight ?? 0) > 0 || (e.grade > 0 && (e.gradeScope ?? \"frame\") !== \"frame\")\n}\n\n/**\n * Whether this recipe needs face landmarks.\n *\n * Must match `Recipe.NeedsFace` on the Go side. Split from {@link needsMask} because the two\n * detectors are independent costs, and the landmark model is 15 times the size of the\n * segmentation one - making someone who only wants a blurred background download it is waste\n * that shows up on the first load.\n */\nexport function needsFace(e: Effects): boolean {\n return (\n e.teeth > 0 ||\n e.eyeBright > 0 ||\n e.underEye > 0 ||\n e.smileLines > 0 ||\n e.lips > 0 ||\n e.blush > 0 ||\n e.iris > 0 ||\n (e.eyeShadow ?? 0) > 0 ||\n (e.lipGloss ?? 0) > 0 ||\n (e.rosy ?? 0) > 0 ||\n (e.skinScope === \"face\" && (e.beautify > 0 || hasSkin(e))) ||\n // Whitening and skin light measure skin on the face; clarity is held to it.\n hasSkin(e) ||\n (e.grade > 0 && e.gradeScope === \"skin\") ||\n e.slimFace > 0 ||\n e.enlargeEyes > 0 ||\n e.noseSlim > 0 ||\n e.chin !== 0 ||\n (e.jaw ?? 0) > 0 ||\n (e.cheekbone ?? 0) > 0 ||\n (e.forehead ?? 0) !== 0 ||\n (e.brow ?? 0) > 0 ||\n (e.contour ?? 0) > 0 ||\n (e.highlight ?? 0) > 0 ||\n ((e.makeup ?? 0) > 0 && !!e.makeupTexture)\n )\n}\n\n/** The recipe in the shape the Go core takes. Field names must match `setRecipe` in wasmjs/main.go. */\nexport interface CoreRecipe {\n background: number\n blurRadius: number\n beautify: number\n exposure: number\n contrast: number\n saturation: number\n warmth: number\n tint: number\n vibrance: number\n grain: number\n autoframe: boolean\n teeth: number\n eyeBright: number\n underEye: number\n smileLines: number\n lips: number\n lipColor: Rgb\n blush: number\n blushColor: Rgb\n iris: number\n irisColor: Rgb\n eyeShadow: number\n eyeShadowColor: Rgb\n lipGloss: number\n rosy: number\n rosyColor: Rgb\n whiten: number\n skinLight: number\n clarity: number\n skinScope: number\n grade: number\n gradeScope: number\n chromaKey: boolean\n keyColor: Rgb\n keyTolerance: number\n autoLight: boolean\n mirror: boolean\n slimFace: number\n enlargeEyes: number\n noseSlim: number\n chin: number\n jaw: number\n cheekbone: number\n forehead: number\n brow: number\n browColor: Rgb\n contour: number\n highlight: number\n makeup: number\n makeupBlend: number\n whitenStyle: number\n}\n\nexport function coreRecipe(f: BgFilter, e: Effects): CoreRecipe {\n return {\n background: backgroundMode(f),\n blurRadius: f.kind === \"blur\" ? f.blurRadius : 0,\n beautify: e.beautify,\n exposure: e.exposure,\n contrast: e.contrast,\n saturation: e.saturation,\n warmth: e.warmth,\n tint: e.tint ?? 0,\n vibrance: e.vibrance ?? 0,\n grain: e.grain ?? 0,\n autoframe: e.autoframe,\n teeth: e.teeth,\n eyeBright: e.eyeBright,\n underEye: e.underEye,\n smileLines: e.smileLines,\n lips: e.lips,\n lipColor: e.lipColor,\n blush: e.blush,\n blushColor: e.blushColor,\n iris: e.iris,\n irisColor: e.irisColor,\n eyeShadow: e.eyeShadow ?? 0,\n eyeShadowColor: e.eyeShadowColor ?? NO_EFFECTS.eyeShadowColor,\n lipGloss: e.lipGloss ?? 0,\n rosy: e.rosy ?? 0,\n rosyColor: e.rosyColor ?? NO_EFFECTS.rosyColor,\n whiten: e.whiten ?? 0,\n skinLight: e.skinLight ?? 0,\n clarity: e.clarity ?? 0,\n skinScope: SKIN_SCOPE[e.skinScope] ?? 0,\n grade: e.grade,\n gradeScope: GRADE_SCOPE[e.gradeScope] ?? 0,\n chromaKey: e.chromaKey,\n keyColor: e.keyColor,\n keyTolerance: e.keyTolerance,\n autoLight: e.autoLight,\n mirror: e.mirror,\n slimFace: e.slimFace,\n enlargeEyes: e.enlargeEyes,\n noseSlim: e.noseSlim,\n chin: e.chin,\n jaw: e.jaw ?? 0,\n cheekbone: e.cheekbone ?? 0,\n forehead: e.forehead ?? 0,\n brow: e.brow ?? 0,\n browColor: e.browColor ?? NO_EFFECTS.browColor,\n contour: e.contour ?? 0,\n highlight: e.highlight ?? 0,\n makeup: e.makeupTexture ? (e.makeup ?? 0) : 0,\n makeupBlend: MAKEUP_BLEND[e.makeupBlend] ?? 0,\n whitenStyle: e.whitenStyle === \"pink\" ? 1 : 0,\n }\n}\n"],"mappings":";AAuKO,IAAM,aAAsB;AAAA,EAC/B,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,UAAU;AAAA,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,WAAW;AAAA,IACrC,QAAQ,EAAE,UAAU;AAAA,IACpB,WAAW,EAAE,aAAa;AAAA,IAC1B,SAAS,EAAE,WAAW;AAAA,IACtB,WAAW,WAAW,EAAE,SAAS,KAAK;AAAA,IACtC,OAAO,EAAE;AAAA,IACT,YAAY,YAAY,EAAE,UAAU,KAAK;AAAA,IACzC,WAAW,EAAE;AAAA,IACb,UAAU,EAAE;AAAA,IACZ,cAAc,EAAE;AAAA,IAChB,WAAW,EAAE;AAAA,IACb,QAAQ,EAAE;AAAA,IACV,UAAU,EAAE;AAAA,IACZ,aAAa,EAAE;AAAA,IACf,UAAU,EAAE;AAAA,IACZ,MAAM,EAAE;AAAA,IACR,KAAK,EAAE,OAAO;AAAA,IACd,WAAW,EAAE,aAAa;AAAA,IAC1B,UAAU,EAAE,YAAY;AAAA,IACxB,MAAM,EAAE,QAAQ;AAAA,IAChB,WAAW,EAAE,aAAa,WAAW;AAAA,IACrC,SAAS,EAAE,WAAW;AAAA,IACtB,WAAW,EAAE,aAAa;AAAA,IAC1B,QAAQ,EAAE,gBAAiB,EAAE,UAAU,IAAK;AAAA,IAC5C,aAAa,aAAa,EAAE,WAAW,KAAK;AAAA,IAC5C,aAAa,EAAE,gBAAgB,SAAS,IAAI;AAAA,EAChD;AACJ;","names":["amount"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BgFilter, Effects } from './recipe.js';
|
|
2
|
-
export { NO_EFFECTS, Rgb, TOUCH_UP, needsFace, needsMask, needsSegmentation, touchUp, touchUpAmount } from './recipe.js';
|
|
2
|
+
export { EFFECTS_SCHEMA, FieldSpec, NO_EFFECTS, Rgb, TOUCH_UP, needsFace, needsMask, needsSegmentation, normalizeEffects, touchUp, touchUpAmount } from './recipe.js';
|
|
3
3
|
import { Color, SceneLayer, TransitionKind } from './layout.js';
|
|
4
4
|
export { BLEND_MODES, BlendMode, Rect, TRANSITIONS, hitTest, layouts, parseColor } from './layout.js';
|
|
5
5
|
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
EFFECTS_SCHEMA,
|
|
2
3
|
NO_EFFECTS,
|
|
3
4
|
TOUCH_UP,
|
|
4
5
|
coreRecipe,
|
|
@@ -6,9 +7,10 @@ import {
|
|
|
6
7
|
needsMask,
|
|
7
8
|
needsSegmentation,
|
|
8
9
|
needsSkinClasses,
|
|
10
|
+
normalizeEffects,
|
|
9
11
|
touchUp,
|
|
10
12
|
touchUpAmount
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-TBMYRKXR.js";
|
|
12
14
|
import {
|
|
13
15
|
BLEND_MODES,
|
|
14
16
|
TRANSITIONS,
|
|
@@ -2397,6 +2399,7 @@ var FACE_UV = new Float32Array([
|
|
|
2397
2399
|
]);
|
|
2398
2400
|
export {
|
|
2399
2401
|
BLEND_MODES,
|
|
2402
|
+
EFFECTS_SCHEMA,
|
|
2400
2403
|
Engine,
|
|
2401
2404
|
FACE_UV,
|
|
2402
2405
|
NO_EFFECTS,
|
|
@@ -2410,6 +2413,7 @@ export {
|
|
|
2410
2413
|
needsFace,
|
|
2411
2414
|
needsMask,
|
|
2412
2415
|
needsSegmentation,
|
|
2416
|
+
normalizeEffects,
|
|
2413
2417
|
parseColor,
|
|
2414
2418
|
renderText,
|
|
2415
2419
|
touchUp,
|