The /caption-video endpoint adds captions to a video from an SRT or ASS file, allowing for easy subtitle embedding.
- URL:
/caption-video - Method:
POST
- X-API-Key (string, required): The API key used for authentication.
- video_url (string, required): URL of the video to which captions will be added.
- srt_url or ass_url (string, required): URL of the subtitle file in SRT or ASS format.
- webhook_url (string, optional): URL to receive the processed video link upon completion.
- id (string, optional): Unique identifier for tracking the job.
{
"video_url": "https://example.com/video.mp4",
"srt_url": "https://example.com/captions.srt",
"webhook_url": "https://your-webhook-url.com/notify",
"id": "caption123"
}curl -X POST "https://your-api-domain.com/caption-video" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"video_url": "https://example.com/video.mp4",
"srt_url": "https://example.com/captions.srt",
"webhook_url": "https://your-webhook-url.com/notify",
"id": "caption123"
}'If the captioning is successful and no webhook_url is provided:
- Status Code:
200 OK - Body:
{ "job_id": "caption123", "video_url": "https://cloud-storage-url.com/output_with_captions.mp4", "message": "success" }
If a webhook_url is provided, the request is queued, and this response is returned:
- Status Code:
202 Accepted - Body:
{ "job_id": "caption123", "message": "processing" }
- 400 Bad Request: Missing or invalid parameters (
video_url,srt_url, orass_url).{ "error": "Missing required video_url and subtitle file (srt_url or ass_url)" } - 500 Internal Server Error: Captioning process failed.
{ "error": "Error during video captioning" }
- 400 Bad Request: Returned if
video_urlor subtitle file (srt_urlorass_url) is missing or malformed. - 500 Internal Server Error: Returned if there’s an error during captioning.
- Either
srt_urlorass_urlmust be provided to add captions to the video. - The endpoint supports popular subtitle formats (SRT and ASS) for embedding captions.
- Invalid Video or Subtitle URL: Ensure
video_urland subtitle URL are valid and accessible. - Unsupported Subtitle Format: Use either SRT or ASS formats for compatibility.
- Asynchronous Processing: For large video files, use
webhook_urlto receive the processed video asynchronously. - Verify Subtitle Sync: Ensure the subtitle timing matches the video length and content for best results.