Docs / Web / Quick start
Web quick start
Install @facevity/web, serve its model files, set up a licence for your domain and beautify a camera track or individual frames with WebGL2.
Demo app: facevity-web-demo on GitHub
@facevity/web brings the Facevity pipeline to the browser: WebGL2 shaders plus MediaPipe face tracking, with the same effects, sliders, presets, lipstick shades, filters, accessories and licence model as the mobile SDKs. It is a typed ES module with no RTC vendor dependency.
1. Install
npm install @facevity/web
The package is distributed to trial and production customers (a registry token for the @facevity scope, or a package tarball). Its only dependency is @mediapipe/tasks-vision, loaded lazily.
Serve the assets
The package ships its runtime files in dist/assets/:
dist/assets/models/face_landmarker.task MediaPipe Face Landmarker
dist/assets/models/selfie_multiclass.tflite segmentation model
dist/assets/models/canonical_mesh.bin canonical face mesh
dist/assets/props/ the AR prop pack
dist/assets/wasm/ MediaPipe tasks-vision wasm
By default they load from assets/ next to the package’s index.js. With a bundler, copy node_modules/@facevity/web/dist/assets to your public folder and pass its URL:
cp -r node_modules/@facevity/web/dist/assets public/facevity
Each file can also be pointed elsewhere, for example a CDN: wasmBaseUrl, faceModelUrl, segmentationModelUrl, canonicalMeshUrl, propsBaseUrl.
2. Create the engine
import { Facevity, BeautyParams, BeautyColors } from '@facevity/web';
const fv = await Facevity.initialize({ licenseToken, assetsBaseUrl: '/facevity/' });
fv.setParams(BeautyParams.NATURAL); // presets: DEFAULT, NATURAL, GLAM, NONE
fv.setParams({ smooth: 60, brightness: 30 }); // partial updates over the current levels
fv.setLipstick(BeautyColors.LIP_RED, 70);
fv.setFilter('warm', 40);
fv.setProp('aviator');
Every 0..100 slider: 0 = off, 50 = natural, 100 = strong but still realistic (skinTone is -100..100). setBeautyEnabled(false), or all levels at 0, is an exact pass-through.
3. Beautify a camera track
For video calls and live streams, get a processed copy of the camera track:
const camera = (await navigator.mediaDevices.getUserMedia({ video: true })).getVideoTracks()[0];
const processed = fv.createProcessedTrack(camera); // MediaStreamTrack
videoElement.srcObject = new MediaStream([processed]);
createProcessedTrack uses insertable streams (MediaStreamTrackProcessor and MediaStreamTrackGenerator) where the browser has them (Chrome, Edge), and a hidden <video> with canvas.captureStream() elsewhere (Safari, Firefox). Stopping the returned track stops the processing; the camera track stays yours. Use one Facevity per processed stream: each owns one WebGL canvas.
4. Or process frames yourself
// synchronous: <video>, VideoFrame, ImageBitmap, canvas, image or ImageData in
fv.processFrame(video, { output: canvas, mirror: true });
// WebCodecs: returns a new VideoFrame you own
const out: VideoFrame = fv.processVideoFrame(frame);
5. Licence for your domain
On the web the app ID is the page: the licence lists your web domains, exact (app.example.com) or wildcard (*.example.com). Development licences also accept localhost, 127.0.0.1, *.localhost and *.test.
// A. a token from your backend, or the contents of an offline .fvl file
const fv = await Facevity.initialize({ licenseToken, assetsBaseUrl: '/facevity/' });
// B. online activation with a licence key (refreshed once a day)
const fv2 = await Facevity.initialize({ licenseServer: 'https://<licence server from your trial>', licenseKey: 'FV-XXXX-XXXX-XXXX-XXXX' });
fv.licenseInfo.status; // 'VALID' | 'OFFLINE_GRACE' | 'WRONG_AUDIENCE' | …
await fv.setLicenseToken(freshToken); // verify and install a new token
fv.addLicenseListener((info) => console.log(info.status));
The token is verified locally with WebCrypto; there is no network call on the frame path. Without a licence frames are processed with a watermark (unlicensedBehavior: 'watermark', the default) or passed through ('passthrough'). See Licensing.
6. Accessories and capabilities
const props = fv.availableProps(); // 9 built-in props
fv.setProp('cat_ears');
fv.clearProp();
await fv.addPropsPack('/my-props/'); // your own pack
const caps = fv.capabilities(); // what the licence covers
fv.addCapabilitiesListener((c) => render(c));
Browser support
| Chrome / Edge 94+ | Safari 16.4+ | Firefox 115+ | |
|---|---|---|---|
| WebGL2 pipeline, all effects | yes | yes | yes |
| MediaPipe landmarker | GPU delegate | GPU delegate | GPU delegate, CPU fallback |
createProcessedTrack |
insertable streams | canvas captureStream |
canvas captureStream |
processVideoFrame (WebCodecs) |
yes | 16.4+ | 130+ |
The canvas path follows the <video> element’s frame callbacks, so browsers throttle it in background tabs.
Lifecycle and diagnostics
resetTracking(),facesDetected,stats(),debugLandmarks(),setDebugMaskView(0..7).release()frees the GL objects, the models and the context.Facevity.VERSIONis"0.4.0-alpha".
FaceUnity-style kit
FVRenderManager.setup(token, cb, options) and FVRenderKit.getInstance() (faceBeauty = new FVFaceBeauty(), renderWithInput({ source, timestamp, mirror, output }), createProcessedTrack) follow FaceUnity’s call flow. See Migrating from FaceUnity.
Demo app and next steps
The web demo app (Vite, TypeScript) has camera beauty with a before/after split, a licence panel and a call page per RTC SDK.
Need help with an integration? Contact the Facevity team. We answer integration questions during trials.