Communitygithub.com

FilippTrigub/abra

使用 AI (透過 rembg 的 BiRefNet-general) 移除影片每一幀的背景。輸出具有透明背景的影片,或合成到純色或圖片上。需要至少 3 GB 可用 VRAM 的 CUDA GPU。

abra 是什麼?

此技能「keyer」能夠對影片進行 AI 背景移除,它利用 rembg 套件中的 BiRefNet-general 高品質去背模型,為影片的每一幀去除背景。此工具對於需要處理人物演講、產品展示等影片的使用者特別有用,可以將主體置於純色背景或自訂背景圖片上,同時保留原始音訊。它支援多種去背模型,包括通用最佳化的 birefnet-general、針對人物優化的 birefnet-portrait、更快速的 isnet-general-use,以及僅適用於人物的 u2net_human_seg。輸出方面,當不指定背景時,會產生帶有 yuv420p 編碼的 MP4 檔案(不支援真正的透明度);若要獲得真正的透明幀,建議輸出為 PNG 序列。此技能專為支援 CUDA 且具備至少 3 GB 可用 VRAM 的 GPU 設計,並提供了明確的錯誤處理機制,例如 VRAM 不足或缺少 CUDA 支援時的提示。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/FilippTrigub/abra/tree/HEAD/skills/video-matte

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

keyer — AI 影片背景移除

使用 BiRefNet-general(透過 rembg 的高品質去背模型)移除影片每一幀的背景。可選擇合成到純色或背景圖片上。音訊會保留。

此技能目錄(即此 SKILL.md 所在位置)在下文中簡稱為 $SKILL_DIR。

需要 GPU。 需要可用 VRAM ≥ 3 GB 的 CUDA GPU。 若 LLM 上下文佔用了 VRAM,請先暫停它再執行。


使用時機

當使用者想要進行以下操作時,使用此技能:

  • 移除影片的背景(人物演講、產品展示等)
  • 將主體置於純色或品牌背景上
  • 匯出帶有透明背景的影片(Alpha 通道 PNG 幀)

設定(僅首次執行)

cd "$SKILL_DIR" && uv sync

BiRefNet 模型權重會在首次執行時自動下載(約 500 MB)。


代理工作流程

1. 詢問使用者

在移除背景之前,我需要知道:

🎭 背景替換
  - null          — 保留透明 Alpha 通道(PNG 幀;mp4 無 Alpha)
  - #hex 顏色    — 例如 "#1a1a2e" 為深海軍藍
  - /path/to/bg  — 合成到背景圖片檔案上

🧠 模型
  - birefnet-general   — 最佳通用品質  [預設]
  - birefnet-portrait  — 針對人物最佳化
  - isnet-general-use  — 更快的替代方案
  - u2net_human_seg    — 快速,僅限人物

📁 輸入 / 輸出目錄  (預設:./input 和 ./output)

等待使用者回覆後再繼續。

2. 編輯 config.json

根據使用者的選擇,寫入或更新 $SKILL_DIR/config.json。

3. 執行

cd "$SKILL_DIR" && uv run python scripts/matte.py --config config.json

4. 報告結果

告知使用者輸出檔案路徑以及使用的背景模式。


設定參考

鍵值預設值說明
input_dirpath./input包含輸入影片的資料夾
output_dirpath./output目標資料夾
model見上方birefnet-general去背模型
bgnull / hex / pathnull背景替換

常用指令

# 預設:移除背景,透明輸出
cd "$SKILL_DIR" && uv run python scripts/matte.py

# 深色背景合成
cd "$SKILL_DIR" && uv run python scripts/matte.py --bg "#0d0d0d"

# 合成到圖片上
cd "$SKILL_DIR" && uv run python scripts/matte.py --bg /path/to/studio_bg.jpg

# 人物最佳化模型
cd "$SKILL_DIR" && uv run python scripts/matte.py --model birefnet-portrait

# 無背景(透過 CLI 傳入字串 "null")
cd "$SKILL_DIR" && uv run python scripts/matte.py --bg null

輸出

每個輸入影片會在 output_dir 中產生一個同名的輸出 .mp4 檔案。若 bg=null,輸出會以 yuv420p 編碼(mp4 中無真正的透明度);若要獲得真正的透明幀,請執行 clawimig 或匯出為 PNG 序列。


錯誤處理

  • VRAM 不足 → 顯示所需與可用 GB,提供釋放 VRAM 的提示,然後退出
  • 無 CUDA GPU 或缺少 ONNX CUDAExecutionProvider → 顯示明確錯誤訊息,然後退出
  • input_dir 中無影片 → 顯示簡潔訊息,然後退出
  • 個別影片錯誤 → 記錄錯誤;其他影片繼續處理

Individual skills in this repo

This repo contains 7 individual skills — each has its own dedicated page.

FilippTrigub/abra

>- Animate a still image into a short video clip using fal.ai's LTX-2.3 Fast image-to-video model in the cloud. No GPU required - runs entirely on fal.ai serverless infrastructure.

FilippTrigub/abra

>- Auto-describe and caption images using a local vision-language model. Writes a JSON sidecar per image containing a one-sentence description, a suggested Instagram caption with hashtags, and detected content tags.

FilippTrigub/abra

>- Animated caption pipeline. Use this skill when the user wants to burn word-by-word animated captions into videos — using Whisper for transcription and pycaps for rendering. Supports default minimalist style or a futuristic CSS theme with alternating gold/magenta glowing words.

FilippTrigub/abra

>- Cut videos into segments, rearrange them, and produce an output video with a specific cuts-per-second rate. Uses MoviePy for video manipulation. Prioritizes audio transcription for timestamped cutting, falls back to adaptive scene detection.

FilippTrigub/abra

>- Edit a region of a video using a text prompt via Wan2.1-VACE inpainting. Supports two modes: background (auto-segment via rembg) or region (rectangle defined by fractions). Requires a CUDA GPU with at least 8 GB free VRAM.

FilippTrigub/abra

>- Video enhancement pipeline. Use this skill when the user wants to sharpen, colour grade, warm, or normalise the audio of videos — including presets for natural, cinematic, or vivid looks.

FilippTrigub/abra

Generate videos from text or images using Higgsfield's multi-model cloud platform. Supports kling, seedance, dop, and dop-preview models. Uses a small preset layer for common creative styles. Auto-detects text-to-video or image-to-video based on input. No GPU required.

相關技能