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

# Create Timeline (v2)

> Create advanced video compositions with multiple tracks, effects, and assets

Create advanced video compositions with multiple tracks, clips, transitions, and effects. Timeline v2 provides granular control over video editing including cropping, filters, and positioning.

<CodeGroup>
  ```python Python theme={null}
  import videodb
  from videodb.editor import Timeline, Track, Clip, VideoAsset

  conn = videodb.connect(api_key="your_api_key")

  # Create timeline with custom resolution and background
  timeline = Timeline(conn)
  timeline.resolution = "1920x1080"
  timeline.background = "#000000"

  # Create a track and add video clips
  track = Track()
  video_asset = VideoAsset(id="m-abc123def", start=0)
  clip = Clip(asset=video_asset, duration=10)
  track.add_clip(0, clip)

  # Add another clip at 10 seconds
  video_asset2 = VideoAsset(id="m-xyz789", start=0)
  clip2 = Clip(asset=video_asset2, duration=8)
  track.add_clip(10, clip2)

  timeline.add_track(track)

  # Generate the stream
  stream_url = timeline.generate_stream()
  print(f"Stream: {stream_url}")
  ```

  ```javascript Node.js theme={null}
  import { connect, EditorTimeline, Track, Clip, EditorVideoAsset } from 'videodb';

  const conn = await connect({ apiKey: 'your_api_key' });

  // Create timeline with custom resolution and background
  const timeline = new EditorTimeline(conn);
  timeline.resolution = '1920x1080';
  timeline.background = '#000000';

  // Create a track and add video clips
  const track = new Track();
  const videoAsset = new EditorVideoAsset({ id: 'm-abc123def', start: 0 });
  const clip = new Clip({ asset: videoAsset, duration: 10 });
  track.addClip(0, clip);

  // Add another clip at 10 seconds
  const videoAsset2 = new EditorVideoAsset({ id: 'm-xyz789', start: 0 });
  const clip2 = new Clip({ asset: videoAsset2, duration: 8 });
  track.addClip(10, clip2);

  timeline.addTrack(track);

  // Generate the stream
  const streamUrl = await timeline.generateStream();
  console.log(`Stream: ${streamUrl}`);
  ```
</CodeGroup>

<Note>
  * Timeline v2 supports multiple tracks for layering videos, audio, images, and text
  * Clips define what asset plays and for how long (duration)
  * Default resolution is 1280x720, default background is black
  * Supports transitions, filters, cropping, and positioning on clips
  * Download the generated timeline with the Download endpoint
</Note>

<CardGroup cols={2}>
  <Card title="Download Timeline" icon="download" href="/api-reference/timeline/download_timeline">
    Export timeline as video file
  </Card>

  <Card title="Editor Guides" icon="book" href="/examples-and-tutorials/programmatic-editing/intro-outro">
    Learn advanced video composition
  </Card>
</CardGroup>


## OpenAPI

````yaml POST /timeline_v2
openapi: 3.0.3
info:
  title: VideoDB Server API
  description: >
    VideoDB Server API for video, audio, and image processing with AI
    capabilities.

    This API provides comprehensive video management, search, indexing, and
    AI-powered features.
  version: 1.0.0
  contact:
    name: VideoDB Support
    url: https://videodb.io
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: https://api.videodb.io
    description: Production server
  - url: https://staging-api.videodb.io
    description: Staging server
security:
  - ApiKeyAuth: []
tags:
  - name: Authentication
    description: User authentication and API key management
  - name: Collections
    description: Collection management operations
  - name: Videos
    description: Video upload, processing, and management
  - name: Audio
    description: Audio management operations
  - name: Images
    description: Image management operations
  - name: Search
    description: Content search and indexing
  - name: AI Generation
    description: AI-powered content generation
  - name: Billing
    description: Billing and usage management
  - name: RTStream
    description: Real-time streaming operations
  - name: Utilities
    description: Utility endpoints
  - name: Meeting
    description: Meeting recording and management
  - name: Capture
    description: Capture session management for recording streams
  - name: Editor
    description: Timeline editor operations
  - name: Transcode
    description: Media transcoding operations
  - name: Assets
    description: Cross-collection asset listing
paths:
  /timeline_v2:
    post:
      summary: Compile timeline (v2)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - request_type
                - timeline
              properties:
                request_type:
                  type: string
                  enum:
                    - compile
                  example: compile
                timeline:
                  type: array
                  items:
                    $ref: '#/components/schemas/Timeline'
                output_format:
                  type: string
                  enum:
                    - mp4
                    - webm
                    - hls
                  example: mp4
                quality:
                  type: string
                  enum:
                    - low
                    - medium
                    - high
                  example: high
      responses:
        '200':
          description: Timeline compilation result
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      stream_url:
                        type: string
                        example: https://stream.videodb.io/compiled/12345
                      duration:
                        type: number
                        example: 120.5
                      format:
                        type: string
                        example: mp4
      security:
        - ApiKeyAuth: []
components:
  schemas:
    Timeline:
      type: object
      properties:
        video_id:
          type: string
          example: m-12345
        clips:
          type: array
          items:
            type: object
            properties:
              start:
                type: number
                example: 0
              end:
                type: number
                example: 30
              volume:
                type: number
                example: 1
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-access-token
      description: API key for authentication (sk-xxx format)

````