Environment:869413421 Ai moive studio FFmpeg
| Knowledge Sources | |
|---|---|
| Domains | Video, Multimedia, Infrastructure |
| Last Updated | 2026-10-23 14:00 GMT |
Overview
FFmpeg and ffprobe CLI tools required for all video composition, concatenation, speed adjustment, and BGM mixing operations.
Description
This environment requires the ffmpeg and ffprobe command-line executables to be installed and available on the system PATH. The backend uses subprocess calls to FFmpeg for per-sentence video synthesis (Ken Burns zoompan effect), crossfade video concatenation (xfade filter), video speed adjustment (setpts + atempo), BGM mixing (amix), and audio/video duration measurement (ffprobe). All operations use the libx264 video codec and AAC audio codec.
Usage
Use this environment for any Video Synthesis, Video Composition, or Movie Video Generation workflow. It is the mandatory prerequisite for running the FFmpeg_Utils, VideoCompositionService, and VideoSynthesisService implementations. The system checks FFmpeg availability at startup of video synthesis tasks via check_ffmpeg_installed().
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux / macOS / Windows | Cross-platform via subprocess |
| Hardware | CPU | No GPU required; FFmpeg uses software encoding (libx264) |
| Disk | 10GB+ temp space | Temporary video files during synthesis |
| Software | FFmpeg >= 4.4 | Requires xfade filter support (added in FFmpeg 4.3) |
Dependencies
System Packages
- `ffmpeg` >= 4.4 (must include libx264 encoder)
- `ffprobe` (bundled with ffmpeg)
Python Packages
- No Python packages — FFmpeg is invoked via subprocess.run
Credentials
No credentials required. FFmpeg is a local CLI tool.
Quick Install
# Ubuntu / Debian
sudo apt-get install -y ffmpeg
# macOS (Homebrew)
brew install ffmpeg
# Verify xfade filter support
ffmpeg -filters | grep xfade
Code Evidence
FFmpeg installation check from `ffmpeg_utils.py:19-66`:
def check_ffmpeg_installed() -> bool:
global _ffmpeg_installed_cache
if _ffmpeg_installed_cache is not None:
return _ffmpeg_installed_cache
if not shutil.which("ffmpeg"):
logger.error("FFmpeg命令未找到,请确保已安装并加入PATH")
_ffmpeg_installed_cache = False
return False
result = subprocess.run(
["ffmpeg", "-version"],
capture_output=True, text=True, timeout=20
)
if result.returncode == 0:
_ffmpeg_installed_cache = True
return True
ffprobe duration measurement from `ffmpeg_utils.py:69-104`:
def get_audio_duration(audio_path: str) -> Optional[float]:
result = subprocess.run(
["ffprobe", "-v", "error",
"-show_entries", "format=duration",
"-of", "default=noprint_wrappers=1:nokey=1",
audio_path],
capture_output=True, text=True, timeout=10
)
if result.returncode == 0:
duration = float(result.stdout.strip())
return duration
xfade filter usage from `ffmpeg_utils.py:442-449`:
xfade_filter = (
f"{current_video_label}[{i}:v]"
f"xfade=transition={transition_type}:"
f"duration={transition_duration}:"
f"offset={offset:.3f}"
f"{output_video_label}"
)
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `FFmpeg命令未找到` | ffmpeg not on PATH | Install ffmpeg and ensure it is in PATH |
| `FFmpeg检查超时(20秒)` | System under heavy load | Code assumes installed on timeout; investigate system load |
| `No such filter: 'xfade'` | FFmpeg version too old (< 4.3) | Upgrade to FFmpeg >= 4.4 |
| `视频拼接失败` | Incompatible video codecs/resolutions | Ensure all segments use same codec and resolution |
Compatibility Notes
- xfade filter: Requires FFmpeg >= 4.3. The crossfade concatenation mode depends on this filter.
- libx264: Must be compiled into FFmpeg. Most distribution packages include it, but minimal builds may not.
- Windows: The biliup binary uses `.exe` extension on Windows; FFmpeg path detection uses shutil.which() which works cross-platform.
- Timeout handling: FFmpeg check uses a 20-second timeout (increased from 5s). On timeout, the system assumes FFmpeg is installed to avoid blocking business operations under high load.
Related Pages
- Implementation:869413421_Ai_moive_studio_FFmpeg_Utils
- Implementation:869413421_Ai_moive_studio_VideoCompositionService_synthesize_sentence_video
- Implementation:869413421_Ai_moive_studio_VideoSynthesisService_synthesize_video
- Implementation:869413421_Ai_moive_studio_MovieVideoService_synthesize_movie_from_transitions