Mask2DiT: Dual Mask-based Diffusion Transformer for Multi-Scene Long Video Generation

Tianhao Qi, Jianlong Yuan, Wanquan Feng, Shancheng Fang, Jiawei Liu, SiYu Zhou, Qian He, Hongtao Xie, Yongdong Zhang · DOI

Abstract

Generating long-form videos with multiple scenes remains a significant challenge for current diffusion models. While Diffusion Transformers (DiT) have shown promise in single-scene generation, they often struggle with semantic alignment and visual consistency when guided by multiple prompts. This paper introduces Mask2DiT, a novel framework that employs a dual-masking strategy to bridge this gap. By utilizing a symmetric binary attention mask for precise prompt-to-video alignment and a segment-level conditional mask for auto-regressive scene extension, Mask2DiT produces coherent multi-scene videos with high visual fidelity. Experimental evaluations show that Mask2DiT significantly outperforms existing state-of-the-art methods in both visual consistency and overall video quality.

Introduction

The advent of Diffusion Transformers (DiT), exemplified by models like Sora, has revolutionized high-quality video generation. However, extending these capabilities to multi-scene long videos introduces complex hurdles. Existing U-Net-based architectures often fail to capture long-range temporal dependencies, leading to abrupt transitions or the loss of character and background consistency across scenes.

The primary technical challenge lies in balancing global visual coherence with local semantic alignment. Simply concatenating multiple prompts often leads to "semantic leakage," where descriptions from one scene bleed into another. Conversely, generating scenes independently leads to a total loss of global context. Mask2DiT addresses these issues by introducing a structured attention mechanism that preserves context while enforcing strict prompt adherence.

Methods

Mask2DiT builds upon the CogVideoX architecture, introducing three key innovations to handle the complexities of multi-scene generation. The framework is designed to provide the model with a "global view" for consistency while maintaining a "local focus" for prompt accuracy.

Overview of the Mask2DiT architecture, illustrating the dual-masking strategy and the 3D Full Attention Layer.

1. Symmetric Binary Attention Mask

This mechanism ensures that text tokens for a specific scene only interact with their corresponding video tokens. Importantly, it allows video tokens to maintain a global view by attending to all other video tokens in the sequence. This "semi-permeable" structure prevents semantic noise—where prompts from one scene influence the visuals of another—while facilitating visual continuity across the entire video.

Detailed visualization of the symmetric binary attention mask pattern used to maintain semantic alignment.

2. Segment-level Conditional Mask

To enable auto-regressive generation, this mask allows the model to treat previous video segments as clean, non-noisy context during the denoising of the current segment. During training, the model is tasked with predicting the $n$-th segment while the previous $n-1$ segments are provided as ground truth. This teaches the model to maintain stylistic and content consistency by "reading" the preceding narrative.

3. Grouped Attention Mechanism

To mitigate the computational and memory overhead associated with long token sequences, Mask2DiT employs a grouped attention strategy. By partitioning the sequence into groups and utilizing multiple cross-attention instances instead of a single massive self-attention calculation, the model achieves high efficiency without sacrificing performance.

Datasets and Training

The training process follows a two-stage pipeline. First, the model undergoes Pre-training on 1 million samples from the Panda70M dataset to learn basic multi-prompt handling. This is followed by Supervised Fine-Tuning (SFT) on a curated dataset of high-quality, logically connected video sequences.

The authors used PySceneDetect to identify shots and the ViClip model to filter for combinations with high visual relevance. Captions were generated using Google's Gemini model to ensure character and background detail were accurately reflected in the text, which is critical for maintaining consistency.

Key Results

Mask2DiT was compared against state-of-the-art (SOTA) methods including CogVideoX, StoryDiffusion, and TALC.

  • Quantitative Performance: Mask2DiT achieved a 15.94% improvement in Visual Consistency over the base CogVideoX model. It also recorded the lowest Fréchet Video Distance (FVD) of 720.01, indicating superior overall video quality and realism compared to competitors like StoryDiffusion (905.69).
  • Qualitative Excellence: In side-by-side comparisons, Mask2DiT successfully maintained character features (e.g., a "boy with a straw hat") across multiple distinct camera angles and environments, whereas other models often changed the character's appearance or the art style between shots.
  • User Preference: In a study involving 10 users, Mask2DiT was preferred 50% of the time for overall quality, more than doubling the score of the next best method.

Conclusion and Future Work

Mask2DiT provides a robust solution for the "Alignment vs. Coherence" trade-off in long-form video generation. While currently focused on animated and cartoon styles due to the availability of high-quality multi-scene training data, the framework's dual-masking and grouped attention strategies offer a scalable path toward high-resolution, multi-minute cinematic generation. Future work will explore adaptive-length scenes to allow for more natural cinematic pacing and broader domain generalization.

Summary updated

BibTeX
@inproceedings{qi2025mask,
  author = {Tianhao Qi and Jianlong Yuan and Wanquan Feng and Shancheng Fang and Jiawei Liu and SiYu Zhou and Qian He and Hongtao Xie and Yongdong Zhang},
  title = {{Mask2DiT: Dual Mask-based Diffusion Transformer for Multi-Scene Long Video Generation}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  url = {https://openreview.net/forum?id=qBZC07N8nl},
}
Figure