Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Zai org CogVideo SAT Video Decoding and Export

From Leeroopedia


Attribute Value
Principle Name SAT Video Decoding and Export
Workflow SAT Video Generation
Step 5 of 5
Type Post-Processing
Repository zai-org/CogVideo
Paper CogVideoX
Last Updated 2026-02-10 00:00 GMT

Overview

Technique for decoding video latents through the VAE and saving as playable video files. After diffusion sampling produces denoised latents, the VAE decoder converts them back to pixel space, and the resulting frames are exported as MP4 video files.

Description

The decoding and export process consists of two stages:

  1. VAE decoding (decode_first_stage): The denoised latent tensor from diffusion sampling is passed through the 3D VAE decoder, which upsamples both spatially (8x) and temporally to produce pixel-space video frames. The scale_factor from training is applied inversely before decoding.
  2. Video export (save_video_as_grid_and_mp4): Decoded frames are rearranged from tensor format, normalized from [-1, 1] to [0, 255] uint8 range, and saved as MP4 files using the imageio library.

Context-parallel decoding handles the temporal dimension efficiently by distributing temporal chunks across GPUs when available.

Usage

Use SAT Video Decoding and Export as the final step of the SAT video generation pipeline, after diffusion sampling has produced denoised latent tensors. The output is a playable MP4 video file.

Theoretical Basis

The VAE decoder inverts the encoder mapping: z -> x. For video, the 3D VAE processes temporal and spatial dimensions jointly, ensuring temporal coherence in the decoded output.

Key mathematical operations:

  • Inverse scaling: z_decoded = z / scale_factor, where scale_factor was applied during encoding to normalize latent magnitudes.
  • 3D transposed convolutions: The decoder uses 3D transposed convolutions to upsample both spatial and temporal dimensions, recovering the original video resolution.
  • Normalization: The decoder outputs values in [-1, 1], which are linearly mapped to [0, 255] via pixel = (value + 1) / 2 * 255.

The einops library is used for tensor rearrangement between the model's internal format (B, C, T, H, W) and the export format (T, H, W, C).

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment