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

# Extract Video Scenes

> Extract and analyze scenes from video content

Extract scenes from a video using shot detection or time-based segmentation, with automatic frame sampling and descriptions.

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

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

  # Extract scenes using shot-based detection (default)
  scene_collection = video.extract_scenes()

  for scene in scene_collection.scenes:
      print(f"Scene: {scene.id}")
      print(f"Time: {scene.start}s - {scene.end}s")
      print(f"Description: {scene.description}")

  # Extract with time-based segmentation (every 10 seconds)
  config = {"time": 10, "frame_count": 2}
  scenes = video.extract_scenes(
      extraction_type="time_based",
      extraction_config=config
  )
  ```

  ```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];

  // Extract scenes using shot-based detection (default)
  const sceneCollection = await video.extractScenes();

  for (const scene of sceneCollection.scenes) {
    console.log(`Scene: ${scene.id}`);
    console.log(`Time: ${scene.start}s - ${scene.end}s`);
  }

  // Extract with time-based segmentation (every 10 seconds)
  const scenes = await video.extractScenes({
    extractionType: 'time_based',
    extractionConfig: { time: 10, frameCount: 2 }
  });
  ```
</CodeGroup>

<Note>
  * Two extraction types: shot-based (detects camera cuts) and time-based (fixed intervals)
  * Shot-based default threshold is 20 (lower = more sensitive to changes)
  * Time-based allows specifying interval (in seconds) and frames per segment
  * Returns SceneCollection with Scene objects including frames and metadata
  * Extracted frames can be used for visual search and thumbnail generation
</Note>


## OpenAPI

````yaml POST /video/{video_id}/scenes/
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}/scenes/:
    post:
      summary: Create video scenes
      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:
                scene_type:
                  type: string
                  enum:
                    - shot
                    - time_based
                  example: shot
                callback_url:
                  type: string
                  example: https://webhook.example.com/callback
      responses:
        '200':
          description: Scene creation started
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AsyncResponse'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    AsyncResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        status:
          type: string
          enum:
            - processing
            - done
            - failed
          example: processing
        data:
          type: object
          properties:
            id:
              type: string
              example: job-123
            output_url:
              type: string
              example: https://api.videodb.io/async-response/job-123
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-access-token
      description: API key for authentication (sk-xxx format)

````