Implementation:ALwrity ALwrity PodcastVideoCombinationService combine videos
| Knowledge Sources | |
|---|---|
| Domains | Podcast, Video_Combination, File_Storage |
| Last Updated | 2026-10-24 00:00 GMT |
Overview
Concrete tool for combining multiple podcast scene videos with embedded audio into a single final episode video, provided by the ALwrity podcast subsystem.
Description
The PodcastVideoCombinationService.combine_videos method is stage 5 of the Podcast Creation Pipeline. It takes a list of scene video file paths (each with embedded audio), validates that the files exist, loads them with moviepy VideoFileClip, concatenates them with concatenate_videoclips, and writes the final video to a per-user workspace output directory (workspace/.../podcast_videos/Final_Videos/). The output is a dict with the file path, URL, total duration, and file size. A progress callback reports progress as each clip is loaded and concatenated. The service handles incomplete video encodings gracefully (MoviePy uses the last valid frame).
Usage
Import this service when:
- The podcast pipeline has composed B-roll scene videos and needs to combine them into a final episode.
- Each scene video already has embedded audio (no separate audio merge needed).
- Progress reporting is needed during the combination.
- Output must be written to the per-user workspace.
Code Reference
Source Location
- Repository: ALwrity
- File: backend/services/podcast/video_combination_service.py (L17-100+)
Signature
class PodcastVideoCombinationService:
"""Service for combining podcast scene videos into final episodes."""
def __init__(
self,
output_dir: Optional[str] = None,
user_id: Optional[str] = None,
):
"""
Initialize the podcast video combination service.
Args:
output_dir: Directory to save combined videos.
user_id: User ID for workspace-scoped output.
Either output_dir or user_id must be provided for workspace isolation.
"""
def combine_videos(
self,
video_paths: List[str],
podcast_title: str,
fps: int = 30,
progress_callback: Optional[callable] = None,
) -> Dict[str, Any]:
"""
Combine multiple video files into a single final podcast video.
Args:
video_paths: List of video file paths to combine.
podcast_title: Title of the podcast episode.
fps: Frames per second for output (default 30).
progress_callback: callback(progress: float, message: str).
Returns:
Dict with file_path, file_url, duration, file_size.
Raises:
ValueError: If no valid video files are provided.
RuntimeError: If video combination fails.
"""
Import
from services.podcast.video_combination_service import PodcastVideoCombinationService
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| video_paths | List[str] | Yes | Scene video file paths to combine |
| podcast_title | str | Yes | Episode title (used for filename) |
| fps | int | No | Output framerate (default 30) |
| progress_callback | callable | No | callback(progress: float, message: str) |
Outputs
| Name | Type | Description |
|---|---|---|
| return | Dict[str, Any] | file_path, file_url, duration, file_size |
| side effect | disk | Final video written to workspace output dir |
Usage Examples
Combining scene videos
from services.podcast.video_combination_service import PodcastVideoCombinationService
service = PodcastVideoCombinationService(user_id="clerk_user_123")
def on_progress(progress, message):
print(f" {progress:.0f}% — {message}")
result = service.combine_videos(
video_paths=["/tmp/scene_1.mp4", "/tmp/scene_2.mp4", "/tmp/scene_3.mp4"],
podcast_title="The future of open-source AI",
fps=30,
progress_callback=on_progress,
)
print(f"Final video: {result['file_path']}")
print(f"Duration: {result['duration']}s, Size: {result['file_size']} bytes")