How pushkrjain/video_forge works
Purpose and Entry Points
Video Forge V2 is a Python/Streamlit system that converts a user-guided topic or article into a deterministic vertical 1080×1920 MP4. The interactive entry point is app.py; it manages chat state, script approval, pipeline status, and invokes the renderer. The non-UI orchestration entry point is video/pipeline.py, with standalone diagnostic runners in debug_full_pipeline.py and debug_pipeline.py.
Conversation-to-Script Layer
The application first turns user input into an article, analysis, selected creative intent, combinations, and a structured short-video script. app.py owns the session-driven state machine and chat interaction; prompts.py contains the prompt contracts; llm.py provides the Anthropic Foundry/Azure Claude client. This is a hard boundary: rendering starts only after a script is generated and the user explicitly triggers video generation.
Paths: app.py, prompts.py, llm.py, utils.py.
Pipeline Orchestration and Working-State Boundary
video/pipeline.py coordinates five sequential dependency waves in a per-run temp/ workspace: parse first; audio and images concurrently; storyboard after both; frame extraction; then compilation. It cleans transient inputs, preserves the final output under temp/output/, and fail-fast prevents later render stages after audio failure. Logging is shared with the UI and concurrent producer stages.
Paths: video/pipeline.py, video/__init__.py, temp/output/final_reel.mp4.
V1: Script Parsing, Speech, and Clock Authority
V1 converts the formatted script to section JSON and produces the authoritative audio timeline. It calls Claude to parse sections, generates Edge TTS chunks concurrently, stitches them with pydub, and derives cumulative millisecond timing from actual audio. The resulting sections, master.mp3, and timings are the contract consumed by storyboard generation and frame extraction.
Paths: video/v1_tts.py, prompts.py, llm.py.
V2: Visual Asset Acquisition
V2 independently resolves a visual asset per section using a five-worker thread pool. It searches SerpAPI Google Images, asks Azure OpenAI GPT-5-nano vision to rank candidates, downloads/crops selected images to portrait JPEGs, and substitutes typed color cards for pauses or failures. This isolates nondeterministic external retrieval before deterministic rendering begins.
Paths: video/v2_images.py, copyright_free.py, video/pipeline.py.
V3: Generated Storyboard as Rendering Program
V3 uses Claude Sonnet Skills and Code Execution to generate a self-contained GSAP storyboard HTML file from sections, timings, and image assets. Skill definitions impose design, vertical layout, GSAP, and virtual-clock rules; MD5 state avoids unnecessary skill synchronization. Validation enforces the seekable global-timeline contract and retries once with targeted repairs. The HTML is the boundary between generative design and frame rendering.
Paths: video/v3_storyboard.py, skills/gsap-animation/SKILL.md, skills/video-clock-contract/SKILL.md, skills/.hashes.json.
V4–V5: Deterministic Offline Rendering and Encoding
V4 splits the 30fps timeline across four independent Playwright/Chromium workers. Each loads the storyboard, waits for assets, seeks the GSAP virtual clock for assigned timestamps, and writes indexed JPEG frames. V5 invokes FFmpeg to combine %05d.jpg frames with master audio into H.264/AAC MP4, optionally mixing background music. These stages do not depend on real-time browser animation.
Paths: video/v4_frames.py, video/v5_compile.py, packages.txt.
Material Runtime and External Dependencies
The primary runtime is Python with Streamlit, asyncio/thread pools, Playwright Chromium, and FFmpeg. External services are Anthropic Foundry on Azure for chat, parse, and storyboard generation; Azure OpenAI for image ranking; SerpAPI for image search; and Edge TTS for speech. Required secrets are represented in .env.example; system browser dependencies are declared in packages.txt.
Paths: .env.example, requirements.txt, packages.txt.
Main entry points: v1_tts.py Parse & speech timeline · v2_images.py Visual asset acquisition · v3_storyboard.py GSAP storyboard · v5_compile.py MP4 compilation
Components 18
Conversation & Script
- Streamlit app · Manages chat state, approval, and pipeline status.
app.py - Prompt contracts
prompts.py - Claude client
llm.py - Approved video script · Rendering begins only after explicit user approval.
Render Pipeline
- Pipeline orchestrator · Coordinates dependency waves in a per-run workspace.
video/pipeline.py - Run workspace · Preserves the final MP4 under temp/output/.
- Parse & speech timeline · Produces sections, master audio, and authoritative timings.
video/v1_tts.py - Visual asset acquisition · Resolves portrait images or typed color-card fallbacks per section.
video/v2_images.py - GSAP storyboard · Generates and validates seekable storyboard HTML.
video/v3_storyboard.py - Storyboard skills · Defines GSAP and virtual-clock requirements.
skills/gsap-animation/SKILL.md
Offline Rendering
- Frame extraction · Four Chromium workers seek the virtual clock and write JPEG frames.
video/v4_frames.py - MP4 compilation · Combines indexed frames, master audio, and optional music.
video/v5_compile.py - Playwright Chromium
- FFmpeg
External Services
- Anthropic Foundry · Supplies chat, parsing, and storyboard generation.
- Azure OpenAI vision
- SerpAPI Google Images
- Edge TTS
Connections 23
- Streamlit app → Prompt contracts: uses
- Streamlit app → Claude client: drives conversation
- Prompt contracts → Claude client: defines requests
- Claude client → Anthropic Foundry: calls
- Streamlit app → Approved video script: approves
- Approved video script → Pipeline orchestrator: starts render
- Pipeline orchestrator → Parse & speech timeline: parse first
- Parse & speech timeline → Edge TTS: generates chunks
- Parse & speech timeline → Anthropic Foundry: parses sections
- Parse & speech timeline → Visual asset acquisition: sections and timings
- Parse & speech timeline → GSAP storyboard: sections and timings
- Pipeline orchestrator → Visual asset acquisition: runs concurrently with audio
- Visual asset acquisition → SerpAPI Google Images: searches
- Visual asset acquisition → Azure OpenAI vision: ranks candidates
- Visual asset acquisition → GSAP storyboard: portrait assets
- Storyboard skills → GSAP storyboard: constrains generation
- GSAP storyboard → Anthropic Foundry: generates and repairs
- GSAP storyboard → Frame extraction: seekable HTML
- Frame extraction → Playwright Chromium: renders with
- Frame extraction → MP4 compilation: indexed JPEGs
- Parse & speech timeline → MP4 compilation: master audio
- MP4 compilation → FFmpeg: encodes with
- MP4 compilation → Run workspace: writes final reel