Happy Pony API Get an API key →

Background replace

Pricing: Background replace

Keep the people in a video exactly as they are, with their voices, and replace everything around them with the scene in a plate image. Returns an mp4.

POST https://api.happypony.io/api/v1/jobs/background-replace
GET  https://api.happypony.io/api/v1/jobs/:requestId/status
GET  https://api.happypony.io/api/v1/jobs/:requestId
PUT  https://api.happypony.io/api/v1/jobs/:requestId/cancel

POST with Content-Type: application/json. The clip and the plate are fetched and stored when the request is created, so a URL that cannot be fetched is a 400 invalid_media and nothing is charged. Unknown fields are a 400.

Field Type Required Default Description
video_url string yes http(s) URL of the source clip (mp4, mov, webm or mkv, up to 200 MB).
plate_url string yes http(s) URL of the plate: one image of the new scene with nobody in it, in the clip's aspect. The plate decides the scene.
scene string unless prompt The new scene in plain literal English, up to 4000 characters, with no negations.
people string no Who stands there and what they do, in English.
prompt string no built from scene Your exact prompt, up to 4000 characters. Needs variant M or R and must name the plate as <Picture 1>; with M, also the clip as <Video 1>.
variant string no auto M reads the people as a matte: fine hair, held objects, night scenes. R regenerates from the plate and the words: daylight scenes with no thin parts, a person absent or small at the start. auto picks R when the kept people cover under 2% or are absent at the start, otherwise M.
duration_seconds integer no 10 1 to 20 (15 at 768). Only the first duration_seconds of the clip are processed.
resolution string no 480 480 or 768.
upscale boolean no false Force the canvas even when the clip already fits it.
seed integer no worker default The same inputs and seed give the same result.
keep object no every person, up to 8 What is kept from the source, applied in this order. people: "all", "largest" or a count 1 to 8. concepts: up to 4 { "text", "expand"? } (0 to 32 px) that stay too. frames: [start_s, end_s], keep only in this range. subtract: up to 4 { "text", "expand"? } (0 to 64 px, default 18) taken back out. boxes: up to 16 { "rect": [x, y, w, h], "set": 0 or 1, "frames"? }, rect in 0–1 fractions, set 0 keeps the source there and 1 regenerates it.
paste_back object no erode 1, feather 3 How the people are pasted back: erode 0 to 8, feather 0 to 16. It cannot be turned off.
grade object no off Adjusts the kept area to the new light. { "auto": true, "strength"?: 0..1 } or manual gain, gamma, lift_bottom.
lipsync boolean no false Pin the audio rows to the source audio.
dry_run boolean no false true: no render, only a mask preview. Read mask_preview (green = the regenerated cells; everything else is kept) and stats.

The source audio is kept. Completed requests have video_url and files, including the comparison sheet and mask preview; dry_run results have mask_preview, stats and files instead.

换背景

价格:换背景

完整保留视频中的人物及其声音,并将人物周围的一切替换为背景图中的场景。返回一个 mp4。

POST https://api.happypony.io/api/v1/jobs/background-replace
GET  https://api.happypony.io/api/v1/jobs/:requestId/status
GET  https://api.happypony.io/api/v1/jobs/:requestId
PUT  https://api.happypony.io/api/v1/jobs/:requestId/cancel

使用 POST 和 Content-Type: application/json。视频和背景图在创建请求时抓取并保存,因此无法抓取的 URL 会返回 400 invalid_media,且不收费。未知字段返回 400。

字段 类型 必填 默认值 说明
video_url string 是 源视频的 http(s) URL(mp4、mov、webm 或 mkv,最大 200 MB)。
plate_url string 是 背景图的 http(s) URL:一张空无一人的新场景图片,宽高比与视频一致。场景由背景图决定。
scene string 未提供 prompt 时必填 用直白的英文描述新场景,最多 4000 字符,不要使用否定句。
people string 否 用英文说明谁站在那里、在做什么。
prompt string 否 根据 scene 生成 完整提示词,最多 4000 字符。需要 variant 为 M 或 R,并以 <Picture 1> 指代背景图;M 还需以 <Video 1> 指代视频。
variant string 否 auto M 把人物作为遮罩读取,适合细碎发丝、手持物体、夜景。R 仅根据背景图和文字重新生成,适合没有细小部位的日光场景,或开头人物不在或很小的情况。auto 在保留人物占比低于 2% 或开头不在画面时选 R,否则选 M。
duration_seconds integer 否 10 1 到 20(768 时最多 15)。只处理视频开头的 duration_seconds 秒。
resolution string 否 480 480 或 768。
upscale boolean 否 false 即使视频已适配画布,也强制调整到画布尺寸。
seed integer 否 worker 默认值 相同输入和种子得到相同结果。
keep object 否 所有人物,最多 8 人 从原视频保留的内容,按此顺序应用。people:"all"、"largest" 或 1 到 8 的人数。concepts:最多 4 个 { "text", "expand"? }(0 到 32 像素),一并保留。frames:[start_s, end_s],只在此范围内保留。subtract:最多 4 个 { "text", "expand"? }(0 到 64 像素,默认 18),从保留内容中去掉。boxes:最多 16 个 { "rect": [x, y, w, h], "set": 0 或 1, "frames"? },rect 为 0–1 的比例,set 为 0 时保留原画面,为 1 时重新生成。
paste_back object 否 erode 1,feather 3 人物贴回方式:erode 0 到 8,feather 0 到 16。不能关闭。
grade object 否 关闭 让保留区域适应新光线。{ "auto": true, "strength"?: 0..1 },或手动指定 gain、gamma、lift_bottom。
lipsync boolean 否 false 将音频行固定为原视频音频。
dry_run boolean 否 false true:不渲染,只生成遮罩预览。查看 mask_preview(绿色 = 重新生成的单元,其余保留)和 stats。

保留原声。完成的请求带有 video_url 和 files(包括对比图和遮罩预览);dry_run 结果则带有 mask_preview、stats 和 files。