> ## 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 Timing & Duration Control | Remove Video Background

> Master video timing control with start times, durations, and source trimming. Learn composition duration rules, layer sequencing, and dynamic videos.

## Timeline Control

Control exactly when your video layers appear and disappear in your composition. The timing system has two levels:

> [card] 📹 Source Timing
>
> **Which part** of the source video to use (trimming)

> [card] 🎬 Composition Timing
>
> **When to show** the layer in the final video

## Composition Timeline

Control when layers appear in your final video:

### Start Time

Set when a layer begins appearing:

```typescript Node.js theme={"dark"}
// Layer appears at 2 seconds
comp.add(transparent).start(2.0)

// Layer appears immediately (default)
comp.add(transparent).start(0.0)
```

```python Python theme={"dark"}
# Layer appears at 2 seconds
comp.add(transparent).start(2.0)

# Layer appears immediately (default)
comp.add(transparent).start(0.0)
```

### Duration Control

Control how long layers are visible:

```typescript Node.js theme={"dark"}
// Show for exactly 5 seconds
comp.add(transparent).start(2.0).duration(5.0)
// Appears at 2s, disappears at 7s

// Show from 10s to 15s
comp.add(transparent).start(10.0).end(15.0)
// Appears at 10s, disappears at 15s

// Show from start time until end of composition
comp.add(transparent).start(5.0)
// Appears at 5s, continues until composition ends
```

```python Python theme={"dark"}
# Show for exactly 5 seconds
comp.add(transparent).start(2.0).duration(5.0)
# Appears at 2s, disappears at 7s

# Show from 10s to 15s
comp.add(transparent).start(10.0).end(15.0)
# Appears at 10s, disappears at 15s

# Show from start time until end of composition
comp.add(transparent).start(5.0)
# Appears at 5s, continues until composition ends
```

## Source Trimming

Use only specific parts of your source videos:

```typescript Node.js theme={"dark"}
// Use seconds 5-10 of the source video
const trimmed = transparent.subclip(5, 10)
comp.add(trimmed)

// Use from 3 seconds to end of source
const fromMiddle = transparent.subclip(3)
comp.add(fromMiddle)

// Or trim directly in composition
comp.add(transparent).subclip(2, 8)
```

```python Python theme={"dark"}
# Use seconds 5-10 of the source video
trimmed = transparent.subclip(5, 10)
comp.add(trimmed)

# Use from 3 seconds to end of source
from_middle = transparent.subclip(3)
comp.add(from_middle)

# Or trim directly in composition
comp.add(transparent).subclip(2, 8)
```

## Combined Timing

You can combine source trimming with composition timing:

```typescript Node.js theme={"dark"}
// Use seconds 1-4 of source (3 seconds of content)
// Show it at 10-13 seconds in the final video
comp.add(transparent)
  .subclip(1, 4)      // Source: use 1-4s (3s of content)
  .start(10)          // Composition: show at 10s
  .duration(3)        // Composition: show for 3s (10-13s)
```

```python Python theme={"dark"}
# Use seconds 1-4 of source (3 seconds of content)
# Show it at 10-13 seconds in the final video
comp.add(transparent) \
    .subclip(1, 4) \     # Source: use 1-4s (3s of content)
    .start(10) \         # Composition: show at 10s
    .duration(3)         # Composition: show for 3s (10-13s)
```

## Staggered Animations

Create dynamic sequences with layers appearing at different times:

```typescript Node.js theme={"dark"}
const videos = [transparent1, transparent2, transparent3, transparent4]
const positions = [
  Anchor.TOP_LEFT, Anchor.TOP_RIGHT,
  Anchor.BOTTOM_LEFT, Anchor.BOTTOM_RIGHT
]

videos.forEach((vid, i) => {
  comp.add(vid)
    .at(positions[i], 50, 50)
    .size(SizeMode.CANVAS_PERCENT, { percent: 40 })
    .start(i * 2)        // Start every 2 seconds: 0s, 2s, 4s, 6s
    .duration(6)         // Each visible for 6 seconds
    .opacity(0.8)
})
```

```python Python theme={"dark"}
videos = [transparent1, transparent2, transparent3, transparent4]
positions = [
    Anchor.TOP_LEFT, Anchor.TOP_RIGHT,
    Anchor.BOTTOM_LEFT, Anchor.BOTTOM_RIGHT
]

for i, (vid, pos) in enumerate(zip(videos, positions)):
    comp.add(vid) \
        .at(pos, dx=50, dy=50) \
        .size(SizeMode.CANVAS_PERCENT, percent=40) \
        .start(i * 2) \      # Start every 2 seconds: 0s, 2s, 4s, 6s
        .duration(6) \       # Each visible for 6 seconds
        .opacity(0.8)
```

## Audio Timing

Control audio from your layers:

```typescript Node.js theme={"dark"}
// Layer with full audio
comp.add(transparent1)
  .start(0)
  .audio(true, 1.0)  // Full volume

// Layer with reduced audio
comp.add(transparent2)
  .start(5)
  .audio(true, 0.3)  // 30% volume

// Silent layer
comp.add(transparent3)
  .start(10)
  .audio(false)      // No audio
```

```python Python theme={"dark"}
# Layer with full audio
comp.add(transparent1) \
    .start(0) \
    .audio(enabled=True, volume=1.0)  # Full volume

# Layer with reduced audio
comp.add(transparent2) \
    .start(5) \
    .audio(enabled=True, volume=0.3)  # 30% volume

# Silent layer
comp.add(transparent3) \
    .start(10) \
    .audio(enabled=False)             # No audio
```

## Duration Rules

Understanding how composition duration is determined:

### Rule 1: Video Background Controls Duration

When you use a video background, it determines the final length:

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

// Final video will be 30 seconds
```

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

# Final video will be 30 seconds
```

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

Color and image backgrounds adapt to your content:

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

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

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

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

### Rule 3: Explicit Duration Override

You can always force a specific duration:

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

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

```python Python theme={"dark"}
comp = Composition(any_background)
comp.set_duration(20.0)  # Force 20-second duration
comp.add(transparent)

# Final video will be exactly 20 seconds
```

## Source Trimming

Use only specific parts of your source videos:

### Basic Trimming

```typescript Node.js theme={"dark"}
// Method 1: Trim the foreground before adding
const trimmed = video.subclip(10, 20)  // Use seconds 10-20
comp.add(trimmed, 'segment')

// Method 2: Trim in the composition
comp.add(transparent).subclip(10, 20)

// Method 3: Open-ended trim (from 5s to end)
comp.add(transparent).subclip(5)
```

```python Python theme={"dark"}
# Method 1: Trim the foreground before adding
trimmed = transparent.subclip(10, 20)  # Use seconds 10-20
comp.add(trimmed, 'segment')

# Method 2: Trim in the composition
comp.add(transparent).subclip(10, 20)

# Method 3: Open-ended trim (from 5s to end)
comp.add(transparent).subclip(5)
```

### Advanced Trimming

```typescript Node.js theme={"dark"}
// Multiple segments from same source
comp.add(transparent).subclip(0, 3).start(0)      // 0-3s of source at 0s
comp.add(transparent).subclip(10, 15).start(5)   // 10-15s of source at 5s
comp.add(transparent).subclip(25, 30).start(12)   // 25-30s of source at 12s

// Re-trimming (trim a trimmed video)
const firstTrim = transparent.subclip(5, 20)    // 5-20s of original
const secondTrim = firstTrim.subclip(2, 8) // 2-8s of first trim = 7-13s of original
```

```python Python theme={"dark"}
# Multiple segments from same source
comp.add(transparent).subclip(0, 3).start(0)       # 0-3s of source at 0s
comp.add(transparent).subclip(10, 15).start(5)    # 10-15s of source at 5s
comp.add(transparent).subclip(25, 30).start(12)    # 25-30s of source at 12s

# Re-trimming (trim a trimmed video)
first_trim = transparent.subclip(5, 20)     # 5-20s of original
second_trim = first_trim.subclip(2, 8) # 2-8s of first trim = 7-13s of original
```

## Audio Synchronization

Control audio timing with your video layers:

### Audio with Timing

```typescript Node.js theme={"dark"}
// Transparent video with audio that starts at 3 seconds
comp.add(transparent)
  .start(3.0)
  .audio(true, 1.0)  // Audio automatically delayed to match video

// Multiple audio sources with different timing
comp.add(transparent1).start(0).audio(true, 0.8)   // Main audio
comp.add(transparent2).start(5).audio(true, 0.3)      // Background music
comp.add(transparent3).start(10).audio(true, 0.5)   // Sound effects
```

```python Python theme={"dark"}
# Transparent video with audio that starts at 3 seconds
comp.add(transparent) \
    .start(3.0) \
    .audio(enabled=True, volume=1.0)  # Audio automatically delayed to match video

# Multiple audio sources with different timing
comp.add(transparent1).start(0).audio(enabled=True, volume=0.8)   # Main audio
comp.add(transparent2).start(5).audio(enabled=True, volume=0.3)      # Background music
comp.add(transparent3).start(10).audio(enabled=True, volume=0.5)   # Sound effects
```

### Audio Mixing

The system automatically mixes audio from multiple layers:

* **Single audio source**: Used directly
* **Multiple audio sources**: Mixed with volume control
* **Timing**: Audio delays automatically match video timing

## Performance Tips

### Optimize for Speed

* **Shorter segments**: Trim videos to only needed parts
* **Reasonable overlaps**: Avoid too many overlapping layers
* **Fast encoding**: Use faster encoder presets for testing

### Memory Management

* **Large videos**: Consider trimming before composition
* **Many layers**: Test with fewer layers first
* **Long compositions**: Break into segments if needed

## What's Next?

> [card] [🎬 Export Your Video](https://docs.videobgremover.com/video-composition/export-formats.md)
>
> Choose the right export format and quality settings

> [card] [🍳 See Examples](https://docs.videobgremover.com/examples.md)
>
> Explore complete timing and animation examples


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