Overview
Initiates the video generation workflow that creates AI-powered video clips from images and compiles them into a final video with transitions and audio. This endpoint starts a background job via Trigger.dev that orchestrates the entire pipeline.Authentication
Requires an authenticated user session. Only the video project owner or workspace members can trigger compilation.Endpoint
Request Body
The ID of the video project to processExample:
"vp_abc123def456"Response
Whether the video generation was successfully triggered
Trigger.dev run ID for tracking progress
Token for accessing run progress via Trigger.dev API
Success or error message
Example Request
Example Response
Error Response
Video Generation Pipeline
Once triggered, the system executes these steps in order:Generate clips in parallel
Creates 5-second AI videos for each image using Kling AI model
- Processes up to 3 clips simultaneously
- Each clip takes 2-5 minutes
- Applies motion prompts for camera movement
Generate transitions
Creates seamless transition videos between clips (if enabled)
- Uses end frame of clip N and start frame of clip N+1
- Generates 1-second transition clips
Compile final video
Uses FFmpeg to merge all clips into final video
- Concatenates clips with transitions
- Mixes background music at specified volume
- Adds AI-generated ambient audio (if enabled)
- Exports in MP4 format (H.264)
Real-Time Progress Tracking
Use the returnedrunId and publicAccessToken to track progress:
Status Progression
The video projectstatus field updates throughout the process:
| Status | Description | Next Action |
|---|---|---|
draft | Initial state after creation | Trigger compilation |
generating | AI clips being generated | Wait for completion |
compiling | FFmpeg merging clips | Wait for completion |
completed | Video ready for download | Download from finalVideoUrl |
failed | Error occurred | Check errorMessage |
Background Task Implementation
Parallel Clip Processing
Clips are generated in batches of 3 for optimal performance:Cost Tracking
The system tracks costs throughout the process:Cost formula: Each 5-second clip costs 3.50.
Error Handling
Common errors and solutions:Video project not found
Video project not found
Ensure the
videoProjectId exists and belongs to your workspace.No clips to generate
No clips to generate
Add at least one clip to the video project before triggering compilation.
Kling AI timeout
Kling AI timeout
Clip generation can take 2-5 minutes. The system automatically retries failed clips up to 3 times.
FFmpeg compilation failed
FFmpeg compilation failed
Check that all clip URLs are accessible and video files are valid MP4 format.
Performance Considerations
- Parallel processing: Up to 3 clips generated simultaneously
- Queue management: One video compilation at a time to prevent resource exhaustion
- Timeout: 30-minute maximum duration per video
- Retry logic: Clip generation retries up to 3 times, orchestrator does not retry
Next Steps
Check Status
Monitor video generation progress
Create Project
Create a new video project