Use Cases
Use this skill when video post-processing is needed, including:
- Merge multiple videos: Composite multiple shot videos into one complete video
- Add audio: Add audio tracks such as voiceover and background music to a video
- Merge audio: Merge multiple audio files into one complete audio along the timeline
- Generate subtitles: Generate subtitle files in SRT format
- Burn subtitles: Hardcode subtitles into the video
- Video production: Post-production compositing of short videos, promotional videos, and instructional videos
Features
1. Merge multiple videos
- Supports concatenation of 2+ video files
- Automatically handles video encoding and format conversion
- Preserves original video quality
- Automatically preserves the original video's background music
2. Add audio tracks
- Supports adding voiceover dubbing
- Supports adding background music
- Adjustable audio volume (0.0-2.0x)
- Adjustable original video background music volume (0.0-2.0x)
- Background music and dialogue audio are automatically mixed
3. Merge multiple audio files
- Supports merging multiple audio files into one complete audio along the timeline
- Each audio can specify its own start time (seconds)
- Uses the amix filter for smooth audio mixing
4. Generate subtitles
- Supports generating standard SRT format subtitle files
- Supports multiple subtitle segments, each with independent start/end times
- UTF-8 encoding, supports Chinese subtitles
5. Burn subtitles
- Hardcode SRT subtitles into the video
- Requires ffmpeg to be compiled with libass (subtitles filter) support
- If the current environment does not support it, you can use other video editing tools (such as CapCut, etc.) to burn subtitles
6. Flexible operation modes
- merge mode: Merge multiple videos (audio can be added at the same time)
- add-audio mode: Add audio to an existing video
- merge-audios mode: Merge multiple audio files
- generate-srt mode: Generate an SRT subtitle file
- burn-subtitles mode: Burn subtitles into the video
System Requirements
Install ffmpeg
Ubuntu/Debian:
sudo apt install ffmpeg
macOS:
brew install ffmpeg
Verify installation:
ffmpeg -version
Usage Steps
Mode 1: Merge multiple videos
Basic usage:
python scripts/video_editor.py output.mp4 --videos video1.mp4 video2.mp4 video3.mp4
Merge with audio:
python scripts/video_editor.py output.mp4 --videos v1.mp4 v2.mp4 v3.mp4 --audio narration.mp3
Adjust audio volume:
# 对白音频音量为 0.8 倍(降低 20%)
python scripts/video_editor.py output.mp4 --videos v1.mp4 v2.mp4 --audio dialogue.mp3 --volume 0.8
# 对白音频音量为 1.5 倍(提高 50%)
python scripts/video_editor.py output.mp4 --videos v1.mp4 v2.mp4 --audio dialogue.mp3 --volume 1.5
# 同时调整背景音乐音量为 0.5 倍
python scripts/video_editor.py output.mp4 --videos v1.mp4 v2.mp4 --audio dialogue.mp3 --volume 0.8 --bg-volume 0.5
Mode 2: Add audio to an existing video
Basic usage:
python scripts/video_editor.py output.mp4 --video input.mp4 --audio narration.mp3 --mode add-audio
Adjust volume:
python scripts/video_editor.py output.mp4 --video input.mp4 --audio background.mp3 --volume 0.5 --mode add-audio
Mode 3: Merge multiple audio files
Basic usage:
python scripts/video_editor.py output.mp3 --audios audio1.mp3,audio2.mp3 --start-times 0,5 --mode merge-audios
Parameter description:
--audios: List of audio files to merge, separated by commas--start-times: Start time of each audio (seconds), separated by commas- The lengths of the two lists must be the same
Mode 4: Generate SRT subtitle file
Basic usage:
python scripts/video_editor.py output.srt --subtitles '[{"text":"你好","start_time":0,"end_time":2},{"text":"世界","start_time":2.5,"end_time":5}]' --mode generate-srt
Parameter description:
--subtitles: Subtitle data in JSON format, each subtitle contains:text: Subtitle textstart_time: Start time (seconds)end_time: End time (seconds)
Mode 5: Burn subtitles into video
Basic usage:
python scripts/video_editor.py output_with_subs.mp4 --video input.mp4 --subtitle subs.srt --mode burn-subtitles
Note:
- Subtitle style parameters are reserved, but the actual effect depends on ffmpeg's subtitles filter configuration
- If the current environment does not support the subtitles filter, it is recommended to:
- Use professional video editing software (Final Cut Pro, Premiere, CapCut, etc.)
- Use online video tools (such as Kapwing, Clideo, etc.)
Parameter description
| Parameter | Description | Example |
|---|---|---|
output |
Output file path | final_video.mp4 |
--videos |
List of video files to merge (2+ files) | --videos v1.mp4 v2.mp4 v3.mp4 |
--video |
Single video file (add-audio or burn-subtitles mode) | --video input.mp4 |
--audio |
Single audio file (narration, dialogue, etc.) | --audio narration.mp3 |
--audios |
List of audio files to merge (comma-separated) | --audios a1.mp3,a2.mp3 |
--start-times |
Start time of each audio (comma-separated, seconds) | --start-times 0,5 |
--volume |
Dialogue audio volume (0.0-2.0, default 1.0) | --volume 0.8 |
--bg-volume |
Background music volume (0.0-2.0, default 1.0) | --bg-volume 0.5 |
--subtitles |
Subtitle data (JSON format, generate-srt mode) | --subtitles '[{\"text\":\"你好\",\"start_time\":0,\"end_time\":2}]' |
--subtitle |
SRT subtitle file path (burn-subtitles mode) | --subtitle subs.srt |
--font-name |
Subtitle font name | --font-name "Arial" |
--font-size |
Subtitle font size | --font-size 24 |
--font-color |
Subtitle font color | --font-color "&H00FFFFFF" |
--outline-color |
Subtitle border color | --outline-color "&H00000000" |
--outline |
Subtitle border width | --outline 2 |
--shadow |
Subtitle shadow depth | --shadow 0 |
--alignment |
Subtitle alignment | --alignment 2 |
--mode |
Operation mode: merge, add-audio, merge-audios, generate-srt, burn-subtitles | --mode generate-srt |
Practical examples
Example 1: AI short drama composition
Suppose there are 3 storyboard videos:
shot1.mp4(5 seconds)shot2.mp4(10 seconds)shot3.mp4(10 seconds)
Compose a version without narration:
python scripts/video_editor.py drama_no_audio.mp4 --videos shot1.mp4 shot2.mp4 shot3.mp4
Compose a version with narration:
python scripts/video_editor.py drama_with_audio.mp4 --videos shot1.mp4 shot2.mp4 shot3.mp4 --audio narration.mp3
Example 2: Add background music
Add background music to an existing video and lower the volume:
python scripts/video_editor.py video_with_music.mp4 --video original.mp4 --audio bgm.mp3 --volume 0.4 --mode add-audio
Example 3: Merge multiple dialogue audio tracks
Suppose there are 3 dialogue audio files, played at different time points:
line1.mp3(starts at 0 seconds)line2.mp3(starts at 5 seconds)line3.mp3(starts at 12 seconds)
Merge into one complete audio:
python scripts/video_editor.py full_narration.mp3 --audios line1.mp3,line2.mp3,line3.mp3 --start-times 0,5,12 --mode merge-audios
Example 4: Generate SRT subtitle file
Suppose there are two lines of dialogue:
- "Hello World" (0-2 seconds)
- "Welcome to the comic drama" (2.5-5 seconds)
**Generate subtitle file:
python scripts/video_editor.py drama_subs.srt --subtitles '[{"text":"你好世界","start_time":0,"end_time":2},{"text":"欢迎来到漫剧","start_time":2.5,"end_time":5}]' --mode generate-srt
Example 5: Burn subtitles into video
Burn using default style:
python scripts/video_editor.py drama_with_subs.mp4 --video drama.mp4 --subtitle drama_subs.srt --mode burn-subtitles
Note: If the environment does not support the burn function, please directly use the generated SRT subtitle file together with video editing software such as CapCut and Final Cut Pro to complete subtitle burning!