Transform any video into a playable Godot 4.x game using LLM-powered analysis.
Three stages, each feeding the next — nothing from a later stage ever reaches back into an earlier one:
Video (file/URL)
│ Subtitles → transcript (source-language dialogue, authoritative;
│ names in it are NOT characters unless shown)
▼
Stage 1 · analyze the ORIGINAL video + extract its assets
Fast mode: ffmpeg keyframes ─┐ faithful GameDesign (characters, story,
Detail mode (-d): full video ┴─▶ scenes, props) + the frames that show them:
background/stills keep the video's aspect,
char/obj sprites are 512×512 and model-checked
▼
Stage 2 · rewrite + redraw — with your theme, or none
design re-skin (theme when given, otherwise "must differ from the source")
assets redrawn beside their frames (local image gen; -i supplies the theme)
▼
Stage 3 · generate the game flow and copy
Visual-novel Godot 4.x project (bilingual VN: source line + Chinese subtitle)
optional per-line voice-over (TTS) + loopable BGM + sound effects
Key properties of generated games:
- Visual novel: dialogue flow, choice options, reputation score — input is
Space/Enter/click only (
vn_manager.gdruntime, template-owned). - Bilingual text: every line shows the verbatim source-language transcript plus a Simplified Chinese subtitle; narration and UI are Chinese-only. Source-language text is extracted from the video's subtitles — never invented.
- Voice-over + music (optional): voice-over and music run against the
same endpoint as the LLM —
V2G_TTS_MODELspeaks the narration and every dialogue line (preset voices via/audio/speech, or one designed voice per character + narrator with a…-voicedesignmodel);V2G_MUSIC_MODELadds a loopable background track (OpenAI chat-audio — orV2G_MUSIC_PROVIDER=llmand the text model writes the synth code;acestepfalls back to a local ACE-Step server); sound effects (V2G_SFX_PROVIDER=llm) are synthesized locally — the text model writes one short synth script per cue, executed on your machine, so a cue can never come back as a spoken voice. Each layer is off until its switch is set, cached across runs, and can never fail a run — which backend serves a model is your routing concern.
Two analysis modes (both part of stage 1):
| Fast (default) | Detail (-d) |
|
|---|---|---|
| Input | Keyframe images (1 per 2s) | Full video file |
| Requires | Any vision model | Video-capable model |
| Output fields | Core design | + physics, behavior, layout, progression |
| Cost / speed | Lower / faster | Higher / slower |
- Analyze + extract — samples keyframes or prepares the video for upload (yt-dlp + ffmpeg), pulls subtitles (sidecar or embedded) as the source-language transcript, returns a faithful game design with bilingual dialogue, then cuts the assets out of the original video.
- Rewrite + redraw — re-skins the design's presentation with the theme you
passed (
-i) or, with none, simply so it no longer looks like the source; characters, objects and scenes get new names and every background is a different place, whileface_id, gameplay and the verbatim dialogue stay fixed — extracted sprites follow the renames (asset keys and speaker labels are re-keyed). If the re-skin fails, the run stops here instead of redrawing the art and generating a source-faithful game. The assets are then redrawn beside their frames when an image-gen backend is configured (skip is always reported); each brief opens and closes with the theme and carries the re-skinned design's art style, so the redraw follows-iinstead of the source frame — and the text the source burned in (subtitles, watermark) is ruled out at every step: the re-skin drops it from the design, the frame caption ignores it, every brief forbids it — redrawn art ships without text. The source-referenced candidate is text-led: the frame enters as a caption and stays a reference, never a template. - Generate — scaffolds a visual-novel Godot 4.x project (
project.godot,main.tscn,vn_manager.gdstory runtime,game_manager.gd), compile-checks every script (one LLM repair pass, then fallback, on parse errors), then runs Godot headless to import assets and self-check. Voice-over (per-line TTS), background music and sound effects all run against the same endpoint as the LLM — one model variable per layer, off when unset; music also offers a local ACE-Step server as an alternative backend. A failure downgrades to a warning, never a failed run.
- Python 3.11+
- ffmpeg on PATH
- yt-dlp on PATH (for URL downloads)
- OpenAI-compatible API key (GPT-4o, Claude via proxy, etc.)
- Godot 4.x to open the generated project
git clone <repo> && cd v2g
uv sync
uv sync --extra imagegen # optional: local image generation (Qwen-Image-2.1)
cp .env.example .env # fill in V2G_LLM_API_KEY# Fast mode — extract keyframes
uv run v2g ./gameplay.mp4
# Detail mode — send full video to video-capable LLM
uv run v2g ./gameplay.mp4 -d
# From a URL
uv run v2g "https://www.youtube.com/watch?v=..."
# Custom run directory (default: projects/<timestamp>_<source>/ — new per run)
uv run v2g ./clip.mp4 -o ./my_game
# Stage 2 theme — rewrite + redraw in a theme (omit it: the art only has to
# differ from the source video; extraction is the same either way)
uv run v2g ./clip.mp4 -i "vampire theme"Every run gets its own projects/<timestamp>_<source>/ directory holding
v2g.log, work/, llm/ and the game — delete it to remove the whole run.
Layered caching avoids pointless retries: projects/.v2g_cache/ stores raw
LLM responses keyed by exact request content (reruns make zero API calls;
V2G_LLM_CACHE=0 disables) and downloaded videos / re-encoded
intermediates keyed by URL or source file + settings (V2G_MEDIA_CACHE=0
disables — artifacts then go to the run's work/), so rerunning a source
skips both downloads and transcodes; <run>/design.json lets a rerun with
the same -o skip analysis entirely. Only a cached answer that fails
validation is refetched.
Then open the generated project in Godot:
godot --editor --path "projects/<run-id>"All settings via environment variables (or .env file):
| Variable | Default | Description |
|---|---|---|
V2G_LLM_API_KEY |
— | API key (required) |
V2G_LLM_BASE_URL |
https://api.openai.com/v1 |
OpenAI-compatible endpoint |
V2G_LLM_MODEL |
gpt-4o |
Model name |
V2G_LLM_CACHE |
1 |
Cache raw LLM responses across runs (0 disables) |
V2G_MEDIA_CACHE |
1 |
Cache downloads/transcodes across runs (0 disables) |
V2G_GODOT_PATH |
godot |
Godot executable |
V2G_MAX_DURATION |
120 |
Max seconds per single analysis; longer detail-mode input is trimmed to this |
V2G_FRAME_INTERVAL |
2.0 |
Seconds between extracted frames (fast mode) |
V2G_VIDEO_MAX_MB |
20 |
Hard cap on upload size in MB — oversized files are split to fit (detail mode) |
V2G_IMAGEGEN_PROVIDER |
— | Image generation: qwen = local Qwen-Image-2.1 (needs --extra imagegen); unset = off |
V2G_IMAGEGEN_STYLE |
— | Style prefix prepended to all image-gen prompts |
V2G_IMAGEGEN_STEPS |
20 |
Image-gen denoising steps |
V2G_IMAGEGEN_MAX_SIDE |
1024 |
Longest output edge for generated assets |
V2G_IMAGEGEN_AB |
— | Per asset, draw text-only and source-referenced candidates and keep the judge's pick (1 = on; off = reference only) |
V2G_ASSET_VERIFY |
1 |
Vision model must confirm each extracted frame shows its asset (0 = extract unchecked) |
V2G_TTS_MODEL |
— | Voice-over model; /audio/speech first (preset voices), documented chat protocol for voice-design models and as fallback (e.g. gpt-4o-mini-tts, mimo-v2.5-tts, mimo-v2.5-tts-voicedesign); unset = off |
V2G_TTS_VOICES |
API defaults | Preset mode: comma-separated voices; the first speaks narration and sets chat-audio audio.voice, characters rotate the rest. Ignored for voice-design models (voices are derived from the design) |
V2G_TTS_TEXT |
zh |
Spoken text: zh = Chinese line (default), source = verbatim transcript line, falling back to Chinese |
V2G_MUSIC_MODEL |
— | Background music model: chat audio (api), the code-writing text model (llm), or the DiT id (acestep); unset = off |
V2G_MUSIC_PROVIDER |
api |
api = OpenAI chat-audio; llm = the text model writes the synth code (works with no music model, executes model-written Python); acestep = local ACE-Step REST |
V2G_MUSIC_ACESTEP_URL |
http://127.0.0.1:8001 |
A running acestep-api for the acestep provider — start/stop it yourself |
V2G_MUSIC_DURATION |
60 |
BGM length in seconds (10–600) |
V2G_SFX_PROVIDER |
— | Sound-effects backend; llm = the text model writes one synthesis script per cue, run locally (model-written Python, same machinery as the BGM llm provider); unset or unknown = off |
Lint/format is ruff (line length 100, target py311) and the repo is kept
ruff-clean:
uv run ruff check . # lint
uv run ruff format . # format (also formats ```python blocks in AGENT.md)
uv run pytest # testsGit hooks run through prek (a pre-commit
drop-in) — .pre-commit-config.yaml pins ruff-check --fix + ruff-format
to ruff v0.16.8:
prek install # wire the pre-commit hook (once per clone)
prek run --all-files # run every hook over the treev2g/
├── v2g/
│ ├── __main__.py # CLI
│ ├── config.py # settings
│ ├── pipeline.py # orchestrator
│ ├── audio_api.py # shared chat-completions audio client (trunk endpoint)
│ ├── codegen.py # shared runner for model-written synth scripts (wav → mp3)
│ ├── tts.py # voice-over synthesizer (/audio/speech) + assignment
│ ├── music.py # BGM: prompt + delivery of one loopable track
│ ├── sfx.py # sound-effect cues (cached LLM call) + local synth scripts
│ ├── video/
│ │ ├── extractor.py # frame extraction (+ subtitle download for URLs)
│ │ ├── dialogue.py # subtitle transcript extraction (source language)
│ │ ├── asset_extractor.py # shot-anchored, model-verified, 512×512 sprite frames
│ ├── llm/
│ │ ├── client.py # OpenAI API wrapper
│ │ └── analyzer.py # frames/video → bilingual game design
│ └── godot/
│ ├── generator.py # project scaffolding + Godot self-check
│ └── templates.py # VN scene, vn_manager story runtime, prompts
└── projects/ # generated games — one fresh directory per run
# (v2g.log, work/, llm/, and the game inside)