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:

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

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:

[output]
object

JSON object (returned as a string) that contains the [output][scenes]

[output][scenes]
List[object]
List of scene objects detected in the video

Where a scene item is made out of:

[output][scenes][].scene_id
integer

Sequential identifier for the scene

Example:

{
  "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:

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}")

Scene Detection JSON

TODO