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

# Generate Video Stream

> Generate a streamable URL for video playback with optional timeline customization

Generate a streamable URL for the entire video or create a custom stream from specific timeline segments.

<CodeGroup>
  ```python Python theme={null}
  import videodb

  conn = videodb.connect(api_key="your_api_key")
  coll = conn.get_collection()
  video = coll.get_videos()[0]

  # Get full stream URL (returns existing if available)
  stream_url = video.generate_stream()

  # Create stream from custom timeline (in seconds)
  # Format: [(start, end), (start, end), ...]
  timeline = [(0, 30), (60, 90)]
  custom_stream_url = video.generate_stream(timeline=timeline)

  print(f"Stream URL: {stream_url}")
  print(f"Custom stream: {custom_stream_url}")
  ```

  ```javascript Node.js theme={null}
  import { connect } from 'videodb';

  const conn = connect({ apiKey: 'your_api_key' });
  const coll = await conn.getCollection();
  const videos = await coll.getVideos();
  const video = videos[0];

  // Get full stream URL (returns existing if available)
  const streamUrl = await video.generateStream();

  // Create stream from custom timeline (in seconds)
  // Format: [[start, end], [start, end], ...]
  const timeline = [[0, 30], [60, 90]];
  const customStreamUrl = await video.generateStream(timeline);

  console.log(`Stream URL: ${streamUrl}`);
  console.log(`Custom stream: ${customStreamUrl}`);
  ```
</CodeGroup>

<Note>
  * Returns a pre-existing stream URL if available (no re-processing needed)
  * Timeline allows creating videos with multiple segments automatically stitched
  * Timeline format: list of (start\_time, end\_time) tuples in seconds
  * Stream URLs are HLS format and work with most video players
  * Stream URLs remain valid as long as the video is stored
</Note>


## OpenAPI

````yaml POST /video/{video_id}/stream/
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:
  /video/{video_id}/stream/:
    post:
      summary: Create video stream
      parameters:
        - name: video_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^m-
            example: m-12345
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                format:
                  type: string
                  enum:
                    - mp4
                    - webm
                    - hls
                  example: mp4
                quality:
                  type: string
                  enum:
                    - low
                    - medium
                    - high
                  example: high
      responses:
        '200':
          description: Stream created
          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/v/12345
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-access-token
      description: API key for authentication (sk-xxx format)

````