Skip to main content

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.

Timeline Control

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

📹 Source Timing

Which part of the source video to use (trimming)

🎬 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:
// 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:
// 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:
// 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)

Combined Timing

You can combine source trimming with composition timing:
// 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:
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)
})

Audio Timing

Control audio from your layers:
// 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

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:
// 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

Rule 2: Color/Image Backgrounds Use Longest Foreground

Color and image backgrounds adapt to your content:
// 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)

Rule 3: Explicit Duration Override

You can always force a specific duration:
const comp = new Composition(anyBackground)
comp.setDuration(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

// 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)

Advanced Trimming

// 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

Audio Synchronization

Control audio timing with your video layers:

Audio with Timing

// 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

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?

🎬 Export Your Video

Choose the right export format and quality settings

🍳 See Examples

Explore complete timing and animation examples