Video Generation Service
Relevant source files
The following files were used as context for generating this wiki page:
The Video Generation Service is a specialized microservice within the Aether-X Ultimate platform designed for video synthesis and Text-to-Speech (TTS) processing. Its primary role is to transform text and image prompts into multimedia content by generating synchronized voiceovers and visual sequences.
As part of the broader microservices architecture, it operates on port 8002 and integrates with the system's storage and messaging infrastructure to deliver real-time content. It relies on the API Gateway for external request routing and rate limiting.
Sources: IMPLEMENTATION_COMPLETE.md:14, services/api-gateway/app.py:16, docker-compose.yml:45-48
Service Architecture and Workflow
The service is built using the Flask web framework and utilizes gTTS (Google Text-to-Speech) for audio generation and moviepy for video assembly. The architecture follows a stateless pattern where each request is processed using temporary directories to store intermediate artifacts before returning a final base64-encoded output.
Internal Data Flow
When a video generation request is received, the service executes a multi-step pipeline:
- Audio Generation: Converts input text into an MP3 voiceover.
- Visual Processing: Generates or retrieves images based on provided prompts.
- Synthesis: Synchronizes the audio track with the image sequence, looping audio if necessary to match the visual duration.
- Encoding: Exports the final video as an MP4 file (using H.264 codec) and encodes it to base64 for transmission.
Sources: services/video-generation/app.py:10-50, services/video-generation/app.py:90-110
The diagram above illustrates the internal logic of the /generate endpoint, emphasizing the sequential transformation of text and prompts into a multimedia file.
Sources: services/video-generation/app.py:53-102
API Reference
The service exposes endpoints for both full video synthesis and standalone text-to-speech conversion.
Endpoints Summary
| Endpoint | Method | Description | Parameters |
|---|---|---|---|
/health | GET | Returns service status | None |
/generate | POST | Generates a full MP4 video | text, image_prompts |
/text-to-speech | POST | Generates an MP3 audio file | text, lang |
Sources: services/video-generation/app.py:49-140
Request Schema: Video Generation
The /generate endpoint requires a JSON payload containing the script and visual cues.
{
"text": "Script for the voiceover",
"image_prompts": ["Prompt 1", "Prompt 2"]
}
Sources: services/video-generation/app.py:56-63
Infrastructure and Deployment
The service is containerized using Docker and is configured for orchestration via Kubernetes. It has specific resource requirements to handle the CPU-intensive nature of video rendering.
Resource Configuration
| Environment | Configuration Property | Value |
|---|---|---|
| Docker | Port | 8002 |
| Docker | Dependencies | redis, mongodb |
| Kubernetes | Replicas | 2 |
| Kubernetes | CPU Request/Limit | 500m / 1000m |
| Kubernetes | Memory Request/Limit | 1Gi / 2Gi |
Sources: docker-compose.yml:49-62, k8s/deployment.yaml:94-118
Integration with API Gateway
The API Gateway provides a unified entry point for the Video Generation Service, implementing specific rate limits to prevent resource exhaustion during heavy rendering tasks.
This sequence shows the interaction between the Client, API Gateway, and the Video Generation Service, highlighting the 20 requests per minute rate limit enforced at the gateway.
Sources: services/api-gateway/app.py:155-165, services/api-gateway/app.py:19
Implementation Details
Multimedia Synthesis Logic
The core synthesis is handled by create_video_from_images_and_audio. It creates ImageClip objects for each image path, sets their duration by dividing the total video duration (defaulting to 5 seconds) by the number of images, and uses afx.audio_loop to ensure the audio matches the video length perfectly.
Sources: services/video-generation/app.py:14-30
Testing and Validation
The service includes health check endpoints used by Docker and Kubernetes for liveness and readiness probes. Integration tests are performed by the platform's test suite to ensure the generation pipeline remains functional.
Sources: test.sh:34-45, k8s/deployment.yaml:120-132
Summary
The Video Generation Service provides a critical multimedia capability to the Aether-X Ultimate platform. By combining gTTS for audio and MoviePy for video composition, it allows for the automated creation of content from natural language descriptions. Its deployment configuration ensures that the service can scale independently to meet the processing demands of video rendering.
Sources: IMPLEMENTATION_COMPLETE.md:14, services/video-generation/app.py:146