MicroDrama AI

Agentic AI Micro-Drama Video Generator

--- ### 🚨 The problem with AI video today: - ❌ **Manual, fragmented workflow** β€” Separate tools needed for scripting, image gen, and video gen - ❌ **No narrative structure** β€” Raw T2V models don't understand story arcs or scene continuity - ❌ **Character inconsistency** β€” Characters look different in every shot - ❌ **Visual-only** β€” Missing scripts, narrative depth, and cinematic storytelling ### πŸ’‘ MicroDrama AI Solution: 🎬 **Screenwriter**, **Storyboard Artist**, **Frame Generator**, and **Video Producer** β€” all in one automated pipeline. Type an idea. MicroDrama AI autonomously handles everything: story development, character design, shot-by-shot storyboarding, frame generation, and video clip production β€” then stitches it all into a complete cinematic micro-drama. Powered entirely by a single MuAPI key. ---

Awesome Generative AI Apps

> 🎨 **[Explore 50+ more open-source AI apps β†’](https://github.com/Anil-matcha/awesome-generative-ai-apps)** ## Related Projects - [AI-Youtube-Shorts-Generator](https://github.com/SamurAIGPT/AI-Youtube-Shorts-Generator) β€” Auto-clip and crop your AI dramas into viral YouTube Shorts - [Clip-Anything](https://github.com/SamurAIGPT/Clip-Anything) β€” Clip any moment from your AI drama with text prompts - [AI-Faceless-Video-Generator](https://github.com/SamurAIGPT/AI-Faceless-Video-Generator) β€” Generate faceless AI videos for your drama channel ## πŸŽ₯ Demo Video https://github.com/user-attachments/assets/f8b5d09c-8c58-40c1-b171-e3f42b0d71a8 Watch MicroDrama AI transform ideas into fully cinematic micro-drama videos using autonomous AI agents, character-consistent image generation, storyboarding, and MuAPI-powered video creation. --- ## πŸ“‘ Table of Contents - [πŸ’‘ Key Features](#-key-features) - [πŸ—οΈ Architecture](#%EF%B8%8F-architecture) - [πŸ”„ Pipeline Stages](#-pipeline-stages) - [πŸš€ Quick Start](#-quick-start) - [πŸ› οΈ Project Structure](#%EF%B8%8F-project-structure) - [🌐 API Reference](#-api-reference) - [βš™οΈ Configuration](#%EF%B8%8F-configuration) - [πŸ–₯️ UI Overview](#%EF%B8%8F-ui-overview) --- ## πŸ’‘ Key Features
### 🎭 Idea to Video **From Spark to Screen** Transform a raw idea into a complete micro-drama. The AI develops the story, writes scene scripts, designs the storyboard, and generates the full video β€” zero manual steps. ### πŸ“ Script to Video **Bring Your Script to Life** Already have a scene script? Skip the writing phase and let MicroDrama AI handle storyboarding, character portraits, frame generation, and video production. ### 🎨 Character Consistency **Coherent Visual Identity** Characters are extracted with detailed static and dynamic features. Reference portraits are generated and used to keep characters visually consistent across every shot. ### πŸ“‘ Real-time Progress **Live Pipeline Visibility** Watch every stage of the pipeline in real time via SSE streaming β€” from story development through to the final concatenated video, with a live animated stage timeline.
--- ## πŸ—οΈ Architecture ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ MicroDrama AI Server β”‚ Idea / Script ─► β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Screenwriter Agent β”‚ β”‚ β”‚ β”‚ develop_story() β†’ write_script_based_on_story() β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ story + scene scripts β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Character Extractor Agent β”‚ β”‚ β”‚ β”‚ extract_characters(script) β†’ List[char] β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ characters[] β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Storyboard Artist Agent β”‚ β”‚ β”‚ β”‚ design_storyboard() β†’ List[ShotBriefDescription] β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ shots[] β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ MuAPI Tools β”‚ β”‚ β”‚ β”‚ β‘  Portrait Gen β†’ flux-dev-image (T2I) β”‚ β”‚ β”‚ β”‚ β‘‘ Frame Gen β†’ flux-kontext-dev-i2i (I2I) β”‚ β”‚ β”‚ β”‚ β‘’ Video Gen β†’ kling-v2.1-standard-i2v (I2V) β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ video clips β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ moviepy Concat β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ └────────────────────────────-┼──────────────────────────--β”˜ β”‚ final_video.mp4 ``` All LLM calls (story, characters, storyboard) go through MuAPI's `/claude-sonnet-4-6` endpoint. **Only one API key is required for the entire pipeline.** --- ## πŸ”„ Pipeline Stages ### Idea to Video β€” Full Pipeline | # | Stage | Agent / Tool | Output | |---|-------|-------------|--------| | 1 | **Story Development** | Screenwriter (MuAPI LLM) | Story outline in prose | | 2 | **Character Extraction** | CharacterExtractor (MuAPI LLM) | Characters with static + dynamic visual features | | 3 | **Scene Scripting** | Screenwriter (MuAPI LLM) | 2–4 individual scene scripts | | 4 | **Character Portraits** | MuAPI `flux-dev-image` (T2I) | Reference portrait per character β€” runs in parallel | | 5 | **Storyboard Design** | StoryboardArtist (MuAPI LLM) | 3–5 shots per scene: visual + motion + audio desc | | 6 | **Frame Generation** | MuAPI `flux-kontext-dev-i2i` (I2I) | First frame per shot using character reference images | | 7 | **Video Generation** | MuAPI `kling-v2.1-standard-i2v` (I2V) | 5-second video clip per shot β€” runs in parallel | | 8 | **Concatenation** | moviepy | All clips joined into `final_video.mp4` | ### Script to Video β€” Short Pipeline Skips stages 1–3. Starts directly from your provided script. | # | Stage | Agent / Tool | Output | |---|-------|-------------|--------| | 1 | **Character Extraction** | CharacterExtractor (MuAPI LLM) | Characters with visual descriptions | | 2 | **Character Portraits** | MuAPI `flux-dev-image` (T2I) | Reference portrait per character | | 3 | **Storyboard Design** | StoryboardArtist (MuAPI LLM) | Shots from your script | | 4 | **Frame Generation** | MuAPI `flux-kontext-dev-i2i` (I2I) | First frame per shot | | 5 | **Video Generation** | MuAPI `kling-v2.1-standard-i2v` (I2V) | 5-second video per shot | | 6 | **Concatenation** | moviepy | Final scene video | --- ## πŸš€ Quick Start ### Prerequisites - Python 3.10+ - Node.js 18+ - A [MuAPI](https://muapi.ai?utm_source=github&utm_medium=readme&utm_campaign=open-ai-micro-drama-generator) API key ### 1. Clone the repo ```bash git clone https://github.com/Anil-matcha/Open-AI-Micro-Drama-Generator.git cd Open-AI-Micro-Drama-Generator ``` ### 2. Set up the server ```bash cd server python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -r requirements.txt cp .env.example .env # Open .env and set MUAPI_KEY=your_key_here ``` ### 3. Start the server ```bash uvicorn api:app --reload --port 8000 ``` API available at `http://localhost:8000`. Health check: `GET /api/health`. ### 4. Set up and start the client ```bash cd client npm install npm run dev ``` Open [http://localhost:3000](http://localhost:3000). ### 5. Generate your first micro-drama 1. Enter an idea β€” e.g. *"A detective chases a shadow through a neon-lit cyberpunk city"* 2. Optionally add requirements β€” e.g. *"Keep it under 3 scenes, suitable for all ages"* 3. Pick a visual style: **Cinematic**, Realistic, Anime, Fantasy, or Documentary 4. Click **Generate Video** and watch the pipeline run in real time 5. Download your finished micro-drama when it completes --- ## πŸ› οΈ Project Structure ``` Open-AI-Micro-Drama-Generator/ β”‚ β”œβ”€β”€ server/ # FastAPI backend β”‚ β”œβ”€β”€ api.py # App entry point, endpoints, SSE job runner β”‚ β”œβ”€β”€ requirements.txt β”‚ β”œβ”€β”€ .env.example β”‚ β”‚ β”‚ β”œβ”€β”€ agents/ # LLM-powered AI agents (all via MuAPI) β”‚ β”‚ β”œβ”€β”€ screenwriter.py # develop_story() + write_script_based_on_story() β”‚ β”‚ β”œβ”€β”€ character_extractor.py # extract_characters() β†’ List[CharacterInScene] β”‚ β”‚ └── storyboard_artist.py # design_storyboard() β†’ List[ShotBriefDescription] β”‚ β”‚ β”‚ β”œβ”€β”€ interfaces/ # Pydantic data models β”‚ β”‚ β”œβ”€β”€ character.py # CharacterInScene (idx, name, static/dynamic features) β”‚ β”‚ └── shot.py # ShotBriefDescription, ShotDescription β”‚ β”‚ β”‚ β”œβ”€β”€ tools/ # MuAPI integration layer β”‚ β”‚ β”œβ”€β”€ muapi_llm.py # MuAPILLM β€” submit + poll LLM completions β”‚ β”‚ β”œβ”€β”€ muapi_image_generator.py # T2I (flux-dev) + I2I (flux-kontext) image gen β”‚ β”‚ β”œβ”€β”€ muapi_video_generator.py # I2V (kling-v2.1) video gen with polling β”‚ β”‚ └── muapi_uploader.py # Upload local images to MuAPI for URL references β”‚ β”‚ β”‚ β”œβ”€β”€ pipelines/ # Orchestration logic β”‚ β”‚ β”œβ”€β”€ idea2video.py # Full end-to-end pipeline β”‚ β”‚ └── script2video.py # Scene-level pipeline (portraits β†’ storyboard β†’ video) β”‚ β”‚ β”‚ └── utils/ β”‚ └── video.py # moviepy concatenation helper β”‚ └── client/ # Next.js 14 frontend β”œβ”€β”€ next.config.js # Rewrites /api/* and /outputs/* β†’ FastAPI server β”œβ”€β”€ package.json β”œβ”€β”€ tailwind.config.js β”‚ β”œβ”€β”€ app/ β”‚ β”œβ”€β”€ layout.js # Root layout + metadata β”‚ β”œβ”€β”€ globals.css # Global styles + gradient utilities β”‚ β”œβ”€β”€ page.js # Landing page: hero + generation form β”‚ └── generate/[jobId]/ β”‚ └── page.js # SSE consumer: pipeline progress + result viewer β”‚ └── components/ β”œβ”€β”€ IdeaForm.js # Idea/script input, style picker, mode toggle β”œβ”€β”€ PipelineProgress.js # Animated 7-stage timeline + live scrolling log └── VideoResult.js # Video player with download + open controls ``` --- ## 🌐 API Reference ### `POST /api/generate` β€” Start a generation job **Request body:** ```json { "idea": "A lone astronaut discovers alien ruins on Europa", "user_requirement": "Keep it under 3 scenes, suitable for all ages", "style": "Cinematic", "mode": "idea2video" } ``` | Field | Type | Default | Description | |-------|------|---------|-------------| | `idea` | string | required | The creative idea or concept | | `user_requirement` | string | `""` | Optional constraints (audience, length, tone) | | `style` | string | `"Cinematic"` | Visual style: Cinematic, Realistic, Anime, Fantasy, Documentary | | `mode` | string | `"idea2video"` | `"idea2video"` or `"script2video"` | | `script` | string | `""` | Scene script (only used when `mode = "script2video"`) | **Response:** ```json { "job_id": "550e8400-e29b-41d4-a716-446655440000" } ``` --- ### `GET /api/status/{job_id}` β€” Stream progress (SSE) ```http GET /api/status/550e8400-... Accept: text/event-stream ``` SSE event stream. Reconnect-safe β€” replays all past events on reconnect. **Progress event:** ```json {"type": "progress", "stage": "screenwriter", "message": "Developing story...", "progress": 10} ``` **Completion event:** ```json {"type": "complete", "video_url": "/outputs/job_id/final_video.mp4", "progress": 100} ``` **Error event:** ```json {"type": "error", "message": "MuAPI image job failed: quota exceeded", "progress": -1} ``` **Pipeline stages in order:** `screenwriter` β†’ `characters` β†’ `storyboard` β†’ `portraits` β†’ `frames` β†’ `video` β†’ `concat` --- ### `GET /api/result/{job_id}` β€” Get job result ```json { "job_id": "550e8400-...", "status": "completed", "video_url": "/outputs/550e8400-.../final_video.mp4", "error": null } ``` **Status values:** `running` | `completed` | `failed` --- ### `GET /api/health` β€” Health check ```json { "status": "ok", "service": "microdrama-api" } ``` --- ## βš™οΈ Configuration ### Environment variables | Variable | Required | Description | |----------|----------|-------------| | `MUAPI_KEY` | βœ… | MuAPI API key β€” used for LLM, image, and video generation | One key. That's it. ### MuAPI endpoints used internally | Purpose | Endpoint | Model | |---------|----------|-------| | LLM completions | `POST /claude-sonnet-4-6` | claude-sonnet-4-6 | | Character portraits (T2I) | `POST /flux-dev-image` | FLUX.1-dev | | Shot frames (I2I + character ref) | `POST /flux-kontext-dev-i2i` | FLUX.1-Kontext-dev | | Video clips (I2V) | `POST /kling-v2.1-standard-i2v` | Kling v2.1 Standard | | File upload | `POST /upload_file` | β€” | | Job polling | `GET /predictions/{id}/result` | β€” | All jobs follow the same async pattern: submit β†’ get `request_id` β†’ poll every 3 s β†’ return on `"completed"`. --- ## πŸ–₯️ UI Overview ### Landing page (`/`) - Dark cinematic design with animated radial glow background - Feature pills: Screenwriter Agent Β· Storyboard Artist Β· Frame Generator Β· Video Generator - Idea textarea, optional requirements field - Style picker: Cinematic Β· Realistic Β· Anime Β· Fantasy Β· Documentary - Mode toggle: Idea to Video / Script to Video ### Generation page (`/generate/[jobId]`) - **7-stage animated pipeline timeline** with live status indicators - **Progress bar** with percentage - **Scrolling live log** showing every message emitted by the pipeline - **Video player** with autoplay once `complete` event is received - Download button saves `microdrama-{jobId}.mp4` - SSE auto-reconnects if the connection drops mid-generation --- ## πŸ“„ License MIT β€” see [LICENSE](LICENSE) for details.