# samuraigpt/clip-anything architecture

> Architecture diagram of the GitHub repository samuraigpt/clip-anything, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/samuraigpt/clip-anything
- Repository: https://github.com/samuraigpt/clip-anything

## Overview

Clip Anything’s checked-in runtime is a small, transcript-driven video clipper: it transcribes an input video, asks a chat-completions service to select matching timestamp ranges, then extracts and joins those ranges into an output video. The README describes broader visual, audio, sentiment, and virality analysis, but the sampled app.py implements transcript matching only; those broader capabilities are omitted rather than inferred. The graph reflects the single-file implementation, with external tools and services shown separately.

Main entry points: [`app.py`](https://github.com/samuraigpt/clip-anything/blob/main/app.py) (Runtime workflow), [`edited_output.mp4`](https://github.com/samuraigpt/clip-anything/blob/main/edited_output.mp4) (Edited video)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Clip workflow"]
  node_main["Runtime workflow<br/>[app.py]"]
  node_transcribe["Video transcription<br/>[app.py]"]
end

subgraph group_selection["Transcript selection"]
  node_matching["Prompt matching<br/>[app.py]"]
end

subgraph group_rendering["Clip rendering"]
  node_edit["Clip extraction<br/>[app.py]"]
  node_output["Edited video<br/>[edited_output.mp4]"]
end

node_user(("Video and query"))
node_ffmpeg["FFmpeg"]
node_whisper["Whisper model"]
node_groq["Groq chat API"]
node_moviepy["MoviePy"]

node_user -->|"starts with"| node_main
node_main -->|"calls"| node_transcribe
node_transcribe -->|"extracts audio"| node_ffmpeg
node_transcribe -->|"transcribes audio"| node_whisper
node_main -->|"passes transcript"| node_matching
node_matching -->|"requests segments"| node_groq
node_main -->|"passes segments"| node_edit
node_edit -->|"cuts and joins"| node_moviepy
node_edit -->|"writes"| node_output

click node_main "https://github.com/samuraigpt/clip-anything/blob/main/app.py"
click node_transcribe "https://github.com/samuraigpt/clip-anything/blob/main/app.py"
click node_matching "https://github.com/samuraigpt/clip-anything/blob/main/app.py"
click node_edit "https://github.com/samuraigpt/clip-anything/blob/main/app.py"
click node_output "https://github.com/samuraigpt/clip-anything/blob/main/edited_output.mp4"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_transcribe toneBlue
class node_matching toneAmber
class node_edit,node_output,node_groq toneMint
class node_user,node_ffmpeg,node_whisper,node_moviepy toneIndigo
```

## Components

### Clip workflow

- [Runtime workflow](https://github.com/samuraigpt/clip-anything/blob/main/app.py): `app.py`
- [Video transcription](https://github.com/samuraigpt/clip-anything/blob/main/app.py): `app.py`

### Transcript selection

- [Prompt matching](https://github.com/samuraigpt/clip-anything/blob/main/app.py): `app.py`

### Clip rendering

- [Clip extraction](https://github.com/samuraigpt/clip-anything/blob/main/app.py): `app.py`
- [Edited video](https://github.com/samuraigpt/clip-anything/blob/main/edited_output.mp4): `edited_output.mp4`

### Other components

- **Video and query**
- **FFmpeg**
- **Whisper model**
- **Groq chat API**
- **MoviePy**

## Connections

- Video and query → Runtime workflow: starts with (evidence: `app.py`)
- Runtime workflow → Video transcription: calls (evidence: `app.py`)
- Video transcription → FFmpeg: extracts audio (evidence: `app.py`)
- Video transcription → Whisper model: transcribes audio (evidence: `app.py`)
- Runtime workflow → Prompt matching: passes transcript (evidence: `app.py`)
- Prompt matching → Groq chat API: requests segments (evidence: `app.py`)
- Runtime workflow → Clip extraction: passes segments (evidence: `app.py`)
- Clip extraction → MoviePy: cuts and joins (evidence: `app.py`)
- Clip extraction → Edited video: writes (evidence: `app.py`)
