mcpField
V
video-background-removal

video-background-removal

github.com/eachlabs创意与媒体44232 次安装今天更新
代码仓库

关于 video-background-removal

使用 each::sense 去除或替换视频背景的剪辑技能,适用于制作合成素材、演示、会议或产品视频。支持透明背景、纯色、图片、动态视频背景及背景模糊。

主要功能

  1. 01去除背景并输出透明效果
  2. 02替换为纯色或图片背景
  3. 03合成动态视频背景
  4. 04应用背景模糊
  5. 05选择 eco 或 max 模式

适用场景

  1. 01制作供后期编辑的透明素材
  2. 02创建虚拟办公室会议视频
  3. 03制作白底产品片段
  4. 04为演讲者视频添加摄影棚场景

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/eachlabs/skills --skill video-background-removal

安装后在 Claude Code 中输入/video-background-removal确认已加载。

附带文件references/SSE-EVENTS.md

详细介绍

视频背景移除

使用 each::sense 移除并替换视频背景。此技能可为任何视频内容实现透明背景、虚拟环境、专业合成和创意背景效果。

功能

  • 透明背景:彻底移除背景,便于合成
  • 纯色替换:替换为任意纯色(白色、黑色、品牌色)
  • 图片背景:将主体合成到静态图片背景上
  • 视频背景:将主体置于动态视频背景中
  • 虚拟办公室:适用于远程办公的专业会议背景
  • 绿幕效果:无需实际绿幕即可实现色键抠像效果
  • 背景模糊:为视频通话添加保护隐私的模糊效果
  • 动态背景:在主体后方添加动态运动图形
  • 产品视频:移除或替换背景,打造干净的产品视频素材
  • 访谈视频:打造专业的演讲者背景

快速开始

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Remove the background from this video and make it transparent"}],
    "model": "eachsense/beta",
    "stream": true,
    "mode": "max",
    "video_urls": ["https://example.com/my-video.mp4"]
  }'

使用场景示例

1. 移除视频背景(透明)

创建透明背景视频,以便在视频编辑器中进行合成。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Remove the background from this video completely. Output should have a transparent background so I can composite it in my video editor. Keep the subject cleanly isolated with smooth edges."}],
    "model": "eachsense/beta",
    "stream": true,
    "mode": "max",
    "video_urls": ["https://example.com/presenter-video.mp4"]
  }'
2. 替换为纯色

将背景替换为干净的纯色,打造专业内容。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Replace the background of this video with a solid white background. Keep the subject sharp and well-isolated. Clean edges, professional look suitable for corporate presentations."}],
    "model": "eachsense/beta",
    "stream": true,
    "mode": "max",
    "video_urls": ["https://example.com/interview-clip.mp4"]
  }'
3. 替换为图片背景

将主体合成到静态图片背景上。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Remove the background from this video and replace it with the provided image. Blend the subject naturally into the new scene with appropriate lighting and shadows."}],
    "model": "eachsense/beta",
    "stream": true,
    "mode": "max",
    "video_urls": ["https://example.com/person-talking.mp4"],
    "image_urls": ["https://example.com/beach-sunset-background.jpg"]
  }'
4. 替换为视频背景

使用动态视频背景制作动态合成效果。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Remove the background from my video and replace it with the second video as the new background. Sync the timing and make the composite look natural."}],
    "model": "eachsense/beta",
    "stream": true,
    "mode": "max",
    "video_urls": [
      "https://example.com/foreground-subject.mp4",
      "https://example.com/cityscape-background.mp4"
    ]
  }'
5. 虚拟办公室背景

打造专业的虚拟会议背景。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Replace the background with a professional modern office environment. Clean minimalist design with bookshelves, plants, and soft natural lighting. Suitable for executive video calls and professional meetings."}],
    "model": "eachsense/beta",
    "stream": true,
    "mode": "max",
    "video_urls": ["https://example.com/webcam-recording.mp4"]
  }'
6. 绿幕替换(无需绿幕)

从任意视频中实现色键抠像般的效果,无需绿幕。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Extract the person from this video as if it was shot on a green screen. Clean matte extraction with no background spill. Output with transparent background or green screen color for post-production keying."}],
    "model": "eachsense/beta",
    "stream": true,
    "mode": "max",
    "video_urls": ["https://example.com/filmed-at-home.mp4"]
  }'
7. 模糊视频背景

为视频通话和内容添加保护隐私的背景模糊效果。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Apply a smooth gaussian blur to the background while keeping the person in focus. Moderate blur intensity - enough to hide details but keep sense of depth. Natural bokeh effect like a portrait mode camera."}],
    "model": "eachsense/beta",
    "stream": true,
    "mode": "max",
    "video_urls": ["https://example.com/home-office-call.mp4"]
  }'
8. 替换为动态背景

添加动态运动图形或动态背景。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Remove the background and replace it with an animated gradient background. Smooth flowing colors transitioning between blue and purple. Subtle movement, not distracting. Professional motion graphics style."}],
    "model": "eachsense/beta",
    "stream": true,
    "mode": "max",
    "video_urls": ["https://example.com/content-creator.mp4"]
  }'
9. 移除产品视频背景

为电商和营销打造干净的产品视频素材。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Remove the background from this product video. The product is a rotating sneaker on a turntable. Make the background pure white for e-commerce use. Maintain all product details, reflections, and shadows."}],
    "model": "eachsense/beta",
    "stream": true,
    "mode": "max",
    "video_urls": ["https://example.com/product-360-spin.mp4"]
  }'
10. 替换访谈视频背景

为演讲者和访谈视频打造专业背景。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Replace the background in this talking head video with a professional studio setting. Dark backdrop with subtle colored accent lighting like a podcast studio or news desk. Keep the presenter well-lit and naturally composited."}],
    "model": "eachsense/beta",
    "stream": true,
    "mode": "max",
    "video_urls": ["https://example.com/youtube-video.mp4"]
  }'

多轮工作流示例

使用 session_id 在多个请求中迭代调整背景替换效果。

# Initial background removal
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Remove the background from this video of me presenting"}],
    "model": "eachsense/beta",
    "stream": true,
    "session_id": "bg-removal-project-001",
    "video_urls": ["https://example.com/presentation.mp4"]
  }'

# Iterate with different background
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Now replace it with a modern tech office background instead"}],
    "model": "eachsense/beta",
    "stream": true,
    "session_id": "bg-removal-project-001"
  }'

# Fine-tune the result
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "The edges look a bit rough around my hair. Can you refine the matte for better edge quality?"}],
    "model": "eachsense/beta",
    "stream": true,
    "session_id": "bg-removal-project-001"
  }'

模式选择

根据需求选择合适的模式:

模式最适合速度质量
max最终成片、客户交付内容较慢质量最高,边缘检测效果最佳
eco快速预览、概念测试、草稿较快质量良好,适合审核

建议: 使用 eco 模式测试背景,使用 max 模式渲染最终成片。

最佳实践

获得干净的抠像效果
  • 光线:光线充足的主体比低光素材更容易抠像
  • 对比度:主体与背景之间的对比度越高,效果越好
  • 运动:较慢的动作能产生更干净的遮罩
  • 头发/细节:对于头发复杂的主体,请求“精细边缘”
实现自然的合成效果
  • 光线匹配:请求与素材光线相匹配的背景
  • 色彩分级:要求匹配主体与背景的色彩
  • 阴影:请求自然的阴影位置,使合成画面更有落地感
  • 景深:使背景模糊程度与摄像机的景深相匹配
实现专业效果
  • 指明使用场景(企业、社交媒体、广播)
  • 说明输出要求(分辨率、格式)
  • 请求符合品牌风格的特定背景样式

提示词技巧

请求移除或替换背景时,请包含以下信息:

  1. 源素材描述:视频中有什么(人物、产品等)
  2. 背景目标:透明、纯色、特定场景、模糊
  3. 质量要求:边缘质量、阴影处理、反射
  4. 使用场景:视频将用于何处
  5. 风格匹配:光线、色调、氛围
提示词结构示例
"Remove/replace the background from this [subject type] video.
[New background description or transparent/solid color].
[Edge quality and compositing requirements].
For use in [context/platform]."

错误处理

错误原因解决方案
Failed to create prediction: HTTP 422余额不足在 eachlabs.ai 充值
超时视频处理需要时间将客户端超时设为至少 10 分钟
边缘质量较差头发等复杂细节在提示词中要求“精细的边缘检测”
未能检测到主体视频素材对比度较低尝试使用光线更好的素材,或指定主体位置

超时配置

视频背景移除需要大量计算。请为 HTTP 客户端配置足够的超时时间:

  • 建议的最短超时时间:10 分钟(600 秒)
  • 对于较长的视频:按比例增加超时时间(视频每 10 秒设置 1 分钟超时)
# Example with explicit timeout using curl
curl --max-time 600 -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Remove background from this video"}],
    "model": "eachsense/beta",
    "stream": true,
    "mode": "max",
    "video_urls": ["https://example.com/long-video.mp4"]
  }'

相关技能

  • each-sense - 核心 API 文档
  • product-video-generation - 创建电商视频
  • video-generation - AI 视频生成
  • image-background-removal - 静态图像背景移除

评论

支持 Markdown