Video Generation
Extending diffusion from images to video: 3D U-Nets with factorized space-time attention, inflating image models with temporal layers, latent video diffusion (Stable Video Diffusion), and diffusion transformers on spacetime patches (the Sora report). Plus the knobs and failure modes.
A video is just a stack of images, so why is video generation so much harder than image generation? Three reasons: temporal consistency (the same character must keep the same face, clothes and position across frames, and motion must obey something like physics), compute (a 5-second 24 fps clip at 1024×576 has 120 frames, i.e. 120 images that must be denoised jointly), and data (good captioned video is scarcer and messier than captioned images). Video diffusion models tackle these with a handful of reusable ideas.
Idea 1: a 3D U-Net with factorized attention
Ho et al.'s Video Diffusion Models[1] extend the image U-Net to a video tensor (frames × height × width × channels). Spatial convolutions run per frame, and each block gets two kinds of attention: spatial attention within each frame and temporal attention across frames at each spatial position. Factorizing this way is much cheaper than full attention over every pixel of every frame. They also train jointly on images and videos (treating images as single-frame videos), which greatly improves quality because image data is so abundant.
- O
- big-O: how the cost grows, ignoring constant factors
- F
- number of frames
- h·w
- tokens per frame (height × width of the feature map)
- (F·h·w)²
- number of token pairs in full attention
- F·(h·w)²
- spatial attention: F frames, each with (h·w)² pairs
- h·w·F²
- temporal attention: h·w positions, each with F² pairs across time
▸Worked example
Idea 2: inflate a pretrained image model
Instead of learning appearance from scarce video, start from a strong Text-to-image model and insert temporal layers (temporal convolutions and temporal attention) after its spatial layers. The image layers already know what things look like; the new layers only have to learn how things move. Temporal layers are often initialized so that they output zero (identity behaviour), so the model starts as a per-frame image generator. Examples: Make-A-Video, Video LDM (Blattmann et al., 2023) and community 'motion modules' such as AnimateDiff that plug into existing Stable Diffusion checkpoints.
Idea 3: latent video diffusion and data curation (SVD)
Stable Video Diffusion (Blattmann et al., 2023)[2] applies Latent diffusion to video: Stable Diffusion 2.1 plus temporal layers, operating in VAE latent space. Its main lesson is about data: training in three stages (image pre-training → video pre-training on a large curated set → fine-tuning on a small high-quality set) and aggressively filtering clips (removing static scenes, cuts, heavy text overlays, low aesthetic or motion scores) matters as much as architecture. The released image-to-video models generate 14 or 25 frames at 576×1024 from a single conditioning image and are micro-conditioned on frame rate and a motion score, which become user knobs.
Idea 4: diffusion transformers on spacetime patches (Sora)
OpenAI's 2024 technical report 'Video generation models as world simulators'[3] describes the recipe behind Sora at a high level: a video compression network maps raw video into a lower-dimensional latent in both space and time; the latent is cut into spacetime patches that act as tokens (like words for an LLM or patches for a ViT); and a large diffusion transformer (Diffusion Transformer (DiT)[4]) denoises those patches, conditioned on text. Because the model consumes a variable-length sequence of patches, it can train on and generate videos of different durations, resolutions and aspect ratios. The report highlights capabilities that emerged with scale (3D-consistent camera motion, object permanence over short periods) as well as clear failures (e.g. glass shattering incorrectly, objects appearing spontaneously). Architectural details and training data were not disclosed.
| Approach | Backbone | Strength | Weakness |
|---|---|---|---|
| Pixel-space 3D U-Net (VDM) | U-Net + factorized attention | Simple, principled; joint image–video training | Expensive at high resolution; needs cascades |
| Inflated image model | Pretrained T2I + temporal layers | Reuses image knowledge; cheap to train | Short clips, limited motion range |
| Latent video diffusion (SVD) | Latent U-Net + temporal layers | Open weights, image-to-video, runs on one GPU | ~2–4 s clips; little camera/scene control |
| Spacetime-patch DiT (Sora-style) | Transformer over spacetime latent patches | Scales with compute; variable length/aspect; longer coherent clips | Very expensive; physics still unreliable |
Cascades. Many systems generate a short, low-resolution, low-frame-rate base video and then apply temporal super-resolution (insert frames) and spatial super-resolution (upscale) models in sequence, as in Imagen Video (Ho et al., 2022). Long videos are often produced autoregressively: generate a chunk, then condition the next chunk on the last frames.
- What it is
- Number of frames generated jointly in one diffusion run.
- ↑ If you increase it
- Longer clips with consistent motion, but memory and time grow at least linearly (temporal attention quadratically); beyond the trained length, consistency breaks down.
- ↓ If you decrease it
- Cheaper and more stable, but very short clips; extend by chaining chunks or frame interpolation.
- Typical values
- 14 (SVD) or 25 (SVD-XT); 16–24 for AnimateDiff-style models.
- What it is
- SVD micro-conditioning value telling the model how much motion to produce (it was trained with measured motion scores).
- ↑ If you increase it
- More and faster motion (camera moves, subject movement); too high and objects warp, melt or lose identity.
- ↓ If you decrease it
- Calmer, more stable clips; too low and the result is an almost still image with slight wobble.
- Typical values
- 127 (default); try 60–180.
- What it is
- How much noise is added to the conditioning image before it is given to SVD.
- ↑ If you increase it
- Looser adherence to the input image: more motion and creative change, but the first frame drifts from your picture.
- ↓ If you decrease it
- The video stays faithful to the input image, with less motion.
- Typical values
- 0.02 (default); up to ~0.1 for more motion.
- What it is
- fps tells SVD the intended frame rate of the clip; decode_chunk_size is how many frames the VAE decodes at once.
- ↑ If you increase it
- Higher fps conditioning → smaller motion between consecutive frames. Larger decode chunks → better temporal consistency of the decoded frames (less flicker) but more VRAM.
- ↓ If you decrease it
- Lower fps → bigger jumps between frames. decode_chunk_size = 1–2 saves memory at the cost of some flicker.
- Typical values
- fps 6–7 (default 7); decode_chunk_size 2–8 depending on VRAM.
import torch
from diffusers import StableVideoDiffusionPipeline
from diffusers.utils import load_image, export_to_video
pipe = StableVideoDiffusionPipeline.from_pretrained(
"stabilityai/stable-video-diffusion-img2vid-xt",
torch_dtype=torch.float16, variant="fp16",
)
pipe.enable_model_cpu_offload() # fits on consumer GPUs
image = load_image("rocket.png").resize((1024, 576))
frames = pipe(
image,
num_frames=25,
motion_bucket_id=127, # amount of motion
noise_aug_strength=0.02, # faithfulness to the input image
fps=7,
decode_chunk_size=4, # lower = less VRAM, slightly more flicker
generator=torch.manual_seed(42),
).frames[0]
export_to_video(frames, "rocket.mp4", fps=7)▸Go deeper: why 'world simulators'?
To predict plausible future frames, a model has to capture regularities of the world: 3D structure, occlusion, how objects persist and move. The Sora report[3] argues that scaling video models is a promising path towards general-purpose simulators of the physical world, while openly listing failures. Treat this as a hypothesis: impressive samples do not prove a model has learned physics, and quantitative evaluation of video realism (FVD, human studies, physics benchmarks) is still an open research area.
Ho et al.[1] also introduced reconstruction-guided sampling for extending videos in time or upsampling them: generate new frames conditioned on existing ones by guiding with the gradient of a reconstruction error, which gives better coherence than naive replacement. Practical recipes and current pipelines (text-to-video, image-to-video, video-to-video) are collected in the diffusers docs[5].
Quiz
References
- [1]Video Diffusion ModelsPaperHo et al.2022arxiv.org
- [2]Stable Video Diffusion: Scaling Latent Video Diffusion Models to Large DatasetsPaperBlattmann et al.2023arxiv.org
- [3]Video generation models as world simulators (Sora technical report)ArticleOpenAI (Brooks et al.)2024openai.com
- [4]Scalable Diffusion Models with Transformers (DiT)PaperPeebles & Xie2022arxiv.org
- [5]Diffusers documentationDocsHugging Facehuggingface.co