Two tools for sharing Factorio (2.0 / Space Age) builds, driven by one in-game companion mod:
- Clip recorder — drag a box over your build while playing and it records that area for N seconds at a true 60 fps, then encodes to a small looping video. No save/quit cycle; you keep playing.
- Web map renderer — point a script at a save file and get a static, zoomable Leaflet site (pan/zoom, planet & platform switcher, shareable deep links). Pure HTML + WebP tiles; host it anywhere static.
mod/ companion mod "breadboard-mapper-tool" (tools, dialogs, capture)
cliprecorder.py encodes recorded frames -> AV1/VP9 video (one-shot or --watch)
factorio2web.py save file -> static web map (launches Factorio to render)
assets/ viewer template + vendored Leaflet (no CDN dependency)
clips/ encoded clips land here (gitignored)
out/, *-map/ rendered map sites (gitignored)
- Full graphical Factorio install (Steam install is auto-detected; a display is required — the headless server cannot take screenshots).
- Python 3.9+ with Pillow (WebP), and
ffmpegfor clips (libsvtav1preferred, falls back to VP9). - Install the companion mod by symlinking it into your mods directory:
ln -s "$(pwd)/mod" ~/.factorio/mods/breadboard-mapper-toolRepo edits to mod/ apply on the next Factorio restart.
- Run
./cliprecorder.py --watchin a terminal (optional but nice: desktop notification seconds after each capture finishes). - In game: shortcut bar → Breadboard: record a clip → drag a box over the build → dialog opens prefilled (name, seconds, fps) → Enter. A red REC overlay counts down while you keep playing, then vanishes. Right-drag with the tool cancels an active recording.
- Clips appear in
./clips/<name>-<timestamp>.mp4.
Frames are captured per tick with force_render = true, which forces a
real engine render per frame — this is what guarantees 60 unique
frames/second even when the window is unfocused (without it, Factorio
throttles rendering and you get ~4 fps footage in a 60 fps container).
Mod settings (Settings → Mod settings → Map): default fps (60/30/20), default length, max resolution of the longest edge (default 1280 px). The record dialog overrides per clip. Capture happens in real time, so a 10 s clip takes 10 s of gameplay.
Encoding presets (cliprecorder.py):
| Preset | What it is | Use when |
|---|---|---|
web (default) |
SVT-AV1 crf 38, light hqdn3d denoise, 10-bit, .mp4 |
Sharing online. ~2.5× smaller than VP9 on dark scenes (Fulgora). |
quality |
SVT-AV1 crf 30, no denoise | Archival / max fidelity. |
vp9 |
libvpx-vp9 .webm, lookahead enabled |
Old-browser compatibility. |
--crf N overrides any preset (higher = smaller). --keep-frames keeps
the raw PNGs in script-output/breadboard-clips/ after encoding.
./factorio2web.py EO2025 # save name or path to any .zip
python3 -m http.server -d EO2025-map 8000 # previewA Factorio window opens for a few minutes (don't play Factorio at the same time), then the script slices screenshots into a 256 px WebP tile pyramid with a self-contained viewer. Only on-screen tiles are downloaded (~10–30 KB each), so it works on poor connections. Only charted areas are rendered — unexplored map is never revealed.
Curation: with the in-game Breadboard share tool, drag boxes over the areas worth sharing; only those regions get rendered, and their names become labels on the map. Click a region with the tool to edit, right-drag to remove. Overlays only show while the tool is in hand. No regions = the whole charted map. (Test render of the full EO2025: 371 MB; curated to one base: 5 MB.)
Viewer features: planet/platform switcher, alt-mode icon toggle
(when rendered with --alt both), mouse coordinates, and shareable URL
hashes like #vulcanus/alt/6/40/-30 (surface/variant/zoom/x/y).
| Flag | Default | Meaning |
|---|---|---|
--ppt {8,16,32} |
8 |
Pixels per game tile at max zoom. 16 ≈ 4× size, 32 ≈ 16×. |
--alt {off,on,both} |
both |
Alt-mode overlay tile sets; both adds the in-map toggle but doubles render time. |
--quality N |
80 |
WebP quality. |
--full |
off | Ignore share regions, render everything charted. |
--inject-regions JSON|@FILE |
— | Override regions from the CLI (testing/automation). |
--keep-shots |
off | Keep raw screenshots in script-output/breadboard-mapper/. |
--factorio PATH, --user-dir PATH, --timeout N |
auto / ~/.factorio / 1800 |
Plumbing. |
factorio2web.pygenerates a throwaway render mod into a temp--mod-directory(your real mods are symlinked in, never modified), launchesfactorio --load-game, and pollsscript-outputfor a done marker. The render mod asks the companion mod for share regions viaremote.call("breadboard-mapper-tool", "export").- The companion mod stores regions in the save (
storage.regions) and exposesremote.call("breadboard-mapper-tool", "record", {surface=, area=, seconds=, fps=, name=})— handy for scripted/headless capture (the e2e test uses it). - Clip frames:
script-output/breadboard-clips/<tick>-<name>/%05d.pngmeta.json+done(orcancelled) marker;cliprecorder.pysweeps, encodes, deletes frames.
- "A Factorio instance is already running" — close the game first; two instances fight over the user-data dir.
- Factorio relaunches itself through Steam — shouldn't happen (we set
SteamAppId=427520in the env), but if it does, kill the spawned instance; it can linger invisibly for hours and block future runs. - Render fails — the work dir (
.<out>.work/) is kept on failure; readfactorio.login there, plus~/.factorio/factorio-current.log. Lua errors at load are detected and reported instead of hanging. - Clips look low-fps — make sure the capture went through the mod (force_render); also check the encoder didn't fall back unexpectedly.
- REC overlay bleed: the red border sits on the capture boundary and can leave a faint edge line in footage — inset the rectangle or draw it outside the area.
- Recorder niceties: optional 3-2-1 countdown before capture; a hotkey to record the current camera view without dragging; show estimated file size in the dialog.
- Map: POI sidebar/search in the viewer; per-surface "last updated" stamps; incremental re-render (only blocks whose chunks changed).
- Clips × map: drop encoded clips back onto the web map as markers
(the viewer code for video popups existed at commit
7fb46daif ever wanted again). - Moonshot — sprite-based renderer: export entity data instead of pixels and draw with sprite atlases in-browser (FBE-style; prototype via blueprint strings → FBE). Infinite zoom, animated belts everywhere, and the only path to a live map from a headless server.
Working end-to-end as of 2026-06-11: live recorder verified at 120/120
unique frames @ 60 fps (unfocused window), AV1 presets verified ~2.5×
smaller on Fulgora night footage; map renderer verified full (371 MB,
8 surfaces) and curated (5 MB) on save EO2025.
