Skip to main content
Glama
README.md
# OpenSourceFrame Studio

Offline-first AI video direction, acoustic word alignment, Telugu/Tinglish kinetic typography, 3-layer subject depth occlusion, and MCP studio workstation.

---

## Key Capabilities

- **100% Local Speech Alignment (`faster-whisper`)**: Millisecond word-level timestamps (`tiny`, `base`, `small`, `medium`) with CPU (`int8`) or CUDA (`float16`) auto-detection and zero cloud tokens.
- **Telugu & Tinglish Transliteration Engine (`scripts/tinglish_engine.py`)**: Deterministic Dravidian-Latin lexicon + phonetic transliteration with WCAG AAA (21:1) kinetic badges.
- **3-Layer Depth & Landmark Tracking (`scripts/realtime_point_detector.py`)**: Computes topological face/pose landmarks, kinematic moments, posture states (`walking`, `sitting`, `standing`), and automatic behind-subject subtitle occlusion.
- **Parametric Style Matrix & Caption Pack (`caption-style-pack/`)**: 24,000+ pre-scored English & Telugu caption styles, 1,235 color palettes, 2,769 effect packs, and bundled Google Fonts (OFL / Apache-2.0 / UFL).
- **4 Interfaces Included**: Web Canvas Studio (`preview_player.html`), Native Desktop Window (`desktop_app.py`), Automation CLI (`cli.py`), and JSON-RPC 2.0 MCP Server (`mcp_server.py`).

---

## Architecture

```mermaid
flowchart TD
    subgraph UI ["Interfaces"]
        CLI["cli.py (osframe)"]
        Desk["desktop_app.py (pywebview)"]
        Web["preview_player.html (:8000)"]
        MCP["mcp_server.py (stdio / HTTP)"]
    end

    subgraph Core ["Processing Pipeline (scripts/)"]
        Align["pipeline_engine.py (Whisper + FFmpeg)"]
        Tinglish["tinglish_engine.py (Telugu / Tinglish)"]
        Depth["realtime_point_detector.py (3-Layer Depth)"]
        AI["local_small_ai.py (Zero-Token Styler)"]
    end

    subgraph Assets ["Local Assets"]
        Fonts["caption-style-pack/fonts/"]
        Models["models/ (faster-whisper)"]
        Styles["styles_database.json / .js"]
    end

    UI --> Core
    Core --> Assets
```

---

## Prerequisites

- **Python 3.10 – 3.12** *(Note: `mcp_server.py` uses Python stdlib `cgi` for multipart uploads, which was removed in Python 3.13+)*
- **FFmpeg** (with `libass` / HarfBuzz support for ASS subtitle burn-in) available on your `PATH`

---

## Installation & Setup

### 1. Clone and Create a Virtual Environment

```bash
git clone https://github.com/powerpackedcreatives-png/OpenSourceFrame-Studio.git
cd OpenSourceFrame-Studio

python -m venv .venv
# Windows:
.venv\Scripts\activate
# macOS / Linux:
# source .venv/bin/activate

pip install -r requirements.txt
```

### 2. Generate the Flat Font Cache (Required for FFmpeg Subtitle Burn-in)

The repository bundles open-source Google Fonts under `caption-style-pack/fonts/` (`english_starter/` and `telugu/`). Run the font indexer once to build the flat FFmpeg `fontsdir` cache (`caption-style-pack/fonts_flat/`) and refresh the browser font CSS/catalog:

```bash
python scripts/ingest_local_fonts.py
```

### 3. Speech Models (`faster-whisper`)

- **Default (Auto-Download):** On your first transcription run, `faster-whisper` automatically fetches the requested model (`base`, `tiny`, etc.) from Hugging Face Hub and caches it locally.
- **100% Air-Gapped Offline Setup:** See [`models/README.md`](models/README.md) to pre-download `faster-whisper-base` or `faster-whisper-tiny` directly into `models/`.

---

## Running OpenSourceFrame Studio

### Mode 1: Web Studio (`http://localhost:8000/preview_player.html`)

```bash
python mcp_server.py --http --port 8000
```

Then open **`http://localhost:8000/preview_player.html`** in your browser *(or double-click `start_localhost.bat` on Windows)*.

### Mode 2: Native Desktop Window

Ensure `pywebview` is installed (`pip install pywebview`), then run:

```bash
python desktop_app.py
```

*(Or double-click `run_desktop.bat` on Windows.)*

### Mode 3: Command-Line Interface (`cli.py`)

```bash
# View all CLI commands
python cli.py --help

# Run end-to-end video + audio + SRT pipeline (9:16 vertical preset)
python cli.py process --video sample_video.mp4 --audio sample_speech.mp3 --srt sample_captions.srt --dimension 9:16

# Transcribe speech offline with Faster-Whisper
python cli.py transcribe --input sample_speech.mp3 --model base --srt output_subtitles.srt

# Analyze 3-layer depth occlusion & subject posture
python cli.py depth --video sample_video.mp4 --out depth_sandwich_report.json

# Track geometric landmarks and kinematic moments
python cli.py track --video sample_video.mp4 --fps 15

# Search curated styles or get zero-token AI style recommendations
python cli.py styles --search "Cinematic" --limit 10
python cli.py ai-analyze --input sample_captions.srt --dimension 9:16 --posture sitting

# Detect silence intervals (optionally ripple-delete on running studio)
python cli.py cut-silence --audio sample_speech.mp3 --min-silence 0.38
```

*(On Windows, quick batch launchers are also included: `run_offline_pipeline.bat`, `run_local_ai_whisper.bat`, and `osframe.bat`.)*

### Mode 4: MCP Server for AI Coding Agents

Connect Antigravity, Claude Desktop, or Cursor via `stdio`:

```json
{
  "mcpServers": {
    "opensourceframe-studio": {
      "command": "python",
      "args": ["/absolute/path/to/OpenSourceFrame-Studio/mcp_server.py"]
    }
  }
}
```

**Exposed MCP Tools:**
- `video_auto_pipeline` — Autonomous captioning, tracking, and manifest assembly
- `video_point_tracking` — Geometric landmark & kinematic moment tracking
- `video_transcribe` — Local Faster-Whisper millisecond alignment
- `video_silence_cut` — Audio silence detection & interval optimization
- `get_styles_catalog` — Query the style matrix & aspect-ratio catalog
- `ai_smart_style` — Zero-token heuristic style & safe-anchor recommender
- `video_depth_analyze` — 3-layer depth sandwich analyzer with zero manual rotoscoping

---

## Telugu & ASS Subtitle Rendering Notes

When burning ASS subtitles directly with FFmpeg, pass `fontsdir` and `shaping=1` so Telugu conjuncts shape properly via HarfBuzz:

```bash
ffmpeg -i input.mp4 -vf "ass=captions.ass:fontsdir=caption-style-pack/fonts_flat:shaping=1" output.mp4
```

*(See [`caption-style-pack/README.md`](caption-style-pack/README.md) for full details on Telugu glyph coverage and style scoring.)*

---

## Project Layout

```text
├── cli.py                     # CLI entrypoint (osframe)
├── desktop_app.py             # Native pywebview desktop wrapper
├── mcp_server.py              # JSON-RPC 2.0 MCP & HTTP studio server
├── preview_player.html        # Interactive Web Canvas & timeline editor
├── antigravity_plugin.json    # Plugin & MCP tool manifest
├── styles_database.json/.js   # Parametric style & palette catalog
├── caption-style-pack/        # English + Telugu styles, palettes, OFL fonts
├── scripts/                   # Whisper, Tinglish, tracking, depth & SFX engines
├── models/                    # Local Faster-Whisper checkpoint directory
├── assets/ & sfx/             # Built-in sample assets and synthesized foley
└── docs/                      # Architecture & design documentation
```

---

## License & Attributions

- **OpenSourceFrame Studio Code:** Licensed under the [MIT License](LICENSE).
- **Caption Style Pack Data & Palettes (`caption-style-pack/data/`):** CC0 / Public Domain.
- **Bundled Fonts (`caption-style-pack/fonts/`):** Each font retains its respective open license (SIL Open Font License 1.1, Apache-2.0, or UFL), included inside each font's directory.