Why Code-First Video Editing?
Traditional video editors are built for one-off productions. But what if you need to:- Generate 100 personalized videos from a template
- Build a TikTok content pipeline that runs daily
- Create video variations for A/B testing
- Automate highlight reels from live streams
- Reusability – One video asset, infinite variations
- Scalability – Loop over data to generate hundreds of videos
- Version control – Git-track your compositions
- Automation – Integrate with AI, databases, APIs
The 4-Layer Architecture
VideoDB Editor uses a hierarchy where each layer has one job. Understanding this structure is the key to mastering composition: Asset → Clip → Track → Timeline
Installing VideoDB in your environment
VideoDB is available as a Python package and Node.js package.
Layer 1: Assets – Your Raw Materials
Assets are your content library. They reference media that exists in your VideoDB collection but don’t define how or when it plays.VideoAsset
Your main video content. EachVideoAsset points to a video file via its ID.
Key parameters:
id(required) – The VideoDB media IDstart(optional) – Trim point in seconds (e.g.,start=10skips first 10s of source)volume(optional) – Audio level:0.0(muted) to2.0(200%), default1.0crop(optional) – Crop the sides of an asset by a relative amount. The size of the crop is specified using a scale between0and1. A left crop of0.5will crop half of the asset from the left, a top crop of0.25will crop the top by quarter of the asset.
start=0), and keep original volume (volume=1).”
Important distinction: VideoAsset.start trims the source file. Where it appears on the timeline is controlled later at the Track layer. This “double start” concept is critical - we’ll explore it more in Layer 3 (Tracks).
AudioAsset
Background music, voiceovers, or sound effects. Works exactly likeVideoAsset.
Key parameters:
id(required) – The VideoDB audio file IDstart(optional) – Same trim behavior as VideoAssetvolume(optional) –0.0-2.0range (0.2 = 20% volume)
ImageAsset
Logos, watermarks, title cards, or static backgrounds. Key parameters:id(required) – The VideoDB image ID
TextAsset
Custom text overlays with full typography control. Key parameters:text(required) – The string to displayfont(optional) – Font object with family, size, color, opacityborder,shadow,background(optional) – Styling objectsalignment(optional) – Position on screentabsize(optional) – Tab size for text formattingline_spacing(optional) – Spacing between lineswidth(optional) – Width of text box in pixelsheight(optional) – Height of text box in pixels
&HAABBGGRR in hex (e.g., &H00FFFFFF = white)

CaptionAsset
Auto-generated subtitles synced to speech. This is where VideoDB gets magical. Important:CaptionAsset is a separate asset type from TextAsset. While TextAsset is for custom text overlays you write yourself, CaptionAsset automatically generates subtitles from video speech.
Key parameters:
src(required) – Set to"auto"to generate captions from video speechanimation(optional) – How words appear:reveal,karaoke,supersize,box_highlight,impact,color_highlightprimary_color,secondary_color(optional) – ASS-style colorsfont, positioning, border, shadow styling (optional)
CaptionAsset(src="auto"), you must call video.index_spoken_words() on the source video. This indexes the speech for auto-caption generation. Without it, captions won’t generate.

Supported Fonts for Text and Caption Assets

- Noto Sans Kannada
- Noto Sans Devanagari
- Noto Sans Gujarati
- Noto Sans Gurmukhi
Layer 2: Clips – The Presentation Engine
Clips wrap Assets and define how and how long they appear. This is your effects layer.
asset and a duration. Everything else is optional.
Duration – How Long It Plays
duration is a float in seconds. It defines how long the clip plays on the timeline.
Real example:
duration=10, only 10 seconds play (starting from VideoAsset.start).
Fit – How It Scales to Canvas
When your asset’s aspect ratio doesn’t match the timeline’s,fit controls scaling behavior.
Four modes:
Fit.crop(most common) – Fills the canvas completely, cropping edges if needed- Use when: Filling the frame is priority, cropping is acceptable
- Example: 16:9 video on a 9:16 (vertical) timeline
Fit.contain– Fits the entire asset inside the canvas, adding bars if needed- Use when: Showing all content is priority, bars are acceptable
- Example: Preserving widescreen footage in a square format
Fit.cover– Stretches to fill canvas (distortion possible)- Use when: Artistic effect or abstract content
Fit.none– Uses native pixel dimensions (no scaling)- Use when: Precise pixel control needed (e.g., 1:1 pixel mapping)
Position – Where It Appears
Position uses a 9-zone grid system:
Offset – For fine-tuned positioning

Scale – Size Adjustment
scale is a multiplier applied after fit. Default is 1.0.
Real example:
Opacity – Transparency
opacity ranges from 0.0 (invisible) to 1.0 (opaque).
Real example:
Filter – Visual Effects
Apply color/blur effects:greyscale, blur, boost (saturation), contrast, darken, lighten, muted, negative.
| Filter | Effect |
|---|---|
Filter.greyscale | Removes all color, creating a black-and-white look |
Filter.blur | Blurs the scene for artistic or privacy effects |
Filter.contrast | Increases contrast, making darks darker and lights lighter |
Filter.darken | Darkens the entire scene |
Filter.lighten | Lightens the entire scene |
Filter.boost | Boosts both contrast and saturation for vibrant colors |
Filter.muted | Reduces saturation and contrast for a subdued look |
Filter.negative | Inverts colors for a surreal, negative effect |
Transition – Fades
Fade in/out at clip start/end:duration) and how it appears (fit, position, scale, opacity, filter, transition). Now let’s see how to place clips on the timeline.
Layer 3: Tracks – Sequencing and Layering
Tracks are timeline lanes. They control when clips play and how they stack.
The Track Object
A Track is a container you add clips to:track.add_clip(start, clip) has two parameters:
start(float, seconds) – When the clip begins on the timelineclip(Clip object) – The clip to add
Sequential Playback (Same Track)
Clips on the same track play one after another:Simultaneous Playback (Different Tracks)
Clips on different tracks at the same timestamp play simultaneously:
Z-Order (Layering)
Later tracks render on top of earlier tracks.
The “Double Start” Concept
There are two separate “start” parameters:Asset.start– Trims the source filetrack.add_clip(start=...)– Places clip on the timeline
Layer 4: Timeline – The Final Canvas
Timeline is your export settings. It defines resolution, background color, and combines all tracks.
Resolution
Format:"WIDTHxHEIGHT"
Common presets:
"1280x720"– 16:9 horizontal (YouTube, landscape)"608x1080"– 9:16 vertical (TikTok, Shorts, Reels)"1080x1080"– 1:1 square (Instagram feed)"600x1060"– Custom dimensions
Background
The color shown behind/around clips when they don’t fill the canvas (e.g., when usingFit.contain). Format: hex color string.

Adding Tracks
Rendering
Complete example :

Concept Guides (Detailed Explanations)
These guides expand on specific concepts with design principles, edge cases, and best practices:Fit and Position
Deep dive into aspect ratios, 9-zone positioning, offset mechanics, and framing patterns
Trimming vs Timing
Complete explanation of the “double start” concept with formulas and multi-clip workflows
Caption Asset
Animation styles, ASS color format, positioning, accessibility, and styling best practices
Clip Parameters
Filters, transitions, opacity patterns, and complex multi-layer compositions
What You Can Build
See real-world applications of timeline composition and programmatic video creation:TikTok Lyric Videos
Transform music into viral vertical clips with AI backgrounds and synced lyrics
Video Statistics Recaps
Turn analytics into cinematic recaps with dynamic animations
Faceless Video Creator
Build complete faceless videos with AI scripts and voiceovers
Chess Match Montages
Automatically extract highlights with AI move detection
Get Started
Timeline Basics
See all concepts in action with hands-on examples and interactive code.