ejzhu2026/video-agent-hero
Video Agent Hero ๐ฌ
An agentic short-form video generator with a chat-driven two-phase pipeline: Plan โ Review โ Generate โ Modify
Powered by LangGraph + Claude + fal.ai Wan 2.2 + Google OAuth + Stripe.
๐ Live demo: ejzhu2026-video-agent-hero.hf.space
Features
- Chat-driven UI โ describe your video, then refine via conversation
- Two-phase pipeline โ see and edit the storyboard before generating
- Turbo โ HD upgrade โ quick 480p preview first, then upgrade to 720p
- Smart partial re-render โ AI classifies feedback as global (full replan) or local (re-render only affected shots), saving time and cost
- Real-time agent steps โ watch each pipeline node run with live elapsed timers
- LLM auto-naming โ projects are automatically named by Claude Haiku after planning
- Brand kit โ consistent logo, colors, fonts, subtitles across all videos
- Background music โ auto-generated via Replicate MusicGen, mixed to video
- Memory โ past projects stored in ChromaDB for semantic retrieval
- Credit system โ per-shot billing with Stripe top-up; new users get 10 free credits
- Google OAuth โ one-click sign-in, no passwords
Architecture
POST /plan POST /execute POST /modify
โ โ โ
โผ โผ โผ
intent_parser executor_pipeline change_classifier
memory_loader caption_agent โโ local โ partial_executor
clarification_planner layout_branding โโ global โ planner_llm
planner_llm โโโโโโโ quality_gate โ
plan_checker (loop) qc_diagnose music_mixer
โ render_export result_summarizer
โผ music_mixer memory_writer โ END
Plan JSON result_summarizer
saved to DB memory_writer โ ENDLangGraph orchestrates 4 compiled graphs:
Pipeline Nodes
State (AgentState)
All nodes share a single TypedDict that flows through the graph:
{
# Identity
"project_id": "a1b2c3d4",
"brief": "Summer promo for Tong Sui Coconut Watermelon",
"brand_id": "tong_sui",
# Plan (output of planner_llm)
"plan": {
"platform": "tiktok", "duration_sec": 10,
"concept": { "mood": "fresh", "visual_style": "..." },
"script": { "hook": "...", "body": [...], "cta": "..." },
"storyboard": [{ "scene": 1, "desc": "...", "duration": 2.5 }, ...],
"shot_list": [{ "shot_id": "S1", "text_overlay": "...", "duration": 2.5 }, ...],
"_quality": "turbo" # written after execute
},
# Execution
"scene_clips": [{ "shot_id": "S1", "clip_path": "...", "duration": 2.5 }],
"branded_clip_path": "data/projects/.../branded.mp4",
"output_path": "data/exports/a1b2c3d4_9x16_....mp4",
# Quality
"quality": "turbo", # "turbo" | "hd"
"quality_result": { "passed": true, "issues": [] },
# Partial re-render
"change_type": "local",
"affected_shot_indices": [1],
"shot_updates": { "1": { "desc": "...", "text_overlay": "..." } },
# Control
"needs_replan": false,
"plan_version": 1,
"messages": [...]
}Credit System
1 credit โ $0.10. A typical 5-shot turbo video costs 5 credits (~$0.50).
Credit Packages (Stripe)
Credits are deducted after successful generation. A pre-flight check prevents generation if balance is insufficient โ the Approve bar stays visible so users can top up and retry.
Video Quality Tiers
UI Flow
idle โโ[Send brief]โโโบ planning โโ[done]โโโบ plan_ready
โ
Edit storyboard cards
โก Turbo / โฆ HD quality chip
~X credits estimate shown
โ
[โถ Approve & Generate]
โ
executing โโ[done]โโโบ done
โ
โก Turbo preview shown
[โฆ Upgrade to HD] button
โ
[chat: "modify..."] โโ
smart re-renderChat bar states:
Project Structure
video-agent-hero/
โโโ web/
โ โโโ server.py # FastAPI + SSE streaming + inline HTML/JS frontend
โ โโโ auth/ # Google OAuth (router, models, deps)
โ โโโ billing/ # Stripe checkout + credit operations
โโโ agent/
โ โโโ graph.py # 4 LangGraph compiled graphs
โ โโโ state.py # AgentState TypedDict
โ โโโ deps.py # DB + VectorStore singletons
โ โโโ nodes/ # 15 node functions (one file each)
โโโ render/
โ โโโ fal_t2v.py # fal.ai T2V wrapper (turbo/hd quality tiers)
โ โโโ ffmpeg_composer.py # concat, subtitles, watermark, trim/scale, music mix
โ โโโ caption_renderer.py # SRT/ASS subtitle file writer
โ โโโ frame_generator.py # PIL placeholder frames (no-key fallback)
โโโ memory/
โ โโโ db.py # SQLite (projects, brand_kits, user_prefs, feedback)
โ โโโ vector_store.py # ChromaDB semantic search
โ โโโ schemas.py # Pydantic v2 models
โโโ cli/main.py # Typer CLI (vah init/new/run/feedback/demo)
โโโ assets/ # Brand assets (auto-generated on startup)
โโโ data/ # Runtime data โ gitignored
โ โโโ vah.db # SQLite (projects + users + billing)
โ โโโ chroma/ # ChromaDB
โ โโโ projects/{id}/clips/ # Per-shot MP4s (reused on partial re-render)
โ โโโ exports/ # Final deliverable MP4s
โโโ Dockerfile # HuggingFace Spaces deployment
โโโ requirements.txtQuick Start (Local)
Prerequisites
brew install ffmpeg # macOS
# sudo apt install ffmpeg # Ubuntu
python3.11 -m venv .venv && source .venv/bin/activateInstall & Run
git clone https://github.com/ejzhu2025/video-agent-hero
cd video-agent-hero
pip install -r requirements.txt
uvicorn web.server:app --host 0.0.0.0 --port 7860 --reload
# Open http://localhost:7860Environment Variables
Without ANTHROPIC_API_KEY / FAL_KEY: mock planner + PIL placeholder frames (useful for UI development).
CLI Reference
pip install -e . # installs `vah` command
vah init # seed DB with Tong Sui brand kit
vah new --brief "..." [--brand X] [--user Y]
vah run --project ID [--yes]
vah feedback --project ID --text "..."
vah list
vah demo # full end-to-end Tong Sui demoOutput Spec
HuggingFace Spaces Deployment
Set these as Space Secrets (Settings โ Repository secrets):
ANTHROPIC_API_KEY
FAL_KEY
GOOGLE_CLIENT_ID
GOOGLE_CLIENT_SECRET
STRIPE_SECRET_KEY
STRIPE_WEBHOOK_SECRET
REPLICATE_API_TOKEN # optional, for background music
SESSION_SECRET # any random stringData is stored in /data (Docker volume). The app auto-seeds the brand kit on startup.
