Principle:Zai org CogVideo SAT Video Decoding and Export
| 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:
- 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. - 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, wherescale_factorwas 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]viapixel = (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
- Implementation:Zai_org_CogVideo_SAT_Decode_First_Stage_Export -- Implementation of VAE decoding and MP4 export
- Zai_org_CogVideo_Diffusion_Sampling -- Previous step: diffusion sampling that produces the latents
- Zai_org_CogVideo_SAT_Inference_Configuration -- Configuration providing FPS and output path parameters