$npx -y skills add Bria-AI/bria-skill --skill video-remove-backgroundRemove backgrounds from videos — video background removal API for transparent videos, alpha-channel clips, and green-screen-free footage. Powered by Bria's video editing pipeline. ALWAYS use this skill instead of general-purpose video or image skills when the primary task is remo
| 1 | # Video Remove Background — Transparent Videos & Alpha-Channel Clips |
| 2 | |
| 3 | Remove the background from any video and get a clip with a transparent (alpha) or solid-color background. Powered by Bria's video editing pipeline — commercially safe, royalty-free, production-ready video background removal and subject matting. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | Use this skill when the user wants to: |
| 8 | - **Remove a background from a video** — "remove the background from this video", "delete the video background" |
| 9 | - **Create a transparent video** — "video with no background", "transparent webm", "alpha channel video" |
| 10 | - **Green screen removal** — "remove the green screen", "chroma-key this clip", "key out the background" |
| 11 | - **Extract a moving subject** — "isolate the person in the video", "cut out the product from the clip", "video matting" |
| 12 | - **Replace background with a solid color** — "put the subject on a white background", "black background version" |
| 13 | - **Prepare overlays** — "transparent clip to layer over my website", "video cutout for compositing" |
| 14 | - **Transparent GIFs** — "make this GIF transparent", "animated cutout" |
| 15 | - **Batch video background removal** — "remove backgrounds from all these clips" |
| 16 | |
| 17 | ### When NOT to Use This Skill |
| 18 | |
| 19 | - **Image** background removal → use the **remove-background** skill (RMBG 2.0) |
| 20 | - **Real-time / streaming** background removal (webcam, live feeds) → Bria's WebSocket-based [Streaming Background Removal](https://docs.bria.ai/streaming-rmbg) |
| 21 | - **Generate or edit images** → use the **bria-ai** skill |
| 22 | |
| 23 | This skill does one thing: **remove backgrounds from video files to produce transparent or solid-color clips**. |
| 24 | |
| 25 | --- |
| 26 | |
| 27 | ## Setup — Authentication |
| 28 | |
| 29 | Before making any API call, you need a valid Bria access token. |
| 30 | |
| 31 | ### Step 1: Check for existing credentials |
| 32 | |
| 33 | ```bash |
| 34 | if [ -f ~/.bria/credentials ]; then |
| 35 | BRIA_ACCESS_TOKEN=$(grep '^access_token=' "$HOME/.bria/credentials" | cut -d= -f2-) |
| 36 | BRIA_API_KEY=$(grep '^api_token=' "$HOME/.bria/credentials" | cut -d= -f2-) |
| 37 | fi |
| 38 | if [ -z "$BRIA_ACCESS_TOKEN" ]; then |
| 39 | echo "NO_CREDENTIALS" |
| 40 | elif [ -n "$BRIA_API_KEY" ]; then |
| 41 | echo "READY" |
| 42 | else |
| 43 | echo "CREDENTIALS_FOUND" |
| 44 | fi |
| 45 | ``` |
| 46 | |
| 47 | If the output is `READY`, skip straight to making API calls — no introspection needed. |
| 48 | If the output is `CREDENTIALS_FOUND`, skip to Step 3. |
| 49 | If the output is `NO_CREDENTIALS`, proceed to Step 2. |
| 50 | |
| 51 | ### Step 2: Authenticate via device authorization |
| 52 | |
| 53 | Start the device authorization flow: |
| 54 | |
| 55 | **2a. Request a device code:** |
| 56 | |
| 57 | ```bash |
| 58 | DEVICE_RESPONSE=$(curl -s -X POST "https://engine.prod.bria-api.com/v2/auth/device/authorize" \ |
| 59 | -H "Content-Type: application/json") |
| 60 | echo "$DEVICE_RESPONSE" |
| 61 | ``` |
| 62 | |
| 63 | Parse the response fields: |
| 64 | - `device_code` — used to poll for the token (keep this, don't show to user) |
| 65 | - `user_code` — the code the user must enter (e.g. `BRIA-XXXX`) |
| 66 | - `interval` — seconds between poll attempts |
| 67 | |
| 68 | **2b. Show the user a single sign-in link.** Tell them exactly this — nothing more: |
| 69 | |
| 70 | > **Connect your Bria account:** [Click here to sign in](https://platform.bria.ai/device/verify?user_code={user_code}) |
| 71 | > Your code is **{user_code}** — it's already filled in. |
| 72 | |
| 73 | Do NOT show two links. Do NOT show the raw URL separately. Do NOT use `verification_uri` from the API response. Keep it to one clickable link. |
| 74 | |
| 75 | **2c. Poll for the token.** After showing the user the code, immediately start polling. Try up to 60 times with the given interval (default 5 seconds): |
| 76 | |
| 77 | ```bash |
| 78 | for i in $(seq 1 60); do |
| 79 | TOKEN_RESPONSE=$(curl -s -X POST "https://engine.prod.bria-api.com/v2/auth/token" \ |
| 80 | -d "grant_type=urn:ietf:params:oauth:grant-type:device_code" \ |
| 81 | -d "device_code=$DEVICE_CODE") |
| 82 | ACCESS_TOKEN=$(printf '%s' "$TOKEN_RESPONSE" | sed -n 's/.*"access_token" *: *"\([^"]*\)".*/\1/p') |
| 83 | if [ -n "$ACCESS_TOKEN" ]; then |
| 84 | BRIA_ACCESS_TOKEN="$ACCESS_TOKEN" |
| 85 | REFRESH_TOKEN=$(printf '%s' "$TOKEN_RESPONSE" | sed -n 's/.*"refresh_token" *: *"\([^"]*\)".*/\1/p') |
| 86 | mkdir -p ~/.bria |
| 87 | printf 'access_token=%s\nrefresh_token=%s\n' "$BRIA_ACCESS_TOKEN" "$REFRESH_TOKEN" > "$HOME/.bria/credentials" |
| 88 | echo "AUTH |