Video compositing—the process of seamlessly injecting dynamic foreground elements from one video into another—is a cornerstone of film and video production. Traditionally, this task is notoriously labor-intensive, requiring experts to manually mask objects, track motion, and painstakingly adjust lighting and colors to make a "pasted" object look like it belongs in a new scene.
While recent generative AI models can create impressive videos from text or images, they struggle with the precise pixel-level control required when using specific external video assets. Existing "video harmonization" tools can fix color mismatches, but they cannot handle complex motion trajectories, resizing, or the physical interactions (like a butterfly casting a shadow on a flower) that make a composite look real. GenCompositor bridges this gap by treating compositing as a generative task guided by user-defined paths, automating the process while maintaining perfect background consistency and realistic environmental interactions.
A Dual-Branch Diffusion Transformer Architecture
GenCompositor is built on a novel Diffusion Transformer (DiT) backbone, specifically tailored for generative video compositing through three key architectural innovations:
1. Background Preservation Branch
To ensure the target background remains untouched outside the composited area, the model uses a lightweight Background Preservation Branch (BPBranch). This branch injects masked background tokens into the main generation stream, ensuring that only the areas intended for the new object—and its immediate interactions—are modified.
2. DiT Fusion Block
Instead of using standard cross-attention, which often loses fine-grained detail and is better suited for abstract semantic concepts, the model uses full self-attention to fuse foreground tokens with the background. This allows the model to "inherit" the exact identity and complex motion of the source foreground video at the pixel level.
3. Extended Rotary Position Embedding (ERoPE)
Standard position embeddings assume all video tokens share the same coordinate grid. However, in compositing, the foreground object has its own layout that does not align with the background. Directly applying standard Rotary Position Embedding (RoPE) to unaligned videos causes severe artifacts. ERoPE solves this by assigning unique labels and stream-specific shifts to different video streams, effectively giving the foreground its own coordinate system. This prevents "leakage" artifacts and allows the model to adaptively rescale and reposition objects without visual glitches.
Training Insights and the VideoComp Dataset
Because no dedicated dataset existed for this complex task, the researchers curated VideoComp, a large-scale dataset comprising 61,000 sets of videos. Each set includes a high-quality source video, a segmented foreground element, and a corresponding mask, filtered for aesthetic quality and motion completeness.
A crucial insight during training was the concept of interaction through mask inflation. By slightly "inflating" the masks used during training (adding a buffered band around the object), the model learns to modify the background pixels near the object. This enables the model to hallucinate realistic physical interactions, such as shadows, glows, and motion blur, grounding the object in its new environment.
State-of-the-Art Compositing Results
GenCompositor significantly outperforms existing baselines in both video harmonization and trajectory-controlled generation.
- Harmonization: It achieved a PSNR of 42.00 and an SSIM of 0.9487, surpassing specialized tools like Harmonizer and VTT. Qualitatively, it eliminates the "jagged edges" often seen in traditional masking.
- Generation Quality: In comparisons with state-of-the-art trajectory models like Tora and Revideo, GenCompositor demonstrated vastly superior identity consistency. It achieved a Fréchet Video Distance (FVD) of 535.71, nearly 50% better than the next best competitor.
- User Preference: In a user study, GenCompositor was preferred over 70% of the time for both harmonization and trajectory control tasks.
Limitations and Future Directions
While highly effective, GenCompositor still faces challenges in extreme lighting conditions where simple gamma correction is insufficient to match the foreground to the background. Additionally, it currently struggles with complex occlusions—for example, an added object moving behind a tree that already exists in the background video. Incorporating 3D priors or depth-aware features represents a promising direction for future research to handle these intricate "behind-the-scenes" interactions.
Summary updated