Diff-BGM: A Diffusion Model for Video Background Music Generation

Sizhe Li, Yiming Qin, Minghang Zheng, Xin Jin, Yang LiuCVPR 2024 · DOI

Abstract

Generating background music (BGM) that aligns with both the semantic content and temporal dynamics of a video remains a significant challenge. We present Diff-BGM, a diffusion-based framework that decouples musical elements to achieve precise control. By utilizing semantic features to guide melody and dynamic features to guide rhythm across different stages of the diffusion process, Diff-BGM ensures high-quality, synchronized music generation. We also introduce BGM909, a comprehensive dataset of video-piano pairs with dense annotations to facilitate research in this domain.

Introduction

The creation of background music is a sophisticated task where the audio must complement the visual narrative. While existing AI models have made progress, they often struggle with "free-style" videos—such as travel vlogs or cinematic shorts—where rhythmic cues are not as obvious as in dance or sports videos. These challenges stem from two primary issues: the scarcity of high-quality, aligned video-music datasets and the difficulty of controlling multi-faceted musical elements like melody and rhythm simultaneously.

Conceptual overview of the Diff-BGM model, illustrating the multi-stage diffusion process guided by melody and rhythm features.

Methodology

Diff-BGM is built upon a latent diffusion model, specifically a modified version of Polyffusion, designed to generate MIDI-style piano rolls. The framework introduces two core innovations to address alignment and control.

Multi-Stage Feature Selection

The researchers observed that the diffusion denoising process naturally progresses from global structure to local detail. The Feature Selector exploits this by injecting different visual signals at specific timesteps:

  • Early Stages (High Timesteps): Semantic features, derived from text captions, guide the global melody and atmosphere.
  • Later Stages (Low Timesteps): Dynamic video features refine the local rhythm and timing, ensuring the music hits visual beats.

Segment-Aware Cross-Attention (SAC-Attn)

To maintain tight temporal synchronization, Diff-BGM replaces standard global attention with Segment-Aware Cross-Attention. By partitioning the video into $k$-frame segments and applying a masked attention mechanism, the model focuses on local temporal contexts. This ensures that musical transitions align precisely with camera cuts and shot changes.

Detailed architecture of the Diff-BGM framework, including the Feature Selector and Segment-Aware Cross-Attention modules.

The BGM909 Dataset

To overcome data scarcity, the authors released BGM909, bridging the gap between the POP909 piano dataset and real-world video. It contains 909 piano pieces paired with official music videos, featuring dense annotations including MIDI files, beats, key signatures, and natural language descriptions for every 8 frames.

Results and Discussion

Diff-BGM was evaluated against state-of-the-art models like CMT and Riffusion. Quantitatively, it achieved a 44.10% Retrieval Precision (P@20) on the BGM909 test set, significantly outperforming the 36.40% achieved by CMT. Qualitative user studies further validated these results, with participants preferring Diff-BGM 77.8% of the time, citing superior rhythm correspondence and accompaniment quality.

Ablation studies confirmed that both the Feature Selector and the SAC-Attn layer are critical for maintaining the balance between musicality and visual alignment.

Conclusion

Diff-BGM represents a significant step forward in automated BGM generation by decoupling melody and rhythm control within a diffusion framework. While currently focused on piano music, the modular nature of the architecture provides a foundation for future expansion into multi-instrumental generation and direct raw audio synthesis.

Summary updated

BibTeX
@inproceedings{li2024diff,
  author = {Sizhe Li and Yiming Qin and Minghang Zheng and Xin Jin and Yang Liu},
  title = {{Diff-BGM: A Diffusion Model for Video Background Music Generation}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2024},
  doi = {10.1109/cvpr52733.2024.02582},
}
Figure