Skip to main content

绿幕视频背景扣除 CLI 工具 — 使用 rembg AI 模型逐帧去除视频背景,输出带透明通道的 VP8 WebM 视频

Project description

rmbg-video

使用 rembg AI 模型逐帧去除视频背景,输出带透明通道的 VP8 WebM 视频,保留原音频。

系统要求

  • Python >= 3.9
  • ffmpeg 和 ffprobe 已安装并在 PATH 中

安装

pip install rmbg-video

使用方式

# 基本用法
rmbg-video input.mp4
rmbg-video input.mp4 output.webm

# 选择模型
rmbg-video input.mp4 --model u2net

# 调节质量 (0-63,越小越好)
rmbg-video input.mp4 --crf 5

# 输出不含透明通道的普通 WebM
rmbg-video input.mp4 --no-alpha

# 跳过音频处理
rmbg-video input.mp4 --no-audio

# 强制使用 CPU
rmbg-video input.mp4 --no-gpu

# 保留临时文件用于调试
rmbg-video input.mp4 --keep-temp

选项

选项 默认值 说明
--model isnet-general-use rembg 模型名
--no-alpha-matting 禁用 alpha matting(更快但边缘较硬)
--fg-threshold 240 前景阈值
--bg-threshold 10 背景阈值
--erode-size 10 腐蚀尺寸
--post-process-mask 对遮罩做后处理平滑
--crf 10 VP8 质量 0-63(越小越好)
--speed good 编码速度预设 (good/best/realtime)
--no-alpha 输出不含透明通道的普通 WebM
--no-audio 跳过音频处理
--keep-temp 保留临时文件用于调试
--ffmpeg-path 自动检测 ffmpeg 可执行文件路径
--no-gpu 强制使用 CPU

工作原理

  1. 使用 ffmpeg 管道流式解码视频为原始 RGBA 帧
  2. 通过 rembg AI 模型逐帧去除背景,应用 alpha matting 平滑边缘
  3. 通过 ffmpeg 管道编码为 VP8 + yuva420p 像素格式(支持透明通道)
  4. 提取原音频为 Opus 编码,与视频流合并输出最终 WebM

许可证

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rmbg_video-1.0.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rmbg_video-1.0.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file rmbg_video-1.0.0.tar.gz.

File metadata

  • Download URL: rmbg_video-1.0.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rmbg_video-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0b018a9306a4168fbc3f1cc2b36dc8a01910c1bcbfec9f3e1b346e617a47c543
MD5 18751c92f6185edf47126f25b948713a
BLAKE2b-256 ce7c006aac655b253e3f7874f3486423532d5caf698a8274ef161558753d1419

See more details on using hashes here.

Provenance

The following attestation bundles were made for rmbg_video-1.0.0.tar.gz:

Publisher: python-publish.yml on jijinggang/rmbg-video

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rmbg_video-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: rmbg_video-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rmbg_video-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a6281e3bd80d2ae8f741fe807c06ffaa537dc1125e0e44417c7f84427d3d726
MD5 197ed91ab15b9342e5bbd848cbba481f
BLAKE2b-256 768a2f4d0304259bcbe2cb88bf3b667fa511e5a46663356bf9473fa9a6f8efbd

See more details on using hashes here.

Provenance

The following attestation bundles were made for rmbg_video-1.0.0-py3-none-any.whl:

Publisher: python-publish.yml on jijinggang/rmbg-video

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page