A full-stack Flask web app that converts movie subtitles → AI-enriched scenes → storytelling script → live FFmpeg video generation (Level 5). Built on a 4-layer AI architecture: Core Engine / AI Brain / Control Center / AI Router (OpenAI key pool with auto-failover). No paid APIs required — Ollama optional, rule-based fallback always available.
python main.py— run Flask app on port 8080- Required: Python 3 + Flask + requests (
pip install requests) - Optional: OpenAI keys via env vars (see below), Ollama at http://localhost:11434
- FFmpeg 6.1.2 available at
/nix/store/.../bin/ffmpeg— detected automatically
- Python 3, Flask, Jinja2 templates
- Pure CSS dark glassmorphism — no external CSS frameworks
- Architecture: CoreEngine / AIBrain / ControlCenter / AIRouter + PipelineEngine + AIHub logging
subprocessfor FFmpeg execution,requestsfor OpenAI HTTP calls
main.py— Flask routes + Levels 1–5 pipeline orchestration (12 logged stages)core_engine.py— Layer 1: deterministic subtitle parsing + scene building (no AI)ai_brain.py— Layer 2: observation, analysis, suggestion engine (advisory only)control_center.py— Layer 3: governance, auto-approve/reject, temporary overridesai_router.py— Level 4: OpenAI key pool, auto-failover, cooldown tracking, usage statsai_hub.py— central logger; session logs atuploads/<id>/hub_log.jsonai_engine.py— LLM priority chain: OpenAI (via router) → Ollama → rule-basedscene_parser.py— Level 5: parses[MM:SS - MM:SS] narrationformat → structured scene listpipeline_engine.py— Level 5: orchestrates script gen → scene parse → FFmpeg executionvideo_pipeline.py— Shell script generator (Level 3) + live FFmpeg execution (Level 5)modules/— srt_parser, scene_builder, script_generator (shim), ffmpeg_generator, exportertemplates/— base, upload, dashboard, scenes, script_view, video_pipeline, downloaduploads/<id>/output/— timestamped_script.txt, video_pipeline.sh, clips/, final_video.mp4
- Layer 1 (CoreEngine): pure deterministic — zero AI logic, immutable
- Layer 2 (AIBrain): advisory only — returns suggestions, never modifies data directly
- Layer 3 (ControlCenter): auto-approves non-destructive; rejects delete/merge/reorder
- Level 4 (AIRouter): LRU key selection; cooldown 90s rate-limits, 300s auth errors; 5-key retry
- Level 5 (PipelineEngine): script gen (OpenAI→Ollama→rule-based) → scene_parser → FFmpeg
-c copy(no re-encode); clean fallback states:no_movie/no_ffmpeg/error/complete - Security: API keys stored in env vars only; masked as
sk-...XXXXin all UI/logs - Session data in
uploads/<uuid>/data.json— no database
- Upload (
/) — movie title, optional video file, SRT or pasted text - Dashboard (
/dashboard/<id>) — 12-stage pipeline timeline, AI Router key pool panel, Brain + Control Center logs - Scenes (
/scenes/<id>) — emotion badges, narrative role labels, importance rings - Script (
/script/<id>) — Level 2 narration with emotion tags, copy buttons - Video Pipeline (
/video/<id>) — AI timestamped script, parsed scenes, live FFmpeg clip cutting + merging, downloadfinal_video.mp4 - Download (
/download/<id>) — ZIP with shell scripts + all exports
GET /api/router/status— live key pool status (JSON, keys masked)POST /api/router/reload— force re-read of env vars + reload poolPOST /video/<id>/generate— trigger Level 5 pipelineGET /video/<id>/download— stream final_video.mp4
Set any of these Replit Secrets (priority order):
OPENAI_KEY_1,OPENAI_KEY_2, ...OPENAI_KEY_10— individual keysOPENAI_API_KEYS— comma-separated listOPENAI_API_KEY— single legacy key
- Beginner-friendly comments throughout
- No database, no paid/external APIs required
- Modular architecture (one file per concern)
- pnpm monorepo at root — Flask runs from root
main.py; do NOT runpnpm dev pip install requestsneeded forai_router.py- FFmpeg uses
-c copy(stream copy, no re-encode) for fast clip cutting _fmt()inpipeline_engine.pymust produceMM:SS(no decimals) to matchscene_parserregexpipeline_statusdict keys fromai_hub.get_pipeline_status()may be int or str — dashboard handles bothuploads/<id>/output/clips/created per session during video generation
ai_router.py— source of truth for key pool logicscene_parser.py— source of truth for timestamp parsing regexpipeline_engine.py— source of truth for Level 5 orchestration flowai_hub.py— source of truth for all pipeline logging