Implementation:869413421 Ai moive studio TransitionService batch create transitions
| Knowledge Sources | |
|---|---|
| Domains | Video, Generative_AI |
| Last Updated | 2026-10-23 12:00 GMT |
Overview
Service that batch-creates transition video prompt records between sequential intra-scene keyframes using an LLM, with concurrency control and incremental skip logic.
Description
TransitionService.batch_create_transitions loads all shots with keyframes from a script, ordered by scene and shot index. It then creates MovieShotTransition records for adjacent shots within the same scene (cross-scene transitions are skipped). Existing transitions are also skipped to support incremental processing.
For each transition, an LLM generates a video_prompt describing the motion transition between the from_shot and to_shot. Workers use a semaphore (default max 5) for concurrency. All successful transitions are committed in a single transaction.
Usage
Import when creating transition video prompts for AI movie generation. Called by the movie generation pipeline after keyframe generation.
Code Reference
Source Location
- Repository: ai-moive-studio
- File: backend/src/services/transition_service.py:L186-358
Signature
class TransitionService(BaseService):
async def batch_create_transitions(
self,
script_id: str,
api_key_id: str,
model: str = None,
max_concurrent: int = 5
) -> Dict[str, Any]:
"""
Args:
script_id: script UUID
api_key_id: API key UUID
model: LLM for prompt generation
max_concurrent: concurrency limit
Returns:
Dict with success, failed, skipped, total, message
"""
Import
from src.services.transition_service import TransitionService
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| script_id | str | Yes | Script UUID |
| api_key_id | str | Yes | API key UUID |
| model | str | No | LLM model for prompt generation |
| max_concurrent | int | No | Max concurrency (default 5) |
Outputs
| Name | Type | Description |
|---|---|---|
| return value | dict | {success, failed, skipped, total, message} |
| DB side effects | — | Creates MovieShotTransition records with video_prompt, status="pending" |
Usage Examples
Creating Transitions
from src.services.transition_service import TransitionService
service = TransitionService(db_session)
result = await service.batch_create_transitions(
script_id="script-uuid",
api_key_id="key-uuid",
model="gpt-4o",
)
print(f"Created {result['success']} transitions, skipped {result['skipped']}")