Background Remove / Replace

Remove or replace video background per frame with foreground segmentation

You send a source video (and optionally a background spec). The service runs frame-by-frame: a segmentation model predicts a foreground alpha mask per frame, the foreground (subject) is refined for cleaner edges and hair, then composited over a base. Base is white (remove), a solid hex color (e.g. #1E90FF), or a replacement image. Original audio is muxed back; output is H.264/AAC MP4. Optional trim (start/end) is applied before processing. Async: submit job, poll until completed, then download the result URL.

videoprocessingstudio

Overview

Features

Remove or replace

Remove: subject over white. Replace: subject over a solid color (hex) or a replacement image. If no background spec is given, the step can be skipped and the original is returned.

Frame-by-frame segmentation

Each frame is run through a segmentation model to get an alpha mask; the foreground is refined (e.g. blur fusion) for better hair and edges, then composited with the chosen base at original resolution.

Optional trim

Optional start and end (seconds or hh:mm:ss) trim the source first; only the trimmed segment is processed. Reduces cost and output length.

Audio preserved

Original audio track is muxed back with the new video; output is single MP4 (H.264 video, AAC audio).

Use Cases

Virtual backgrounds

Replace background with a solid color or image for calls, presentations, or thumbnails.

Product or talking-head clips

Clean subject over white or a custom background; optional trim to process only the needed portion.

Input / Output

Input

Source video (URL or asset ID), optional background (hex color or replacement image URL/asset), optional start/end for trim

JSON body

Output

Job ID; when completed, result includes output video URL (MP4)

JSONmedia URL

Specs

Latency
Async; completion time depends on video length and resolution
Async
true
Rate Limit
Per API key
Max Input
Resolution and length limits depend on gateway/upstream

Quickstart

Prerequisites

  • -A CN8 Gateway API key with studio-background service enabled
  • -Source video accessible via URL (or ingested as asset)

Submit background job

studio-background

POST videoUrl + optional back_ground (hex color) OR imageUrl (replacement image URL). Omit both for remove (subject over white). Optional start/end (seconds or hh:mm:ss) to trim before processing.

POST/v1/proxy/studio-background
{
  "videoUrl": "https://example.com/video.mp4",
  "back_ground": "#1E90FF",
  "start": 0,
  "end": 30
}

Response

{
  "status": "accepted",
  "message": "Job queued for processing",
  "job": { "id": "550e8400-...", "status": "queued", "service": "studio-background" }
}

Field name is `videoUrl` (camelCase). Background spec is `back_ground` (with underscore) for hex colors, OR `imageUrl` for replacement image URL. Standard async — poll GET /v2/jobs/{job_id}.

Get result

When the job is completed, the result contains the output video URL. Download before the URL expires if you need long-term storage.

Background Remove/Replace

POSTasync

Remove or replace video background per frame. Optional background: none (white), hex color, or replacement image. Optional start/end trim. Returns job_id; poll for output video URL.

/v1/proxy/studio-background

Pricing

Billed per second of source video (trimmed segment if start/end are provided).

ServiceUnitPrice
Background Remove/Replacesecond$0.06/second
  • -Trim (start/end) reduces the segment length and thus the billed duration.

Guides & Tips

What happens under the hood

  • -Frames are decoded from the source (or trimmed clip). Each frame is run through a segmentation model to get a foreground alpha mask.
  • -The foreground (subject) is refined to improve edges and hair, then composited over the base (white, solid color, or stretched replacement image).
  • -The result is encoded as video; the original audio is muxed back. Output is a single MP4 file.

When to use trim

  • -Use start/end when you only need a portion of the video processed (e.g. first 30 seconds). This reduces processing time and billed seconds.

FAQ

Q: Remove vs replace?

A: Remove: subject is composited over white. Replace: subject over a solid color (hex) or a replacement image. If you omit background, behavior is remove (or skip, depending on gateway).

Q: Is the output resolution the same as input?

A: Yes. Compositing is done at the original frame size; output video matches input resolution (and original audio is preserved).

Q: How do I get the result?

A: Poll the job status endpoint with the job_id; when status is completed, the result contains the output video URL. Download before the URL expires if needed for long-term storage.

Related Products

Changelog

1.0 (2026-01-26)

  • -Initial catalog.

1.2 (2026-04-29)

  • -Renamed request fields: input_url → videoUrl, background → back_ground (hex colour) + imageUrl (replacement image).
  • -Documented full result_data shape: url, key, folder_id, content_type, duration_seconds + usage block.

1.1 (2026-02-23)

  • -Aligned with background_service: frame-by-frame segmentation, remove/replace with white/hex/image, optional trim (start/end), audio muxed back, H.264/AAC output. No model name in docs.