Skip to main content
Version: 5.x.x

Video Effects Config - Flutter

VideoSDK.setVideoEffects() and room.setVideoEffects() take a VideoEffectsConfig, which describes the effects for the camera video you send. This page lists the classes and enums of that configuration, and the map that both methods return. To learn how to use the effects, see the Video Effects guide.

VideoEffectsConfig​

The whole effects configuration. Every effect is off until you turn it on.

Each call to setVideoEffects() replaces the whole configuration: an effect you leave out goes back to its default. Build the full configuration from your app's state every time.

Outside a const expression, you can also write the enum values under VideoEffectsConfig: VideoEffectsConfig.Pipeline.GRAPH, VideoEffectsConfig.StylePreset.VIVID, VideoEffectsConfig.Lut.WARM.

Example​

const VideoEffectsConfig config = VideoEffectsConfig(
lighting: VideoEffectsLighting(enabled: true, strength: 0.8),
filter: VideoEffectsFilter(lut: VideoEffectsLut.WARM, strength: 0.6),
background: VideoEffectsBackground(mode: VideoEffectsBackgroundMode.BLUR),
);

VideoEffectsFraming​

Auto-framing crops and zooms the picture to keep the subject in the center. The size of the video does not change.

  • enabled: bool - Defaults to false.
  • maxZoom: double - The closest the crop can zoom in, from 1.0 to 4.0. Defaults to 2.0.

On VideoEffectsPipeline.LEGACY, framing follows the largest face the SDK detects. On Android, this needs com.google.mlkit:face-detection:16.1.7 in your app's build.gradle. Without it, the other effects still run, and the returned map says why framing is off.

On VideoEffectsPipeline.GRAPH, framing follows the subject that you publish with publishFramingSubject().


VideoEffectsLighting​

Low-light correction brightens the dark parts of the picture and leaves the bright parts alone.

  • enabled: bool - Defaults to false.
  • strength: double - From 0.0 to 1.0. Defaults to 1.0.

VideoEffectsStyle​

A look applied to the whole picture.

  • preset: VideoEffectsStylePreset - Defaults to VideoEffectsStylePreset.OFF.
  • strength: double - From 0.0 to 1.0. Defaults to 1.0.
  • levels: int - The number of color steps that VideoEffectsStylePreset.POSTERIZE uses, from 3 to 17. Defaults to 5. VideoEffectsPipeline.GRAPH rounds it to an odd number.

VideoEffectsFilter​

A color grade, applied after the other effects.

  • lut: VideoEffectsLut - Defaults to VideoEffectsLut.OFF.
  • strength: double - From 0.0 to 1.0. Defaults to 1.0.

VideoEffectsBackground​

Background blur keeps the person sharp and blurs everything behind them. It runs on VideoEffectsPipeline.LEGACY only.

  • mode: VideoEffectsBackgroundMode - Defaults to VideoEffectsBackgroundMode.OFF.
  • blurStrength: double - How strong the blur is, from 0.0 to 1.0. Defaults to 0.5.

On Android, background blur needs com.google.mlkit:segmentation-selfie:16.0.0-beta6 in your app's build.gradle. Without it, the other effects still run, and the returned map says why blur is off.


VideoEffectsPipeline​

The engine that runs the effects.

  • LEGACY - The default. Runs the effects on the CPU. Framing follows the face the SDK detects. It runs every effect, including background blur.
  • GRAPH - Runs the effects on the GPU. Framing follows the subject that you publish with publishFramingSubject(). Background blur does not run on it. On a device whose GPU cannot run the effects, the returned map has applied set to false, and the camera video is sent without effects.

VideoEffectsStylePreset​

  • OFF - The default.
  • POSTERIZE - Flat color bands.
  • VIVID - Boosted contrast and color.

VideoEffectsLut​

  • OFF - The default.
  • WARM - Warmer tones.
  • COOL - Cooler tones.
  • MONO - Black and white.

VideoEffectsBackgroundMode​

  • OFF - The default.
  • BLUR - Blurs the background.

Applied effects​

setVideoEffects() and getAppliedVideoEffectsConfig() return a Map<String, dynamic>? that describes the effects that are running. It can differ from what you asked for.

  • engine: String - cpu when the effects run on VideoEffectsPipeline.LEGACY, gpu when they run on VideoEffectsPipeline.GRAPH, and none when no effect runs.
  • applied: bool - false when the effects are not running.
  • reason: String - Why the effects, or one of them, do not run. For example, the camera is off, or an ML Kit library is missing on Android.
  • pipeline: String - LEGACY or GRAPH.
  • framing, lighting, style, filter and background: Map - The settings in force for each effect. On VideoEffectsPipeline.LEGACY, framing also has face, which is true while a face is followed, and zoom, the current zoom factor. When an effect cannot run, its map has a reason.

The map can contain other keys.

While your camera is off, engine is none and applied is false. The SDK keeps the configuration and applies it when the camera starts.

Example​

final Map<String, dynamic>? effects = await VideoSDK.getAppliedVideoEffectsConfig();

if (effects?['applied'] != true) {
print("Effects are not running: ${effects?['reason']}");
}

Got a Question? Ask us on discord