

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 为 Amazon Chime SDK 配置 VideoFxProcessor 对象
<a name="configure-videofxprocessor"></a>

下表列出可以配置的 `VideoFxProcessor` 属性。表下方的示例显示典型的运行时系统配置。

**背景模糊**  
背景模糊具有以下属性：


| 属性 | Type | 说明 | 
| --- | --- | --- | 
| `isEnabled` | `boolean` | 当为 `true` 时，筛选器会模糊背景。 | 
| `strength` | `string` | 确定模糊程度。有效值：`low` \$1`medium` \$1`high`. | 

**背景替换**  
背景替换使用以下参数：


| 属性 | Type | 说明 | 
| --- | --- | --- | 
| `isEnabled` | `boolean` | 当为 `true` 时，筛选器会替换背景。 | 
| `backgroundImageURL` | `string` | 背景图片的 URL。筛选器根据当前屏幕的尺寸动态调整图像大小。您可以使用诸如 `https://...` 等字符串或诸如 `data:image/jpeg;base64` 等 URL。 | 
| `defaultColor` | `string` | 十六进制颜色字符串，例如 `000000` 或 `FFFFFF`，或 `black` 或 `white` 等字符串。如果未指定图像 URL，则处理器会使用 `defaultColor` 作为背景。如果未指定 `defaultColor`，则处理器默认为黑色。 | 

**运行时更改配置**  
您可以使用 `videoFxProcessor.setEffectConfig` 参数在运行时更改 `VideoFxProcessor` 配置。以下示例显示如何启用背景替换和禁用背景模糊。

**注意**  
一次只能指定一种类型的背景替换。指定 `backgroundImageURL` 或 `defaultColor` 的值，但不能同时指定两者。

```
videoFxConfig.backgroundBlur.isEnabled = false;
videoFxConfig.backgroundReplacement.isEnabled = true;
try {
  await videoFxProcessor.setEffectConfig(videoFxConfig);
} catch(error) {
  logger.error(error.toString())
}
```

如果 `setEffectConfig` 抛出异常，则之前的配置仍然有效。`setEffectConfig` 会在与导致 `VideoFxProcessor.create` 抛出异常的类似条件下抛出异常。

以下示例显示如何在视频运行时更改背景图像。

```
videoFxConfig.backgroundReplacement.backgroundImageURL = "https://my-domain.com/my-other-image.jpg";
try {
  await videoFxProcessor.setEffectConfig(videoFxConfig);
} catch(error) {
  logger.error(error.toString())
}
```