Docs

Movie sprite

One character picture in. A transparent idle loop out.

See also: Portrait motion

yuzu_standing.png

loop.mkv · 18.2 MB

42 s
from picture to finished loop
$0.24
estimated, for one eight-second take

A character that breathes and shifts its weight usually means a video model, a green screen, a keyer, a loop editor, and someone checking frame by frame that the face did not drift and the edges are not green. FX Games holds that as one graph, and the first frame of the finished loop becomes the picture the face workflow starts from.

Try it

Use FX Games' movie sprite workflow (uv run python -m grida.fx schema movie-sprite lists its inputs) to turn 1this character into a transparent idle loop. Keep the face still, because I will add blinks separately.

Plan it offline, generate one eight-second 720p take with a $2 limit, and show me the take. Finish it only after I say it is good.

+

Paste it into an agent that can use this repository, and attach your own files where the prompt refers to them.

From picture to loop

On a green plate
The generated take
Keyed to transparency
Checked on light, dark and checkerboard

What you get

This example was made by the workflow of that time, whose run folder kept its files under body/; a run today puts them under outputs/, as the contract lists. Its loop holds 192 frames, played over 12 seconds.

yuzu-idle-0124 files, 21.2 MB
NameSizeKind
body21.2 MBFolder, 16 files
loop.mkv18.2 MBThe finished loop, lossless and transparent
canonical.png147 KBThe loop's first frame, exactly, for the face workflow
loop-preview.mp41.4 MBA preview to play anywhere, over a dark background
contact-sheet.png516 KBFrames sampled across the loop, on three grounds
manifest.json2 KBWhat a game reads: size, frames, playback rate and digests
processing-report.json73 KBThe settings, the checks, and a hash of every frame
source.mp4924 KBThe take you chose, kept as it was
execution-view.json11 KBEvery step as it ran, with its timing
and 7 more files the pipeline keeps for recovery and auditing

Where it works

Works well

  • A finished character picture with a transparent background
  • Gentle idle motion: breathing, a little weight shift, hair and sleeves settling
  • Characters with no green in their design
  • Portrait or landscape takes of three to ten seconds, played back slower if you like

Not expected to work

  • Walking, turning, big gestures, or anything that leaves the pose
  • Green clothing, hair or props: green is what gets removed
  • Exact control of the motion: the prompt guides it, and some takes will not be usable
  • Sound

Good to know

  • The video model may redraw the character slightly. The loop's first frame becomes the new picture for the face workflow.
  • Pick a take before finishing. Finishing is local, so trying other finishing settings costs nothing.
  • MP4 previews have no transparency. Use the lossless loop or the PNG frames in a game.

What goes wrong by hand

By handIn the graphHow
Settings the video service cannot take are found after paying.Length, resolution and aspect ratio are checked against the video route, and the take is priced, before any call.
A failed request is retried blindly and paid for again.The take is one recorded job: a run that stops while it renders collects it next time, and a new take is asked for by name.
A green fringe stays around the hair and edges.Green is removed with edge despill, and the result is checked on light, dark and checkerboard grounds.
The loop jumps where it restarts.The ends are blended with optical flow, and the first and last frames are verified identical.
The face drifts, so blinks drawn later no longer line up.The face is held to the first frame, and that frame is handed to the face workflow.

Models and tools

Gemini Omni Flash 1.1falVideo model
FFmpeglocalDecodes, encodes and verifies every frame
OpenCVlocalOptical flow that closes the loop

Run it yourself

The workflow turns a character illustration into a transparent, recurring body animation: draw a take, look at it, then finish it. The finished loop's first frame becomes the canonical picture for the separate portrait-motion workflow. Games decide how to display the resulting videos and images. The contract holds the graph, the call and cache behaviour, and an offline example.

Install the Python dependencies with uv sync --frozen, build the engine with uv run python third_party/fx/tools/build_engine.py (again after each pull), and install ffmpeg and ffprobe on PATH. The command line is uv run python -m grida.fx plan|run movie-sprite; in Python, grida.fx.run("movie-sprite", ...).

Author the take

Put a character PNG with a transparent background beside a take.yaml:

character: character.png
direction: A relaxed listening idle with subtle overlapping movement.
requested_motion:
  - Loose hair ends settle gently; hair roots stay anchored.
  - The forearms and fingers make tiny relaxed adjustments.
  - The chest rises and falls slowly and vertically below fixed shoulders.
constraints:
  - Keep the head, bangs, face, neck and shoulders still.
  - No sideways chest motion, body rocking, external wind or expression change.
seconds: 8
resolution: 720p
aspect_ratio: "9:16"
finish: finish.json

Only character is required. A fixed template and these sections become one video prompt, and the fitted picture is passed as both the first and the last frame; this route has no middle-frame or extra-reference inputs. uv run python -m grida.fx plan movie-sprite --inputs take.yaml shows the steps and the price, offline.

The template holds the head, neck and shoulders still, keeps motion local elsewhere, and asks for a fixed camera, green backing and no sound. Directions can explicitly ask for blinking or mouth movement when separate facial control is unnecessary. Prompts guide generation; they cannot guarantee pixel locks or a useful take.

The original picture supplies identity and pose. A video model may redraw it, including the first frame. After finishing, canonical.png is the exact first frame of the transparent loop; use it for the portrait-motion workflow.

Draw, look, finish

Start with finish.json:

{
  "source_mode": "chroma",
  "playback_seconds": 12,
  "loop_closure": "flow"
}

Draw the take with a spending ceiling:

uv run python -m grida.fx run movie-sprite --inputs take.yaml --live --max-usd 2

The workflow's fx.yaml names fal's Gemini Omni Flash 1.1 image-to-video route. It draws whole seconds from 3 to 10, at 360p, 720p, 1080p or 4k, in 9:16 or 16:9. Credentials use FAL_KEY; see provider configuration. The take is recorded as a job: if the run stops while the clip renders, running the same command again collects it rather than paying for another. python -m grida.fx reroll <run> take asks for a new take on purpose, which the next live run draws, and python -m grida.fx pick <run> take <n> chooses which one is finished.

FX's viewer (python -m grida.fx start) shows the take and the finished loop beside their steps. Change finish.json and run again: the plate, the brief and the take come from the cache, and only finishing runs.

A clip made elsewhere can be finished instead: give footage: selected.mp4 (or a Matroska file with alpha) and no character. That run makes no provider call.

Control the finishing

Finishing applies green chroma extraction, optional fixed regions and local repairs, a bounded optical-flow loop closure, then playback retiming. It preserves native dimensions and source frame count. An eight-second, 192-frame source retimed to twelve seconds still has 192 frames, played at 16 fps; it is not two concatenated loops.

fixed_regions pins caller-selected polygons to the first keyed frame. moving_guards subtracts regions such as loose hair or ears from those pins. The fixed field uses a feather outside its boundary; keep it compact so it does not suppress desired body motion. local_repairs optionally aligns and pins a small opaque attachment. Spatial controls require both source_sha256 and native coordinate_size, preventing geometry for one take from silently affecting another. See the component settings.

source_mode: "rgba" skips chroma extraction. Already finished transparent footage can use source_mode: "finished" with loop_closure: "none" and no spatial corrections; every RGBA pixel is kept. Its endpoint frames must already match. Each frame must include transparent background and fully opaque foreground pixels. Use playback_seconds: null to keep the source playback rate.

Consume the assets

The outputs are listed in the contract. loop.mkv is native lossless FFV1 video with straight RGBA and no audio, and frames.zip adds a numbered PNG sequence when export_frames is true. FFV1 is the lossless interchange master; consumers may select their own playback codec or use the PNG sequence. MP4 previews do not carry transparency. Structural verification checks every decoded native output frame and the loop endpoints. Visual review still chooses whether a new character's motion and keyed edges are acceptable, including over the intended background. That review does not require a game runtime.

For independent eyes and mouth, pass the finished canonical to the portrait-motion workflow, with an inputs file that names it and the committed face spec:

portrait: sprites/idle.png
spec: src/fx_games/workflows/portrait_motion/inputs/face-four-card.json
uv run python -m grida.fx plan portrait-motion --inputs face.yaml

The portrait-motion workflow's input contracts, generation, validation, budgets and outputs are its own. The two workflows exchange an image, not game state or a combined runtime.