Skip to content

Commit 72f1c57

Browse files
Stephen G. PopeStephen G. Pope
authored andcommitted
fix to captions docs
1 parent 0f53f32 commit 72f1c57

1 file changed

Lines changed: 93 additions & 41 deletions

File tree

docs/video/caption_video.md

Lines changed: 93 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ The `/v1/video/caption` endpoint is part of the Video API and is responsible for
2020
The request body must be a JSON object with the following properties:
2121

2222
- `video_url` (string, required): The URL of the video file to be captioned.
23-
- `captions` (string, optional): The caption text to be added to the video.
23+
- `captions` (string, optional): Can be one of the following:
24+
- Raw caption text to be added to the video
25+
- URL to an SRT subtitle file
26+
- URL to an ASS subtitle file
27+
- If not provided, the system will automatically generate captions by transcribing the audio from the video
2428
- `settings` (object, optional): An object containing various styling options for the captions. See the schema below for available options.
2529
- `replace` (array, optional): An array of objects with `find` and `replace` properties, specifying text replacements to be made in the captions.
2630
- `webhook_url` (string, optional): A URL to receive a webhook notification when the captioning process is complete.
@@ -60,7 +64,13 @@ The request body must be a JSON object with the following properties:
6064
"strikeout": {"type": "boolean"},
6165
"style": {
6266
"type": "string",
63-
"enum": ["classic", "karaoke", "highlight", "underline", "word_by_word"]
67+
"enum": [
68+
"classic", // Regular captioning with all text displayed at once
69+
"karaoke", // Highlights words sequentially in a karaoke style
70+
"highlight", // Shows full text but highlights the current word
71+
"underline", // Shows full text but underlines the current word
72+
"word_by_word" // Shows one word at a time
73+
]
6474
},
6575
"outline_width": {"type": "integer"},
6676
"spacing": {"type": "integer"},
@@ -71,38 +81,62 @@ The request body must be a JSON object with the following properties:
7181
}
7282
```
7383

74-
### Example Request
84+
### Example Requests
85+
86+
#### Example 1: Basic Automatic Captioning
87+
```json
88+
{
89+
"video_url": "https://example.com/video.mp4"
90+
}
91+
```
92+
This minimal request will automatically transcribe the video and add white captions at the bottom center.
7593

94+
#### Example 2: Custom Text with Styling
7695
```json
7796
{
7897
"video_url": "https://example.com/video.mp4",
7998
"captions": "This is a sample caption text.",
99+
"settings": {
100+
"style": "classic",
101+
"line_color": "#FFFFFF",
102+
"outline_color": "#000000",
103+
"position": "bottom_center",
104+
"alignment": "center",
105+
"font_family": "Arial",
106+
"font_size": 24,
107+
"bold": true
108+
}
109+
}
110+
```
111+
112+
#### Example 3: Karaoke-Style Captions with Advanced Options
113+
```json
114+
{
115+
"video_url": "https://example.com/video.mp4",
80116
"settings": {
81117
"line_color": "#FFFFFF",
82-
"word_color": "#000000",
118+
"word_color": "#FFFF00",
83119
"outline_color": "#000000",
84120
"all_caps": false,
85121
"max_words_per_line": 10,
86-
"x": 20,
87-
"y": 40,
88-
"position": "bottom_left",
89-
"alignment": "left",
122+
"position": "bottom_center",
123+
"alignment": "center",
90124
"font_family": "Arial",
91125
"font_size": 24,
92126
"bold": false,
93127
"italic": false,
94-
"underline": false,
95-
"strikeout": false,
96-
"style": "classic",
128+
"style": "karaoke",
97129
"outline_width": 2,
98-
"spacing": 2,
99-
"angle": 0,
100130
"shadow_offset": 2
101131
},
102132
"replace": [
103133
{
104-
"find": "sample",
105-
"replace": "example"
134+
"find": "um",
135+
"replace": ""
136+
},
137+
{
138+
"find": "like",
139+
"replace": ""
106140
}
107141
],
108142
"webhook_url": "https://example.com/webhook",
@@ -111,44 +145,47 @@ The request body must be a JSON object with the following properties:
111145
}
112146
```
113147

148+
#### Example 4: Using an External Subtitle File
149+
```json
150+
{
151+
"video_url": "https://example.com/video.mp4",
152+
"captions": "https://example.com/subtitles.srt",
153+
"settings": {
154+
"line_color": "#FFFFFF",
155+
"outline_color": "#000000",
156+
"position": "bottom_center",
157+
"font_family": "Arial",
158+
"font_size": 24
159+
}
160+
}
161+
```
162+
114163
```bash
115164
curl -X POST \
116165
-H "x-api-key: YOUR_API_KEY" \
117166
-H "Content-Type: application/json" \
118167
-d '{
119168
"video_url": "https://example.com/video.mp4",
120-
"captions": "This is a sample caption text.",
121169
"settings": {
122170
"line_color": "#FFFFFF",
123-
"word_color": "#000000",
171+
"word_color": "#FFFF00",
124172
"outline_color": "#000000",
125173
"all_caps": false,
126174
"max_words_per_line": 10,
127-
"x": 20,
128-
"y": 40,
129-
"position": "bottom_left",
130-
"alignment": "left",
175+
"position": "bottom_center",
176+
"alignment": "center",
131177
"font_family": "Arial",
132178
"font_size": 24,
133-
"bold": false,
134-
"italic": false,
135-
"underline": false,
136-
"strikeout": false,
137-
"style": "classic",
138-
"outline_width": 2,
139-
"spacing": 2,
140-
"angle": 0,
141-
"shadow_offset": 2
179+
"style": "karaoke",
180+
"outline_width": 2
142181
},
143182
"replace": [
144183
{
145-
"find": "sample",
146-
"replace": "example"
184+
"find": "um",
185+
"replace": ""
147186
}
148187
],
149-
"webhook_url": "https://example.com/webhook",
150-
"id": "request-123",
151-
"language": "en"
188+
"id": "custom-request-id"
152189
}' \
153190
https://your-api-endpoint.com/v1/video/caption
154191
```
@@ -255,13 +292,28 @@ Additionally, the main application context (`app.py`) includes error handling fo
255292

256293
## 6. Usage Notes
257294

258-
- The `video_url` parameter must be a valid URL pointing to a video file.
259-
- The `captions` parameter is optional. If not provided, the video will be returned without captions.
260-
- The `settings` parameter allows for customization of the caption appearance and behavior.
261-
- The `replace` parameter can be used to perform text replacements in the captions.
295+
- The `video_url` parameter must be a valid URL pointing to a video file (MP4, MOV, etc.).
296+
- The `captions` parameter is optional and can be used in multiple ways:
297+
- If not provided, the endpoint will automatically transcribe the audio and generate captions
298+
- If provided as plain text, the text will be used as captions for the entire video
299+
- If provided as a URL to an SRT or ASS subtitle file, the system will use that file for captioning
300+
- For SRT files, only 'classic' style is supported
301+
- For ASS files, the original styling will be preserved
302+
- The `settings` parameter allows for customization of the caption appearance and behavior:
303+
- `style` determines how captions are displayed, with options including:
304+
- `classic`: Regular captioning with all text displayed at once
305+
- `karaoke`: Highlights words sequentially in a karaoke style as they're spoken
306+
- `highlight`: Shows the full caption text but highlights each word as it's spoken
307+
- `underline`: Shows the full caption text but underlines each word as it's spoken
308+
- `word_by_word`: Shows only one word at a time
309+
- `position` can be used to place captions in one of nine positions on the screen
310+
- `alignment` determines text alignment within the position (left, center, right)
311+
- `font_family` can be any available system font
312+
- Color options can be set using hex codes (e.g., "#FFFFFF" for white)
313+
- The `replace` parameter can be used to perform text replacements in the captions (useful for correcting words or censoring content).
262314
- The `webhook_url` parameter is optional and can be used to receive a notification when the captioning process is complete.
263-
- The `id` parameter is optional and can be used to identify the request.
264-
- The `language` parameter is optional and can be used to specify the language of the captions. If not provided, the language will be automatically detected.
315+
- The `id` parameter is optional and can be used to identify the request in webhook responses.
316+
- The `language` parameter is optional and can be used to specify the language of the captions for transcription. If not provided, the language will be automatically detected.
265317

266318
## 7. Common Issues
267319

0 commit comments

Comments
 (0)