> ## Documentation Index
> Fetch the complete documentation index at: https://docs.videobgremover.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Video Background Removal Examples

> Ready-to-use code examples for video background removal. Complete Node.js, Python, and cURL examples with step-by-step workflows and best practices.

## Basic Examples

### Simple Background Replacement

Remove background and overlay on a colored background.

```typescript Node.js theme={"dark"}
// 1. Remove background from video
import { VideoBGRemoverClient, Video, Background, Composition, EncoderProfile, Anchor, SizeMode } from '@videobgremover/sdk'

const client = new VideoBGRemoverClient('your_api_key')
const video = Video.open('input.mp4')
const transparent = await video.removeBackground({ client })

// 2. Add to colored background
const background = Background.fromColor('#FF6B35', 1920, 1080, 30)
const comp = new Composition(background)
comp.add(transparent, 'main').at(Anchor.CENTER).size(SizeMode.CONTAIN)

// 3. Export
await comp.toFile('output.mp4', EncoderProfile.h264())
console.log('✅ Background replaced!')
```

```python Python theme={"dark"}
# 1. Remove background from video
from videobgremover import VideoBGRemoverClient, Video, Background, Composition, EncoderProfile, Anchor, SizeMode

client = VideoBGRemoverClient('your_api_key')
video = Video.open('input.mp4')
transparent = video.remove_background(client)

# 2. Add to colored background
background = Background.from_color('#FF6B35', 1920, 1080, 30)
comp = Composition(background)
comp.add(transparent, 'main').at(Anchor.CENTER).size(SizeMode.CONTAIN)

# 3. Export
comp.to_file('output.mp4', EncoderProfile.h264())
print('✅ Background replaced!')
```

## AI UGC Ads

### AI Avatar on Video Background

Create professional UGC ads with AI avatars positioned bottom-right.

```typescript Node.js theme={"dark"}
import {
  VideoBGRemoverClient, Video, Background, Composition,
  EncoderProfile, Anchor, SizeMode, RemoveBGOptions, Prefer
} from '@videobgremover/sdk'

async function createAIUGCAd() {
  // 1. Remove background from AI actor
  const client = new VideoBGRemoverClient('your_api_key')
  const aiActor = Video.open('ai_actor_video.mp4')

  const options = new RemoveBGOptions(Prefer.WEBM_VP9)
  const transparentActor = await aiActor.removeBackground({ client, options })

  // 2. Create video background
  const background = Background.fromVideo('product_showcase.mp4')
  const comp = new Composition(background)

  // 3. Position AI avatar bottom-right (35% of canvas)
  comp.add(transparentActor, 'ai_avatar')
    .at(Anchor.BOTTOM_RIGHT, -50, -50)  // 50px from edges
    .size(SizeMode.CANVAS_PERCENT, { percent: 35 })
    .opacity(0.95)  // Slight transparency for polish

  // 4. Export for ads
  await comp.toFile('ai_ugc_ad.mp4', EncoderProfile.h264({
    crf: 20,
    preset: 'medium'
  }))

  console.log('✅ AI UGC ad created: ai_ugc_ad.mp4')
}

createAIUGCAd()
```

```python Python theme={"dark"}
from videobgremover import (
    VideoBGRemoverClient, Video, Background, Composition,
    EncoderProfile, Anchor, SizeMode, RemoveBGOptions, Prefer
)

def create_ai_ugc_ad():
    # 1. Remove background from AI actor
    client = VideoBGRemoverClient('your_api_key')
    ai_actor = Video.open('ai_actor_video.mp4')

    options = RemoveBGOptions(prefer=Prefer.WEBM_VP9)
    transparent_actor = ai_actor.remove_background(client, options)

    # 2. Create video background
    background = Background.from_video('product_showcase.mp4')
    comp = Composition(background)

    # 3. Position AI avatar bottom-right (35% of canvas)
    comp.add(transparent_actor, 'ai_avatar') \
        .at(Anchor.BOTTOM_RIGHT, dx=-50, dy=-50) \
        .size(SizeMode.CANVAS_PERCENT, percent=35) \
        .opacity(0.95)

    # 4. Export for ads
    comp.to_file('ai_ugc_ad.mp4', EncoderProfile.h264(crf=20, preset='medium'))

    print('✅ AI UGC ad created: ai_ugc_ad.mp4')

create_ai_ugc_ad()
```

## Dynamic Social Media Content

### Interactive Positioning with Transparency Effects

Create engaging social media content with moving elements and transparency changes.

```typescript Node.js theme={"dark"}
async function createDynamicSocialContent() {
  // 1. Process content video
  const client = new VideoBGRemoverClient('your_api_key')
  const contentVideo = Video.open('dynamic_content.mp4')
  const transparent = await contentVideo.removeBackground({ client })

  // 2. Create vertical background video (9:16 for social)
  const background = Background.fromVideo('trending_background.mp4')
  const comp = new Composition(background)

  // 3. Dynamic positioning sequence
  // 0-3s: Bottom-right with transparency
  comp.add(transparent.subclip(0, 3), 'phase1')
    .start(0).duration(3)
    .at(Anchor.BOTTOM_RIGHT, -30, -30)
    .size(SizeMode.CANVAS_PERCENT, { percent: 40 })
    .alpha(true)
    .opacity(0.8)

  // 3-6s: Top-left without transparency
  comp.add(transparent.subclip(3, 6), 'phase2')
    .start(3).duration(3)
    .at(Anchor.TOP_LEFT, 30, 30)
    .size(SizeMode.CANVAS_PERCENT, { percent: 35 })
    .alpha(false)
    .opacity(1.0)

  // 6-9s: Center with partial transparency
  comp.add(transparent.subclip(6, 9), 'phase3')
    .start(6).duration(3)
    .at(Anchor.CENTER)
    .size(SizeMode.CANVAS_PERCENT, { percent: 50 })
    .alpha(true)
    .opacity(0.6)

  // 9-12s: Bottom-left with full transparency
  comp.add(transparent.subclip(9, 12), 'phase4')
    .start(9).duration(3)
    .at(Anchor.BOTTOM_LEFT, 30, -30)
    .size(SizeMode.CANVAS_PERCENT, { percent: 45 })
    .alpha(true)
    .opacity(0.9)

  // 4. Export for social media
  await comp.toFile('dynamic_social_content.mp4', EncoderProfile.h264({
    crf: 25,
    preset: 'fast'
  }))

  console.log('✅ Dynamic social content created')
}

createDynamicSocialContent()
```

```python Python theme={"dark"}
def create_dynamic_social_content():
    # 1. Process content video
    client = VideoBGRemoverClient('your_api_key')
    content_video = Video.open('dynamic_content.mp4')
    transparent = content_video.remove_background(client)

    # 2. Create vertical background video
    background = Background.from_video('trending_background.mp4')
    comp = Composition(background)

    # 3. Dynamic positioning sequence
    # 0-3s: Bottom-right with transparency
    comp.add(transparent.subclip(0, 3), 'phase1') \
        .start(0).duration(3) \
        .at(Anchor.BOTTOM_RIGHT, dx=-30, dy=-30) \
        .size(SizeMode.CANVAS_PERCENT, percent=40) \
        .alpha(enabled=True) \
        .opacity(0.8)

    # 3-6s: Top-left without transparency
    comp.add(transparent.subclip(3, 6), 'phase2') \
        .start(3).duration(3) \
        .at(Anchor.TOP_LEFT, dx=30, dy=30) \
        .size(SizeMode.CANVAS_PERCENT, percent=35) \
        .alpha(enabled=False) \
        .opacity(1.0)

    # 6-9s: Center with partial transparency
    comp.add(transparent.subclip(6, 9), 'phase3') \
        .start(6).duration(3) \
        .at(Anchor.CENTER) \
        .size(SizeMode.CANVAS_PERCENT, percent=50) \
        .alpha(enabled=True) \
        .opacity(0.6)

    # 9-12s: Bottom-left with full transparency
    comp.add(transparent.subclip(9, 12), 'phase4') \
        .start(9).duration(3) \
        .at(Anchor.BOTTOM_LEFT, dx=30, dy=-30) \
        .size(SizeMode.CANVAS_PERCENT, percent=45) \
        .alpha(enabled=True) \
        .opacity(0.9)

    # 4. Export for social media
    comp.to_file('dynamic_social_content.mp4', EncoderProfile.h264(
        crf=25, preset='fast'
    ))

    print('✅ Dynamic social content created')

create_dynamic_social_content()
```

## Next Steps

> [card] [📖 API Reference](https://docs.videobgremover.com/api-reference/introduction.md)
>
> Complete API documentation for all classes and methods

> [card] [🎬 Background Removal Guide](https://docs.videobgremover.com/video-background-removal/guide.md)
>
> Detailed guide to background removal options and formats

> [card] [🎨 Video Composition Guide](https://docs.videobgremover.com/video-composition/overview.md)
>
> Learn advanced composition techniques and effects


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.