Text-to-Video: Temporal Coherence and Models
Video is not many images
The tempting mental model â generate frames independently and play them back â fails within two seconds of playback. Independent frames share a prompt but nothing else: the background drifts, a jacket changes colour, the number of objects flickers, and the camera position wanders because each frame sampled a different plausible interpretation of the same description. Human vision is brutally sensitive to exactly these inconsistencies, far more than it is to occasional softness in a single still.
So the modelling problem changes shape. The network must represent a volume of latent frames jointly, with a constraint that adjacent times stay compatible: the same object keeps its identity, motion is continuous rather than teleporting, and lighting persists across the clip. Every architecture in this space is a different answer to how to get that temporal constraint without the cost of full 3-D attention over every voxel, which would be prohibitive at video resolutions people actually want.
Three architectural answers to the same problem
| Approach | Temporal mechanism | Strength | Weakness |
|---|---|---|---|
| 3-D convolutional U-Net | Kernels span time and space | Local motion baked in | Long-range consistency weak |
| Factorised attention | Spatial then temporal passes | Scales to more frames | Two-stage errors compound |
| Latent shift-and-add | Frame latents blended before denoising | Cheap, stable | Motion can look smoothed |
| Autoregressive frame models | Predict next frame from history | Open-ended length | Drift accumulates |
| Diffusion transformer over clips | One attention over space-time tokens | Strong coherence | Very expensive |
Most systems in production combine two of these: spatial processing per frame, a cheap temporal pass across the clip, and text conditioning injected into both. The trend is toward treating a clip as a sequence of space-time tokens in a single transformer, which improves coherence at a cost that scales steeply with clip length.
Generating a clip with a latent video pipeline
import torch
from diffusers import DiffusionPipeline
def build_video_pipe(model_id="ali-vilab/text-to-video-ms-1.7b"):
pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda")
pipe.set_progress_bar_config(disable=True)
return pipe
def generate_clip(pipe, prompt, negative_prompt="", num_frames=16,
steps=25, height=256, width=256, seed=None):
generator = None
if seed is not None:
generator = torch.Generator(device="cuda").manual_seed(seed)
result = pipe(
prompt=prompt,
negative_prompt=negative_prompt or None,
num_frames=num_frames,
num_inference_steps=steps,
height=height,
width=width,
generator=generator,
)
return result.frames[0] # list of PIL images, one per frame
def save_gif(frames, path="clip.gif", fps=8):
frames[0].save(path, save_all=True, append_images=frames[1:],
duration=int(1000 / fps), loop=0)
Frame count is the primary cost lever: sixteen frames cost roughly double eight, while resolution multiplies on top. Short clips at modest resolution with strong prompts outperform long clips with vague ones, and almost every successful shot in practice starts as a four-second test that gets extended deliberately rather than a thirty-second first attempt.
Resolution and frame rate trade against each other for the same reason they do in ordinary video work: at a fixed budget, a smooth twelve-frame-per-second clip with clean detail usually reads better than a choppy thirty with soft edges, because viewers forgive missing frames long before they forgive shimmer. Fix the rate your player will actually show, generate to match it, and avoid generating at one rate only to resample later â interpolation invents in-between frames, and inventing motion is exactly the problem you are trying to control.
Keeping frames consistent
Several mechanisms fight drift, and they operate at different points in the stack.
class TemporalStabiliser:
"""Post-hoc consistency pass over generated frames."""
def __init__(self, blend: float = 0.25, history: int = 3):
self.blend = blend
self.history = history
self.previous = []
def stabilise(self, frame, guide):
"""Pull the current frame slightly toward a blend of recent history."""
if not self.previous:
self.previous.append(frame)
return frame
stack = torch.stack(self.previous[-self.history:] + [frame])
anchor = stack.mean(dim=0)
out = (1.0 - self.blend) * frame + self.blend * anchor
self.previous.append(out)
return out
@staticmethod
def optical_flow_score(frames) -> float:
"""Lower and smoother is better: measures frame-to-frame jump magnitude."""
diffs = [(frames[i + 1].float() - frames[i].float()).abs().mean()
for i in range(len(frames) - 1)]
jumps = torch.stack(diffs)
return jumps.mean().item(), jumps.std().item()
The mean jump tells you how much the image changes on average â too low means the clip is effectively frozen â while the standard deviation of those jumps exposes flicker, where one transition breaks pattern. Watching that second number catches the failures that a casual scrub through the clip misses.
Extending a clip beyond the trained window
Models are trained on short windows, commonly one to four seconds, so longer shots require stitching, and stitching is where most visible seams come from. The three strategies differ mainly in what they condition the next chunk on. Overlap the tail of the previous chunk with the head of the next and crossfade, which is cheap and tolerable when motion is slow but shows as a ghost whenever anything moves quickly. Feed the last generated frames back as conditioning for the next generation, which preserves motion direction but lets errors accumulate, so quality decays the further you extend. Or generate an entire long clip as one latent volume with a model whose temporal window supports it, which avoids seams entirely but is exactly where the compute cost bites.
Whichever route you take, the practical discipline is the same: lock the seed, the prompt, and the sampler across every chunk, because a changed setting at chunk three is the most common cause of a colour or lighting jump that viewers read as a glitch rather than an edit. Where a model offers image conditioning, generate a keyframe for each chunk from the last frame of the previous one before running the diffusion pass; that re-anchors composition and stops the drift that pure frame-conditioning accumulates. Keep chunks short and let the stitch overlap do its work, and check the join by scrubbing across it slowly rather than watching at full speed, since seams that are obvious frame by frame often vanish in playback â or the reverse, which is worse.
Prompting for motion rather than for a still
A video prompt has to specify dynamics, and most writers default to describing a photograph. Verbs carry the motion: "slowly pans," "steam rising," "tails flicking" give the model something to animate, while static descriptions such as "a serene kitchen" produce a locked-off shot with minor shimmer.
Order still matters, but now time does too. Describe the start state, the action, and the end state when you need a specific arc; models with stronger temporal conditioning follow a small narrative better than a single label. Negative prompts are equally useful â excluding "camera shake, flicker, warping" removes the most common artefacts without touching guidance strength. And where the pipeline supports it, conditioning on an initial image or a first-frame sketch buys enormous consistency, because composition is fixed once and only motion has to be invented.
Evaluating clips honestly
Sharpness per frame is the wrong headline metric for video. What viewers notice is temporal quality, so measure it directly: frame-to-frame difference statistics for flicker, optical flow smoothness for judder, and identity consistency â embedding similarity of the main subject across the clip â for object persistence. Then run a human pass, because artefacts that survive every automatic check still get noticed immediately by anyone watching.
Long-horizon consistency is the harder test and the one that separates systems: does the scene remain coherent at second six that was established at second one? Keep a fixed evaluation set of prompts with a stated beginning and ending, and score whether the clip actually reaches the stated end state. Systems that produce beautiful three-second fragments and contradictory thirty-second clips fail this test loudly.
Common Mistakes
Generating frames independently and stitching them
Fix: Use a model with temporal conditioning; independent frames share a prompt but not an identity.
Judging a video from a single exported still
Fix: Scrub the timeline and watch frame-difference statistics for flicker and jumps.
Spending the whole budget on one long attempt
Fix: Iterate on four-second clips at low resolution, then extend the shot that works.
Writing prompts as static scene descriptions
Fix: Lead with motion verbs and, where supported, an explicit start-to-end arc.
Best Practices
- Fix the seed while tuning so prompt changes are the only variable.
- Record frame count, resolution, steps, and model version with every accepted clip.
- Evaluate identity and motion with metrics alongside a human watch-through.
- Reserve the expensive high-resolution pass for shots already validated cheaply.
Key Takeaways
- Video generation succeeds or fails on temporal consistency, not per-frame sharpness.
- Architectures differ mainly in how they get space-time attention affordably: 3-D kernels, factorised passes, or token-level transformers.
- Frame count and resolution are the cost levers; short validated clips beat long speculative ones.
- Drift and flicker are measurable through frame-difference statistics and subject-embedding similarity over time.
- Prompts must describe motion â verbs, arcs, start and end states â rather than a still scene.