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

# Clipping

> Find and extract important parts of videos

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

<CodeGroup>
  ```python python theme={null}
  resp = moonshine.run(
    flow="core/clipping",
    index="your-index",
    video_id="[file_id].mp4",
    prompt="Find me every dunk from the game"
  )
  ```
</CodeGroup>

Clipping only runs on a single video at a time.

### Setting Number of Results

To set the number of results from clipping:

<CodeGroup>
  ```python python theme={null}
  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
  )
  ```
</CodeGroup>

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

<CodeGroup>
  ```python python theme={null}
  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
  )
  ```
</CodeGroup>

## Clipping Response Format

Clipping response contains:

<Tabs>
  <Tab title="output">
    <ParamField path="[output]" type="object">
      JSON object (returned as a string) that maps clip identifiers (e.g., <code>clip\_1</code>, <code>clip\_2</code>) to their metadata
    </ParamField>
  </Tab>

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

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

Where a clip object contains:

<Tabs>
  <Tab title="clip.video_id">
    <ParamField path="[output][clip_*].video_id" type="string"> Video ID (file name) for the individual clip </ParamField>
  </Tab>

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

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

  <Tab title="clip.overview">
    <ParamField path="[output][clip_*].overview" type="string"> Brief narrative description of what happens in the clip </ParamField>
  </Tab>
</Tabs>

Example:

```json theme={null}
{
  "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:

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

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

## Clipping 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/clipping', ...) 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>

  <ParamField path="prompt" type="string" required>
    Prompt for clips in the video to find.
  </ParamField>

  <ParamField path="num_clips" type="number">
    Max number of clips to find.
  </ParamField>

  <ParamField path="length" type="number">
    Soft target for the length of each clip in seconds.
  </ParamField>

  <ParamField path="min_length" type="number">
    Hard minimum length of each clip in seconds.
  </ParamField>

  <ParamField path="max_length" type="number">
    Hard maximum length of each clip in seconds.
  </ParamField>
</Accordion>
