KS
Killer-Skills

bgm — how to use bgm how to use bgm, bgm alternative, bgm setup guide, what is bgm, bgm vs Remotion, automated video generation, edge-tts integration, Playwright automation, free music sources for videos

v1.0.0
GitHub

About this Skill

Perfect for Media Generation Agents needing automated product introduction videos with customizable background music. bgm is an AI agent skill for automated product introduction video generation with Remotion, Playwright, and edge-tts, utilizing free music sources like Pixabay Music and Free Music Archive.

Features

Utilizes Remotion for video generation
Leverages Playwright for automated browser interactions
Integrates edge-tts for text-to-speech functionality
Supports various music sources like Pixabay Music and Free Music Archive
Allows for music style selection based on video type, such as Epic and Corporate
Provides a recommendation for free music sources, including Pixabay Music

# Core Topics

MatrixReligio MatrixReligio
[20]
[5]
Updated: 2/23/2026

Quality Score

Top 5%
36
Excellent
Based on code quality & docs
Installation
SYS Universal Install (Auto-Detect)
Cursor IDE Windsurf IDE VS Code IDE
> npx killer-skills add MatrixReligio/ProductVideoCreator/bgm

Agent Capability Analysis

The bgm MCP Server by MatrixReligio is an open-source Categories.community integration for Claude and other AI agents, enabling seamless task automation and capability expansion. Optimized for how to use bgm, bgm alternative, bgm setup guide.

Ideal Agent Persona

Perfect for Media Generation Agents needing automated product introduction videos with customizable background music.

Core Value

Empowers agents to generate engaging videos using Remotion, Playwright, and edge-tts, with access to various music styles and sources like Pixabay Music, Free Music Archive, and Uppbeat, utilizing protocols for seamless integration.

Capabilities Granted for bgm MCP Server

Automating product introduction video creation with epic cinematic music
Generating corporate videos with upbeat background tracks
Customizing video music styles using keyword searches like 'technology' and 'corporate'

! Prerequisites & Limits

  • Requires Remotion, Playwright, and edge-tts setup
  • Limited to free music sources with potential attribution requirements
  • Dependent on internet connection for music source access
Project
SKILL.md
14.3 KB
.cursorrules
1.2 KB
package.json
240 B
Ready
UTF-8

# Tags

[No tags]
SKILL.md
Readonly

背景音乐技能

免版权音乐来源

来源网址特点
Pixabay Musichttps://pixabay.com/music/完全免费,无需署名
Free Music Archivehttps://freemusicarchive.org/CC 授权,部分需署名
Uppbeathttps://uppbeat.io/免费版每月限量
Mixkithttps://mixkit.co/free-stock-music/完全免费

推荐: Pixabay Music (无需署名,商用免费)

音乐风格选择

视频类型推荐风格关键词搜索
科技历程Epic, Cinematic"epic cinematic", "technology"
产品介绍Corporate, Upbeat"corporate", "business"
教程视频Ambient, Soft"ambient", "background"
发布会Inspiring, Motivational"inspiring", "motivational"
创意内容Modern, Electronic"modern", "electronic"

FFmpeg 音频混合

基础混合(配音优先)

bash
1# 将 BGM 与配音混合,BGM 音量降低 2# 配音密集时推荐 volume=0.05,配音稀疏时可用 0.08-0.10 3ffmpeg -i voiceover.mp3 -i bgm.mp3 \ 4 -filter_complex "[1:a]volume=0.05[bgm];[0:a][bgm]amix=inputs=2:duration=first[out]" \ 5 -map "[out]" mixed_audio.mp3

带淡入淡出效果

bash
1# BGM 淡入3秒,淡出3秒 2ffmpeg -i voiceover.mp3 -i bgm.mp3 \ 3 -filter_complex " 4 [1:a]volume=0.05,afade=t=in:st=0:d=3,afade=t=out:st=82:d=3[bgm]; 5 [0:a][bgm]amix=inputs=2:duration=first[out] 6 " \ 7 -map "[out]" mixed_audio.mp3

完整音频处理流程

bash
1# 1. 处理 BGM(循环、淡入淡出、降低音量) 2ffmpeg -stream_loop -1 -i bgm_original.mp3 \ 3 -t 85 \ 4 -af "volume=0.05,afade=t=in:st=0:d=3,afade=t=out:st=82:d=3" \ 5 bgm_processed.mp3 6 7# 2. 混合配音和 BGM 8ffmpeg -i voiceover.mp3 -i bgm_processed.mp3 \ 9 -filter_complex "[0:a][1:a]amix=inputs=2:duration=first[out]" \ 10 -map "[out]" final_audio.mp3 11 12# 3. 音量标准化 13ffmpeg -i final_audio.mp3 \ 14 -af "loudnorm=I=-16:TP=-1.5:LRA=11" \ 15 final_audio_normalized.mp3

音量平衡建议

核心原则

配音清晰度优先:BGM 必须作为"背景"存在,绝不能盖过配音。人声频率(85-255Hz基频 + 泛音)与 BGM 重叠时尤其需要注意。

音频类型相对音量说明
配音1.0 (100%)主音频,保持原音量
BGM(有密集配音)0.05-0.08确保配音清晰可辨
BGM(有稀疏配音)0.08-0.12配音间隙较多时
BGM(无配音段落)0.15-0.25片头/片尾/转场
BGM(纯音乐段落)0.30-0.50无配音时可提高

音量选择决策树

视频有配音吗?
├── 是 → 配音密度高吗(>70%时间有语音)?
│   ├── 是 → BGM volume = 0.05-0.06 (推荐 0.05)
│   └── 否 → BGM volume = 0.08-0.10
└── 否 → BGM volume = 0.25-0.40

测试方法

在正式渲染前,截取30秒包含配音的片段测试:

bash
1# 快速测试不同音量 2for vol in 0.04 0.05 0.06 0.08; do 3 ffmpeg -y -i bgm.mp3 -i voiceover.mp3 \ 4 -filter_complex "[0:a]volume=$vol[bgm];[1:a][bgm]amix=inputs=2[out]" \ 5 -map "[out]" -t 30 test_vol_$vol.mp3 6done

动态音量控制(高级)

bash
1# 配音出现时自动降低 BGM(侧链压缩效果) 2ffmpeg -i voiceover.mp3 -i bgm.mp3 \ 3 -filter_complex " 4 [0:a]asplit=2[vo][vo_sidechain]; 5 [1:a]volume=0.3[bgm]; 6 [bgm][vo_sidechain]sidechaincompress=threshold=0.02:ratio=8:attack=50:release=500[bgm_ducked]; 7 [vo][bgm_ducked]amix=inputs=2:duration=first[out] 8 " \ 9 -map "[out]" ducked_audio.mp3

智能 BGM 长度计算

问题:无脑循环的弊端

简单的 -stream_loop -1 会导致:

  • BGM 在非自然位置截断
  • 音乐节奏与视频内容不匹配
  • 循环接缝处听感不自然

解决方案:场景感知的 BGM 选择

策略 1: 选择合适长度的音乐

优先选择时长接近或略长于视频的 BGM:

视频时长推荐 BGM 时长策略
< 60s60-90s单曲裁剪
60-120s90-180s单曲裁剪 + 淡出
120-300s180-360s单曲或精心设计的接缝
> 300s多首拼接场景转换处切换

策略 2: 基于场景结构计算

python
1# 场景时间配置 2SCENES = { 3 "opening": {"start": 0, "duration": 8}, # 片头 4 "scene1": {"start": 8, "duration": 14}, # 场景1 5 "scene2": {"start": 22, "duration": 16}, # 场景2 6 "scene3": {"start": 38, "duration": 14}, # 场景3 7 "scene4": {"start": 52, "duration": 20}, # 场景4 8 "closing": {"start": 72, "duration": 13}, # 片尾 9} 10 11def calculate_bgm_strategy(scenes: dict, bgm_duration: float, video_duration: float): 12 """ 13 计算 BGM 使用策略 14 15 Returns: 16 dict: 包含 trim_end, need_loop, loop_point 等信息 17 """ 18 if bgm_duration >= video_duration: 19 # BGM 够长,直接裁剪 20 return { 21 "strategy": "single_trim", 22 "trim_end": video_duration, 23 "need_loop": False 24 } 25 26 # BGM 不够长,找最佳循环点(场景边界) 27 scene_boundaries = sorted([s["start"] for s in scenes.values()]) 28 29 # 找到最接近 BGM 时长的场景边界 30 best_loop_point = min( 31 scene_boundaries, 32 key=lambda x: abs(x - bgm_duration) if x <= bgm_duration else float('inf') 33 ) 34 35 return { 36 "strategy": "scene_aware_loop", 37 "loop_point": best_loop_point, 38 "bgm_duration": bgm_duration, 39 "loops_needed": math.ceil(video_duration / best_loop_point) 40 }

策略 3: 动态音量适配场景

不同场景使用不同 BGM 音量:

python
1# 场景音量配置 2SCENE_VOLUMES = { 3 "opening": 0.15, # 片头无配音,音量较高 4 "scene1": 0.05, # 有配音场景 5 "scene2": 0.05, 6 "scene3": 0.05, 7 "scene4": 0.05, 8 "closing": 0.12, # 片尾配音较少 9} 10 11def generate_volume_filter(scenes: dict, volumes: dict, fps: int = 30): 12 """生成 FFmpeg 音量自动化滤镜""" 13 points = [] 14 for name, scene in scenes.items(): 15 start_frame = scene["start"] * fps 16 vol = volumes.get(name, 0.05) 17 points.append(f"volume=enable='between(t,{scene['start']},{scene['start']+scene['duration']})':volume={vol}") 18 19 return ",".join(points)

FFmpeg 场景感知混合

bash
1# 使用 aeval 实现场景动态音量 2# 片头(0-8s): 0.15, 正片(8-72s): 0.05, 片尾(72-85s): 0.12 3 4ffmpeg -i voiceover.mp3 -i bgm.mp3 \ 5 -filter_complex " 6 [1:a]volume='if(lt(t,8),0.15,if(lt(t,72),0.05,0.12))':eval=frame, 7 afade=t=in:st=0:d=3, 8 afade=t=out:st=82:d=3[bgm]; 9 [0:a][bgm]amix=inputs=2:duration=first[out] 10 " \ 11 -map "[out]" mixed_audio.mp3

最佳实践

  1. 优先选择时长合适的 BGM:避免循环,选择 >= 视频时长的音乐
  2. 如果必须循环:在场景转换处设置循环点,而非音乐结尾
  3. 场景边界淡入淡出:循环接缝处使用交叉淡化
  4. 动态音量:片头片尾可略高,配音密集段落降低

Remotion 动态音量控制 (推荐)

除了使用 FFmpeg 预处理,还可以在 Remotion 中直接实现动态音量控制。这种方式更灵活,便于调试。

基础用法:场景感知音量

tsx
1import { Audio, staticFile, useCurrentFrame, useVideoConfig } from "remotion"; 2import { SCENES } from "./config/scenes"; 3 4// 场景音量配置 5const SCENE_VOLUMES = { 6 opening: 0.15, // 片头无配音,音量较高 7 scene1: 0.05, // 有配音场景 8 scene2: 0.05, 9 scene3: 0.05, 10 scene4: 0.05, 11 closing: 0.12, // 片尾配音较少 12}; 13 14// 动态音量函数 15const getDynamicVolume = (frame: number, fps: number): number => { 16 const currentTime = frame / fps; 17 18 // 遍历场景找到当前所在场景 19 for (const [sceneName, scene] of Object.entries(SCENES)) { 20 const sceneEnd = scene.start + scene.duration; 21 if (currentTime >= scene.start && currentTime < sceneEnd) { 22 return SCENE_VOLUMES[sceneName as keyof typeof SCENE_VOLUMES] ?? 0.05; 23 } 24 } 25 return 0.05; // 默认音量 26}; 27 28// 在组件中使用 29export const VideoWithDynamicBGM: React.FC = () => { 30 const { fps } = useVideoConfig(); 31 32 return ( 33 <> 34 {/* 配音 - 固定音量 */} 35 <Audio src={staticFile("audio/voiceover.mp3")} volume={1} /> 36 37 {/* BGM - 动态音量 */} 38 <Audio 39 src={staticFile("audio/bgm.mp3")} 40 volume={(frame) => getDynamicVolume(frame, fps)} 41 /> 42 </> 43 ); 44};

进阶用法:平滑过渡

tsx
1import { interpolate } from "remotion"; 2 3const getSmoothVolume = (frame: number, fps: number): number => { 4 const currentTime = frame / fps; 5 6 // 片头 (0-8s): 0.15 -> 片头结束前0.5s开始降低 7 if (currentTime < 7.5) return 0.15; 8 if (currentTime < 8) { 9 return interpolate(currentTime, [7.5, 8], [0.15, 0.05]); 10 } 11 12 // 正片 (8-71.5s): 0.05 13 if (currentTime < 71.5) return 0.05; 14 15 // 正片结束 -> 片尾 (71.5-72s): 平滑过渡到 0.12 16 if (currentTime < 72) { 17 return interpolate(currentTime, [71.5, 72], [0.05, 0.12]); 18 } 19 20 // 片尾 (72-85s): 0.12 21 return 0.12; 22};

组件模板

tsx
1// components/DynamicBGM.tsx 2import React from "react"; 3import { Audio, staticFile, useVideoConfig } from "remotion"; 4 5interface DynamicBGMProps { 6 /** BGM 文件路径 (相对于 public/) */ 7 src: string; 8 /** 场景音量配置 */ 9 sceneVolumes: Record<string, number>; 10 /** 场景时间配置 */ 11 scenes: Record<string, { start: number; duration: number }>; 12 /** 是否启用平滑过渡 (默认 true) */ 13 smoothTransition?: boolean; 14 /** 过渡时长 (秒, 默认 0.5) */ 15 transitionDuration?: number; 16} 17 18export const DynamicBGM: React.FC<DynamicBGMProps> = ({ 19 src, 20 sceneVolumes, 21 scenes, 22 smoothTransition = true, 23 transitionDuration = 0.5, 24}) => { 25 const { fps } = useVideoConfig(); 26 27 const getVolume = (frame: number): number => { 28 const currentTime = frame / fps; 29 30 for (const [sceneName, scene] of Object.entries(scenes)) { 31 const sceneEnd = scene.start + scene.duration; 32 if (currentTime >= scene.start && currentTime < sceneEnd) { 33 return sceneVolumes[sceneName] ?? 0.05; 34 } 35 } 36 return 0.05; 37 }; 38 39 return ( 40 <Audio 41 src={staticFile(src)} 42 volume={(frame) => getVolume(frame)} 43 /> 44 ); 45};

FFmpeg vs Remotion 对比

方面FFmpeg 预处理Remotion 动态控制
调试便捷性⚠️ 需重新处理音频✅ 实时预览
灵活性⚠️ 固定一次✅ 随时调整
渲染性能✅ 无额外开销⚠️ 微小开销
文件大小⚠️ 预混合体积大✅ 分离存储
推荐场景最终交付开发调试

建议工作流

  1. 开发阶段使用 Remotion 动态控制快速调试
  2. 确定最终参数后,使用 FFmpeg 预处理生成交付版本

Python 脚本模板

python
1#!/usr/bin/env python3 2""" 3背景音乐处理脚本 4""" 5 6import subprocess 7from pathlib import Path 8 9def process_bgm( 10 bgm_path: str, 11 voiceover_path: str, 12 output_path: str, 13 video_duration: float, 14 bgm_volume: float = 0.05, # 默认低音量,确保配音清晰 15 fade_duration: float = 3.0 16): 17 """ 18 处理背景音乐并与配音混合 19 20 Args: 21 bgm_path: BGM 文件路径 22 voiceover_path: 配音文件路径 23 output_path: 输出文件路径 24 video_duration: 视频总时长(秒) 25 bgm_volume: BGM 相对音量 (0.0-1.0) 26 fade_duration: 淡入淡出时长(秒) 27 """ 28 fade_out_start = video_duration - fade_duration 29 30 # 构建 filter_complex 31 filter_complex = f""" 32 [1:a]aloop=loop=-1:size=2e+09,atrim=0:{video_duration}, 33 volume={bgm_volume}, 34 afade=t=in:st=0:d={fade_duration}, 35 afade=t=out:st={fade_out_start}:d={fade_duration}[bgm]; 36 [0:a][bgm]amix=inputs=2:duration=first[out] 37 """.replace("\n", "").replace(" ", "") 38 39 cmd = [ 40 "ffmpeg", "-y", 41 "-i", voiceover_path, 42 "-i", bgm_path, 43 "-filter_complex", filter_complex, 44 "-map", "[out]", 45 output_path 46 ] 47 48 subprocess.run(cmd, check=True) 49 print(f"✓ 混合音频输出: {output_path}") 50 51def normalize_audio(input_path: str, output_path: str): 52 """音量标准化到 -16 LUFS""" 53 cmd = [ 54 "ffmpeg", "-y", 55 "-i", input_path, 56 "-af", "loudnorm=I=-16:TP=-1.5:LRA=11", 57 output_path 58 ] 59 subprocess.run(cmd, check=True) 60 print(f"✓ 标准化输出: {output_path}") 61 62# 使用示例 63if __name__ == "__main__": 64 process_bgm( 65 bgm_path="public/audio/bgm_epic.mp3", 66 voiceover_path="public/audio/synced_voiceover.mp3", 67 output_path="public/audio/mixed_audio.mp3", 68 video_duration=85, 69 bgm_volume=0.05, # 配音密集时推荐 0.05 70 fade_duration=3.0 71 ) 72 73 normalize_audio( 74 input_path="public/audio/mixed_audio.mp3", 75 output_path="public/audio/final_audio.mp3" 76 )

Remotion 集成

在 Remotion 组件中使用混合后的音频:

tsx
1import { Audio, staticFile } from "remotion"; 2 3export const FinalVideo: React.FC = () => { 4 return ( 5 <> 6 {/* 使用混合后的音频(配音 + BGM) */} 7 <Audio src={staticFile("audio/final_audio.mp3")} volume={1} /> 8 9 {/* 或者分开控制 */} 10 <Audio src={staticFile("audio/synced_voiceover.mp3")} volume={1} /> 11 <Audio 12 src={staticFile("audio/bgm.mp3")} 13 volume={(f) => { 14 // 淡入淡出控制 15 const fps = 30; 16 if (f < 3 * fps) return (f / (3 * fps)) * 0.12; 17 if (f > 82 * fps) return ((85 * fps - f) / (3 * fps)) * 0.12; 18 return 0.12; 19 }} 20 /> 21 </> 22 ); 23};

工作流程

1. 确定视频风格 → 选择音乐关键词
2. 从免版权网站下载 BGM
3. 处理 BGM(循环/裁剪到视频时长)
4. 添加淡入淡出效果
5. 与配音混合(配音优先)
6. 音量标准化
7. 集成到视频

常见问题

问题解决方案
BGM 太响干扰配音降低 volume 到 0.04-0.06(配音密集时推荐 0.05)
BGM 不够长优先选择更长的音乐;必须循环时在场景边界处接缝
淡入淡出太突然增加 fade_duration 到 4-5 秒
混合后音量不一致使用 loudnorm 滤镜标准化
风格不匹配重新选择更合适的 BGM
循环接缝明显使用交叉淡化或在场景转换处设置循环点

Related Skills

Looking for an alternative to bgm or building a Categories.community AI Agent? Explore these related open-source MCP Servers.

View All

widget-generator

Logo of f
f

widget-generator is an open-source AI agent skill for creating widget plugins that are injected into prompt feeds on prompts.chat. It supports two rendering modes: standard prompt widgets using default PromptCard styling and custom render widgets built as full React components.

149.6k
0
Design

chat-sdk

Logo of lobehub
lobehub

chat-sdk is a unified TypeScript SDK for building chat bots across multiple platforms, providing a single interface for deploying bot logic.

73.0k
0
Communication

zustand

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
Communication

data-fetching

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
Communication