getOutput to get the output stream in the cameraReady callback, because the effects are not working yet at this point, the stream obtained will be the same as the input stream fed into the SDK. After the effects start to work, the SDK will apply them to the output stream automatically. You don’t need to call getOutput again. You can use this method if you want to display a video image as soon as possible but do not need to apply effects to the video the moment it is played.getOutput in the ready callback, the output stream obtained will have been processed. Because the ready callback occurs later than cameraReady, you can call getOutput in the ready callback if you want to apply effects to the video the moment it is displayed, but do not expect the video to be played as soon as possible.
// Get the authentication informationconst authData = {licenseKey: 'xxxxxxxxx',appId: 'xxx',authFunc: authFunc // For details, see “Configuring and Using a License - Signature”};// When initializing the SDK in regular mode, pass in the input or camera parametersconst config = {auth: authData, // The authentication informationbeautify: { // The effect parameterswhiten: 0.1,dermabrasion: 0.5,lift: 0,shave: 0,eye: 0.2,chin: 0,},input: inputStream // Prepare the stream data fed into the SDK as the input. For details, see “SDK Integration - Parameters and APIs”.}const sdk = new ArSdk(// Pass in a config object to initialize the SDKconfig)// After authentication succeeds, the SDK will trigger the `created` callback immediatelysdk.on('created', () => {// Pull and display the filter and effect list in the `created` callbacksdk.getEffectList({Type: 'Preset',Label: 'Makeup',}).then(res => {effectList = res});sdk.getCommonFilter().then(res => {filterList = res})})// The data you get by calling `getOutput` in different callbacks vary slightly. Choose the one that fits your needs.sdk.on('cameraReady', async () => {const output = await sdk.getOutput() // The effect parameters have not taken effect// Play the stream...})sdk.on('ready', async () => {const output = await sdk.getOutput() // The effect parameters have taken effect// Play the stream...// Call `setBeautify`, `setEffect`, or `setFilter` in the `ready` callback})

<button id="start">Enable the camera</button>
// Get the authentication informationconst authData = {licenseKey: 'xxxxxxxxx',appId: 'xxx',authFunc: authFunc // For details, see “Configuring and Using a License - Signature”};// Do not pass in the input or camera parameters when initializing the SDK. After an instance is obtained, the SDK will start loading the necessary resources.const config = {auth: authData, // The authentication informationbeautify: { // The effect parameterswhiten: 0.1,dermabrasion: 0.5,lift: 0,shave: 0,eye: 0.2,chin: 0,},}const sdk = new ArSdk(// Pass in a config object to initialize the SDKconfig)// After authentication succeeds, the SDK will trigger the `created` callback immediatelysdk.on('created', () => {// Pull and display the filter and effect list in the `created` callbacksdk.getEffectList({Type: 'Preset',Label: 'Makeup',}).then(res => {effectList = res});sdk.getCommonFilter().then(res => {filterList = res})})// `resourceReady` indicates that the necessary resources are ready. After receiving this callback, you can call `initCore` to feed an input stream to the SDK.sdk.on('resourceReady', () => {})// In this mode, the SDK will trigger the `ready` callback only after `initCore` is called.sdk.on('ready', async () => {const output = await sdk.getOutput() // The effects have been applied.// Play the stream...// Call `setBeautify`, `setEffect`, or `setFilter` in the `ready` callback})// Feed stream data to the SDK when the user turns the camera ondocument.getElementById('start').onclick = async function(){const devices = await navigator.mediaDevices.enumerateDevices()const cameraDevice = devices.find(d=>d.kind === 'videoinput')navigator.mediaDevices.getUserMedia({audio: false,video: {deviceId: cameraDevice.deviceId... // Other configuration}}).then(mediaStream => {// In this mode, make sure you call `initCore` after the `resourceReady` callback.sdk.initCore({input: mediaStream // Prepare the stream data fed into the SDK as the input. For details, see “SDK Integration - Parameters and APIs”.})})}
Feedback