Docs / Web / Agora

Agora on the Web

Publish a beautified camera in the Agora Web SDK 4.x by wrapping Facevity's processed track in a custom video track.

Demo app: facevity-web-demo on GitHub

The Agora Web SDK publishes any MediaStreamTrack through createCustomVideoTrack. Give it Facevity’s processed track instead of the raw camera.

1. Requirements

  • @facevity/web set up as in the quick start
  • Agora Web SDK 4.x (agora-rtc-sdk-ng)
  • A licence that lists the page’s domain

2. Join and publish

import AgoraRTC from 'agora-rtc-sdk-ng';
import { Facevity, BeautyParams } from '@facevity/web';

const fv = await Facevity.initialize({ licenseToken, assetsBaseUrl: '/facevity/' });
fv.setParams(BeautyParams.NATURAL);

const client = AgoraRTC.createClient({ mode: 'rtc', codec: 'vp8' });
await client.join(appId, channel, token, null);

const camera = (await navigator.mediaDevices.getUserMedia({ video: true })).getVideoTracks()[0];
const processed = fv.createProcessedTrack(camera);
const videoTrack = AgoraRTC.createCustomVideoTrack({ mediaStreamTrack: processed });

videoTrack.play('local-player');           // local preview of the beautified track
await client.publish([videoTrack]);

Remote users receive the processed track. Beauty settings apply live; turning beauty off keeps the call running and frames pass through untouched.

3. Tear down

await client.unpublish([videoTrack]);
videoTrack.close();
processed.stop();                           // stops the processing
camera.stop();
fv.release();

Notes

  • Audio is separate: publish AgoraRTC.createMicrophoneAudioTrack() next to the video track as usual.
  • Use one Facevity instance per processed stream.

Next: ZEGOCLOUD on the Web · all platforms

Need help with an integration? Contact the Facevity team. We answer integration questions during trials.