> ## 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.

# Custom Video Backgrounds for video compositions

> Create custom backgrounds for video compositions. Complete guide for color, image, and video backgrounds in multi-layer video editing workflows.

## Background Types

Choose the type of background that fits your creative vision:

> [card] 🎨 Color
>
> **Solid colors** using hex codes

> [card] 🖼️ Image
>
> **Static images** (automatically looped)

> [card] 🎬 Video
>
> **Dynamic videos** as moving backgrounds

## Color Backgrounds

Perfect for clean, professional looks or chroma key workflows.

```typescript Node.js theme={"dark"}
import { Background } from '@videobgremover/sdk'

// Solid color backgrounds
const red = Background.fromColor('#FF0000', 1920, 1080, 30)
const green = Background.fromColor('#00FF00', 1920, 1080, 30) // Chroma key
const blue = Background.fromColor('#0000FF', 1920, 1080, 30)
const white = Background.fromColor('#FFFFFF', 1920, 1080, 30)
const black = Background.fromColor('#000000', 1920, 1080, 30)

// Custom colors
const purple = Background.fromColor('#7C3AED', 1920, 1080, 30)
const orange = Background.fromColor('#FF6B35', 1920, 1080, 30)
```

```python Python theme={"dark"}
from videobgremover import Background

# Solid color backgrounds
red = Background.from_color('#FF0000', 1920, 1080, 30)
green = Background.from_color('#00FF00', 1920, 1080, 30)  # Chroma key
blue = Background.from_color('#0000FF', 1920, 1080, 30)
white = Background.from_color('#FFFFFF', 1920, 1080, 30)
black = Background.from_color('#000000', 1920, 1080, 30)

# Custom colors
purple = Background.from_color('#7C3AED', 1920, 1080, 30)
orange = Background.from_color('#FF6B35', 1920, 1080, 30)
```

### Popular Colors

| Color | Hex Code | Use Case |
| - | - | - |
| 🔴 Red | `#FF0000` | Bold, attention-grabbing |
| 🟢 Green | `#00FF00` | Chroma key standard |
| 🔵 Blue | `#0000FF` | Professional, clean |
| ⚪ White | `#FFFFFF` | Clean, minimal |
| ⚫ Black | `#000000` | Dramatic, cinematic |

## Image Backgrounds

Use static images that automatically loop to match your video duration.

```typescript Node.js theme={"dark"}
import { Background } from '@videobgremover/sdk'

// Image backgrounds (dimensions auto-detected)
const cityscape = Background.fromImage('cityscape.jpg', 30)
const nature = Background.fromImage('forest.png', 24)

// From URLs
const webImage = Background.fromImage('https://example.com/bg.jpg', 30)

// Different frame rates
const cinema = Background.fromImage('background.jpg', 24)   // Cinematic
const smooth = Background.fromImage('background.jpg', 60)   // Smooth
```

```python Python theme={"dark"}
from videobgremover import Background

# Image backgrounds (dimensions auto-detected)
cityscape = Background.from_image('cityscape.jpg', fps=30)
nature = Background.from_image('forest.png', fps=24)

# From URLs
web_image = Background.from_image('https://example.com/bg.jpg', fps=30)

# Different frame rates
cinema = Background.from_image('background.jpg', fps=24)   # Cinematic
smooth = Background.from_image('background.jpg', fps=60)   # Smooth
```

### Image Requirements

* **Formats**: JPG, PNG, WebP, TIFF
* **Resolution**: Any resolution (will be scaled to match composition)
* **Aspect ratio**: Any aspect ratio (consider your final video dimensions)

## Video Backgrounds

Use dynamic video backgrounds for more engaging compositions.

```typescript Node.js theme={"dark"}
import { Background } from '@videobgremover/sdk'

// Video backgrounds (dimensions and FPS auto-detected)
const nature = Background.fromVideo('nature_scene.mp4')
const abstract = Background.fromVideo('abstract_motion.mov')

// From URLs
const streaming = Background.fromVideo('https://example.com/bg_video.mp4')

// With audio control
const silent = Background.fromVideo('music_video.mp4').audio(false)
const quiet = Background.fromVideo('ambient.mp4').audio(true, 0.3) // 30% volume
```

```python Python theme={"dark"}
from videobgremover import Background

# Video backgrounds (dimensions and FPS auto-detected)
nature = Background.from_video('nature_scene.mp4')
abstract = Background.from_video('abstract_motion.mov')

# From URLs
streaming = Background.from_video('https://example.com/bg_video.mp4')

# With audio control
silent = Background.from_video('music_video.mp4').audio(enabled=False)
quiet = Background.from_video('ambient.mp4').audio(enabled=True, volume=0.3)
```

### Video Background Features

* **Duration control**: Video backgrounds determine the final composition length
* **Audio support**: Include or exclude background audio
* **Trimming**: Use only part of the background video
* **Auto-detection**: Dimensions and frame rate detected automatically

### Trimming Video Backgrounds

Use only part of a video as background:

```typescript Node.js theme={"dark"}
// Use seconds 10-30 of background video
const trimmed = Background.fromVideo('long_video.mp4').subclip(10, 30)

// Use from 5 seconds to end
const fromMiddle = Background.fromVideo('video.mp4').subclip(5)
```

```python Python theme={"dark"}
# Use seconds 10-30 of background video
trimmed = Background.from_video('long_video.mp4').subclip(10, 30)

# Use from 5 seconds to end
from_middle = Background.from_video('video.mp4').subclip(5)
```

## Background Audio

Control audio from video backgrounds:

```typescript Node.js theme={"dark"}
// Enable background audio (default for video backgrounds)
const withAudio = Background.fromVideo('music.mp4').audio(true, 1.0)

// Disable background audio
const silent = Background.fromVideo('music.mp4').audio(false)

// Reduce background audio volume
const quiet = Background.fromVideo('music.mp4').audio(true, 0.2) // 20% volume
```

```python Python theme={"dark"}
# Enable background audio (default for video backgrounds)
with_audio = Background.from_video('music.mp4').audio(enabled=True, volume=1.0)

# Disable background audio
silent = Background.from_video('music.mp4').audio(enabled=False)

# Reduce background audio volume
quiet = Background.from_video('music.mp4').audio(enabled=True, volume=0.2)
```

## Duration Rules

Understanding how background types affect composition duration:

### Rule 1: Video Backgrounds Control Duration

When you use a video background, the final composition duration matches the background video:

```typescript Node.js theme={"dark"}
// 30-second background video = 30-second final composition
const bg = Background.fromVideo('30_second_video.mp4')
const comp = new Composition(bg)
comp.add(shortForeground) // Even if foreground is 5 seconds

// Final video will be 30 seconds (background duration)
```

```python Python theme={"dark"}
# 30-second background video = 30-second final composition
bg = Background.from_video('30_second_video.mp4')
comp = Composition(bg)
comp.add(short_foreground)  # Even if foreground is 5 seconds

# Final video will be 30 seconds (background duration)
```

### Rule 2: Color/Image Backgrounds Use Foreground Duration

Color and image backgrounds adapt to your foreground duration:

```typescript Node.js theme={"dark"}
// Color background adapts to foreground
const bg = Background.fromColor('#FF0000', 1920, 1080, 30)
const comp = new Composition(bg)
comp.add(tenSecondForeground) // 10-second foreground

// Final video will be 10 seconds (foreground duration)
```

```python Python theme={"dark"}
# Color background adapts to foreground
bg = Background.from_color('#FF0000', 1920, 1080, 30)
comp = Composition(bg)
comp.add(ten_second_foreground)  # 10-second foreground

# Final video will be 10 seconds (foreground duration)
```

### Rule 3: Explicit Duration Override

You can always override with explicit duration:

```typescript Node.js theme={"dark"}
const comp = new Composition(anyBackground)
comp.setDuration(15.0) // Force 15-second duration
comp.add(foreground)

// Final video will be exactly 15 seconds
```

```python Python theme={"dark"}
comp = Composition(any_background)
comp.set_duration(15.0)  # Force 15-second duration
comp.add(foreground)

# Final video will be exactly 15 seconds
```

## Examples

### Professional Interview Setup

```typescript Node.js theme={"dark"}
// Clean corporate background
const bg = Background.fromColor('#1E293B', 1920, 1080, 30) // Dark blue
const comp = new Composition(bg)

comp.add(interviewSubject, 'person')
  .at(Anchor.CENTER_RIGHT, -100)
  .size(SizeMode.CANVAS_PERCENT, { percent: 60 })

comp.add(companyLogo, 'logo')
  .at(Anchor.BOTTOM_LEFT, 50, -50)
  .size(SizeMode.CANVAS_PERCENT, { percent: 15 })
  .opacity(0.8)
```

```python Python theme={"dark"}
# Clean corporate background
bg = Background.from_color('#1E293B', 1920, 1080, 30)  # Dark blue
comp = Composition(bg)

comp.add(interview_subject, 'person') \
    .at(Anchor.CENTER_RIGHT, dx=-100) \
    .size(SizeMode.CANVAS_PERCENT, percent=60)

comp.add(company_logo, 'logo') \
    .at(Anchor.BOTTOM_LEFT, dx=50, dy=-50) \
    .size(SizeMode.CANVAS_PERCENT, percent=15) \
    .opacity(0.8)
```

### Creative Video-on-Video

```typescript Node.js theme={"dark"}
// Dynamic video background
const bg = Background.fromVideo('city_timelapse.mp4')
const comp = new Composition(bg)

comp.add(dancer, 'performer')
  .at(Anchor.CENTER)
  .size(SizeMode.CONTAIN)
  .opacity(0.9)

// Background video controls duration automatically
```

```python Python theme={"dark"}
# Dynamic video background
bg = Background.from_video('city_timelapse.mp4')
comp = Composition(bg)

comp.add(dancer, 'performer') \
    .at(Anchor.CENTER) \
    .size(SizeMode.CONTAIN) \
    .opacity(0.9)

# Background video controls duration automatically
```

## Next Steps

> [card] [📐 Position Your Videos](https://docs.videobgremover.com/video-composition/positioning.md)
>
> Learn precise positioning and sizing techniques

> [card] [⏰ Control Timing](https://docs.videobgremover.com/video-composition/timing.md)
>
> Create timed sequences and animations


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