What is Clipping?

Clipping is a feature that allows you to extract specific parts of a video. This can be useful for creating shorter clips or for extracting specific moments from a longer video.

The path to use clipping:

core/clipping

Running Clipping

To run clipping:

resp = moonshine.run(
  flow="core/clipping",
  index="your-index",
  video_id="[file_id].mp4",
  prompt="Find me every dunk from the game"
)

Clipping only runs on a single video at a time.

Setting Number of Results

To set the number of results from clipping:

resp = moonshine.run(
  flow="core/clipping",
  index="your-index",
  video_id="[file_id].mp4",
  prompt="Find me every dunk from the game",
  num_clips=10
)

Setting Clip Duration

The duration of the clip can also be set with length, which is the soft target duration of the clip in seconds, and min_length and max_length, which are the hard minimum and maximum duration of the clip in seconds.

resp = moonshine.run(
  flow="core/clipping",
  index="your-index",
  video_id="[file_id].mp4",
  prompt="Find me every dunk from the game",
  length=10,
  min_length=5,
  max_length=15
)

Clipping Response Format

Clipping response contains:

[output]
object

JSON object (returned as a string) that maps clip identifiers (e.g., clip_1, clip_2) to their metadata

Where a clip object contains:

[output][clip_*].video_id
string
Video ID (file name) for the individual clip

Example:

{
  "output": {
    "clip_1": {
      "video_id": "VLT1MOKLMOHD981.mp4",
      "start_time": "00:10",
      "end_time": "00:21",
      "overview": "A well-executed offensive play by San Antonio, culminating in a powerful dunk by Sohan."
    },
    "clip_2": {
      "video_id": "VLT1MOKLMOHD981.mp4",
      "start_time": "01:47",
      "end_time": "02:04",
      "overview": "The moment where the Clippers secure their first official win at Intuit Dome, overcoming a large deficit."
    }
  },
  "status": "complete",
  "video_id": "[file_id].mp4"
}

Clipping 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/clipping",
        index=index,
        video_id=file_id,
        prompt="Find me every dunk from the game"
    )

    print(f"Clipping results for {file_name}: {resp}")

Clipping JSON

TODO