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

# Scene Detection

> Break a video up into scenes

## What is Scene Detection?

Scene detection is a technique used in video processing to identify and separate different scenes within a video. This is particularly useful for tasks such as video summarization, content analysis, and ad insertion.

The path to use scene detection:

```
core/scene-detection
```

## Running Scene Detection

To run scene detection:

<CodeGroup>
  ```python python theme={null}
  resp = moonshine.run(
    flow="core/scene-detection",
    index="your-index",
    video_id="[file_id].mp4"
  )
  ```
</CodeGroup>

Scene detection can only be run on one video at a time. If you need to process multiple videos, you will need to run the scene detection function for each video separately.

## Scene Detection Response Format

The response of scene detection follows:

<Tabs>
  <Tab title="output">
    <ParamField path="[output]" type="object">
      JSON object (returned as a string) that contains the \[output]\[scenes]
      <ParamField path="[output][scenes]" type="List[object]"> List of scene objects detected in the video </ParamField>
    </ParamField>
  </Tab>

  <Tab title="status">
    <ParamField path="[status]" type="string">
      Completion status of the scene-detection operation
    </ParamField>
  </Tab>

  <Tab title="video_id">
    <ParamField path="[video_id]" type="string">
      Video ID (file name) of the analysed video
    </ParamField>
  </Tab>
</Tabs>

Where a scene item is made out of:

<Tabs>
  <Tab title="scenes.scene_id">
    <ParamField path="[output][scenes][].scene_id" type="integer">
      Sequential identifier for the scene
    </ParamField>
  </Tab>

  <Tab title="scenes.start_time">
    <ParamField path="[output][scenes][].start_time" type="string">
      Start timestamp of the scene (HH:MM:SS)
    </ParamField>
  </Tab>

  <Tab title="scenes.end_time">
    <ParamField path="[output][scenes][].end_time" type="string">
      End timestamp of the scene (HH:MM:SS)
    </ParamField>
  </Tab>

  <Tab title="scenes.description">
    <ParamField path="[output][scenes][].description" type="string">
      Narrative summary of what happens in the scene
    </ParamField>
  </Tab>

  <Tab title="scenes.type">
    <ParamField path="[output][scenes][].type" type="string">
      Scene category (e.g., "action-oriented", "dialogue-driven")
    </ParamField>
  </Tab>

  <Tab title="scenes.cues">
    <ParamField path="[output][scenes][].cues" type="string">
      Salient visual or audio cues that define the scene
    </ParamField>
  </Tab>

  <Tab title="scenes.characters_or_subjects">
    <ParamField path="[output][scenes][].characters_or_subjects" type="string">
      Key people or subjects appearing in the scene
    </ParamField>
  </Tab>
</Tabs>

Example:

```json theme={null}
{
  "output": {
    "scenes": [
      {
        "scene_id": 1,
        "start_time": "00:00:00",
        "end_time": "00:01:25",
        "description": "The initial segment of a basketball game at the Intuit Dome, featuring early plays, dunks, and three-pointers with ongoing commentary.",
        "type": "action-oriented",
        "cues": "Close-ups, wide court shots, score progression, live commentary",
        "characters_or_subjects": "Sohan, Wembanyama, Harden, Champagne, other players"
      }
    ]
  },
  "status": "complete",
  "video_id": "[file_id].mp4"
}

```

## Scene Detection Complete Example

A complete example over an entire index:

<CodeGroup>
  ```python python theme={null}
  import moonshine

  moonshine.configure("YOUR-TOKEN-HERE")
  index = "my-videos"

  items = moonshine.items(index=index)
  for item in items:
      file_id = item["file_id"]
      file_name = item["file_name"]
      print(f"Processing video: {file_name} (ID: {file_id})")

      resp = moonshine.run(
          flow="core/scene-detection",
          index=index,
          video_id=file_id
      )

      print(f"Scene detection results for {file_name}: {resp}")
  ```
</CodeGroup>

## Scene Detection JSON

Workflows are in a private beta. Please contact us at [team@usemoonshine.com](mailto:team@usemoonshine.com) to request access.

***

<Accordion title=".run(flow='core/scene-detection', ...) params" icon="code-simple">
  <ParamField path="index" type="string" required>
    Name/ID of the parent index of the video being processed.
  </ParamField>

  <ParamField path="video_id" type="string" required>
    ID of the video being processed.
  </ParamField>
</Accordion>
