You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"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
+
]
64
74
},
65
75
"outline_width": {"type": "integer"},
66
76
"spacing": {"type": "integer"},
@@ -71,38 +81,62 @@ The request body must be a JSON object with the following properties:
71
81
}
72
82
```
73
83
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.
75
93
94
+
#### Example 2: Custom Text with Styling
76
95
```json
77
96
{
78
97
"video_url": "https://example.com/video.mp4",
79
98
"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",
80
116
"settings": {
81
117
"line_color": "#FFFFFF",
82
-
"word_color": "#000000",
118
+
"word_color": "#FFFF00",
83
119
"outline_color": "#000000",
84
120
"all_caps": false,
85
121
"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",
90
124
"font_family": "Arial",
91
125
"font_size": 24,
92
126
"bold": false,
93
127
"italic": false,
94
-
"underline": false,
95
-
"strikeout": false,
96
-
"style": "classic",
128
+
"style": "karaoke",
97
129
"outline_width": 2,
98
-
"spacing": 2,
99
-
"angle": 0,
100
130
"shadow_offset": 2
101
131
},
102
132
"replace": [
103
133
{
104
-
"find": "sample",
105
-
"replace": "example"
134
+
"find": "um",
135
+
"replace": ""
136
+
},
137
+
{
138
+
"find": "like",
139
+
"replace": ""
106
140
}
107
141
],
108
142
"webhook_url": "https://example.com/webhook",
@@ -111,44 +145,47 @@ The request body must be a JSON object with the following properties:
111
145
}
112
146
```
113
147
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
+
114
163
```bash
115
164
curl -X POST \
116
165
-H "x-api-key: YOUR_API_KEY" \
117
166
-H "Content-Type: application/json" \
118
167
-d '{
119
168
"video_url": "https://example.com/video.mp4",
120
-
"captions": "This is a sample caption text.",
121
169
"settings": {
122
170
"line_color": "#FFFFFF",
123
-
"word_color": "#000000",
171
+
"word_color": "#FFFF00",
124
172
"outline_color": "#000000",
125
173
"all_caps": false,
126
174
"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",
131
177
"font_family": "Arial",
132
178
"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
142
181
},
143
182
"replace": [
144
183
{
145
-
"find": "sample",
146
-
"replace": "example"
184
+
"find": "um",
185
+
"replace": ""
147
186
}
148
187
],
149
-
"webhook_url": "https://example.com/webhook",
150
-
"id": "request-123",
151
-
"language": "en"
188
+
"id": "custom-request-id"
152
189
}' \
153
190
https://your-api-endpoint.com/v1/video/caption
154
191
```
@@ -255,13 +292,28 @@ Additionally, the main application context (`app.py`) includes error handling fo
255
292
256
293
## 6. Usage Notes
257
294
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).
262
314
- 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.
0 commit comments