# Customize Video Background

Easily customize the background of your avatar videos. 

With HeyGen, you can create videos with custom backgrounds. You can choose one of the following three sources for the background:

* **Color**
* **Image**
* **Video**

To do this, you need to change the "**Background Settings**" type to the appropriate option in the [Create Avatar Video (V2)](https://movio-api.readme.io/reference/create-an-avatar-video-v2#colorbackground) endpoint.

## Color Background

In this example, we’re setting a solid color background for the avatar video.\
To do this, set the background `type` to `color`. and specify the desired color using a hex code in the `value` field (for example, here we set it to `#FAFAFA` which corresponds to a light gray color).

<Callout icon="📘" theme="info">
  **Note:**

  To retrieve the *avatar\_id* and *voice\_id* used in this request, refer to the following APIs: [List All Avatars (V2)](https://movio-api.readme.io/reference/list-avatars-v2) and [List All Voices (V2)](https://movio-api.readme.io/reference/list-voices-v2).
</Callout>

```bash Request
curl -X POST https://api.heygen.com/v2/video/generate \
-H 'X-Api-Key: <your-api-key>' \
-H 'Content-Type: application/json' \
-d '{
  "video_inputs": [
    {
      "character": {
        "type": "avatar",
        "avatar_id": "Brain_public_pro4_20230613",
        "avatar_style": "normal"
      },
      "voice": {
        "type": "text",
        "input_text": "With HeyGen, it is very easy to create avatar videos with custom backgrounds.",
        "voice_id": "d7bbcdd6964c47bdaae26decade4a933"
      },
      "background": {
        "type": "color",
        "value": "#FAFAFA"
      }
    }
  ]
}'
```

```json Response
{
  "code": 100,
  "data": {
    "video_id": "<video_id>"
  },
  "message": "Success"
}
```

**Avatar Video with Color Background**

<Embed url="https://app.heygen.com/embeds/17b4a951dcb8445f9aeb0cbae786fbf5" href="https://app.heygen.com/embeds/17b4a951dcb8445f9aeb0cbae786fbf5" typeOfEmbed="iframe" height="450px" width="100%" iframe="true" />

You can also set the color code to `#008000` if you want to create *green screen* videos.

<Embed url="https://app.heygen.com/embeds/369e2c284a644bdcb02617a9bfc175b3" href="https://app.heygen.com/embeds/369e2c284a644bdcb02617a9bfc175b3" typeOfEmbed="iframe" height="450px" width="100%" iframe="true" />

## Image Background

In this example, we’re setting an image background for the avatar video.\
To set the **background** as **image**, you need change the background `type` to `image`. Then, you need to provide either the `url`  or `image_asset_id` for the image asset from Heygen. Exactly one of these parameters must be provided. Omitting both, or defining both, will result in an error. These parameters can be obtained from the response of the [Upload Asset](https://movio-api.readme.io/reference/upload-asset) API.

```bash Request
curl -X POST https://api.heygen.com/v2/video/generate \
-H 'X-Api-Key: <your-api-key>' \
-H 'Content-Type: application/json' \
-d '{
  "video_inputs": [
    {
      "character": {
        "type": "avatar",
        "avatar_id": "Brain_public_pro4_20230613",
        "avatar_style": "normal"
      },
      "voice": {
        "type": "text",
        "input_text": "With HeyGen, it is very easy to create avatar videos with custom backgrounds.",
        "voice_id": "d7bbcdd6964c47bdaae26decade4a933"
      },
      "background": {
        "type": "image",
        "image_asset_id": "<asset_id>"
      }
    }
  ]
}'
```

```json Response
{
  "code": 100,
  "data": {
    "video_id": "<video_id>"
  },
  "message": "Success"
}
```

**Avatar Video with Image Background**

<Embed url="https://app.heygen.com/embeds/965f8cf2cc6c4cc390454d37468b4a08" href="https://app.heygen.com/embeds/965f8cf2cc6c4cc390454d37468b4a08" typeOfEmbed="iframe" height="450px" width="100%" iframe="true" />

## Video Background

In this example, we’re setting a video background for the avatar video.\
To set the **background** as **video**, you need change the background `type` to `video`. Then, you need to provide either the `url` or `video_asset_id` for video asset from HeyGen. Exactly one of these parameters must be provided. Omitting both, or defining both, will result in an error. These parameters can be obtained from the response of the [Upload Asset](https://movio-api.readme.io/reference/upload-asset) API.

You can also specify video playback style with `play_style`. Supported values are `fit_to_scene`, `freeze`, `loop`, `full_video`.

```bash Request
curl -X POST https://api.heygen.com/v2/video/generate \
-H 'X-Api-Key: <your-api-key>' \
-H 'Content-Type: application/json' \
-d '{
  "video_inputs": [
    {
      "character": {
        "type": "avatar",
        "avatar_id": "Brain_public_pro4_20230613",
        "avatar_style": "normal"
      },
      "voice": {
        "type": "text",
        "input_text": "With HeyGen, it is very easy to create avatar videos with custom backgrounds.",
        "voice_id": "d7bbcdd6964c47bdaae26decade4a933"
      },
      "background": {
        "type": "video",
        "video_asset_id": "<asset_id>",
        "play_style": "loop"
      }
    }
  ]
}'
```

```json Response
{
  "code": 100,
  "data": {
    "video_id": "<video_id>"
  },
  "message": "Success"
}
```

**Avatar Video with Video Background**

<Embed url="https://app.heygen.com/embeds/604fb54308764239a5fc040e99a78bb6" href="https://app.heygen.com/embeds/604fb54308764239a5fc040e99a78bb6" typeOfEmbed="iframe" height="450px" width="100%" iframe="true" />

For more details on background configuration options, supported values, and additional parameters for video generation, see detailed API Reference: [Create Avatar Video (V2)](https://movio-api.readme.io/reference/create-an-avatar-video-v2#colorbackground)

<br />