Caption Gemini
AI-generatedOverview
This node generates video captions using the Gemini AI API. It takes a video URL as input and returns subtitles in SRT format or structured JSON, depending on configuration. The node supports different Gemini models and allows customization of the prompt used to generate captions.
Common scenarios include:
- Automatically generating subtitles for videos to improve accessibility.
- Creating transcripts for video content for SEO or content repurposing.
- Using AI-generated captions when no manual subtitles are available.
Practical example:
- Input a public video URL and receive time-coded subtitles in the original language of the video, either as structured data or plain text in SRT format.
Properties
| Name | Meaning |
|---|---|
| Gemini API KEY | API key credential required to authenticate requests to the Gemini AI service. |
| Media Url | URL of the video file to be captioned (e.g., https://example-video.com/videoUrl.mp4). |
| Model | The Gemini AI model to use for caption generation. Options: Gemini 1.5 Flash, Gemini 1.5 Pro, Gemini 1.0 Pro. |
| Content Type | MIME type of the video content, default is video/mp4. |
| Custom Prompt | Boolean flag to enable usage of a custom prompt instead of the default one. |
| Prompt | Custom prompt text to guide caption generation; only shown if "Custom Prompt" is enabled. |
| Use Structured Output | Boolean flag indicating whether to return captions as structured JSON (recommended with default prompt). Only shown if "Custom Prompt" is enabled. |
Output
The node outputs an array of items where each item contains a json field with the generated captions:
If structured output is enabled (default or when using a custom prompt with this option), the output JSON has a
subtitlesarray. Each subtitle object includes:startTime: string representing the start timestamp of the subtitle.endTime: string representing the end timestamp.text: the subtitle text for that time segment.
If structured output is disabled, the output JSON contains a
textfield with the full subtitle content in SRT format as a plain string.
No binary data output is produced by this node.
Example structured output snippet:
{
"subtitles": [
{
"startTime": "00:00:01,000",
"endTime": "00:00:05,000",
"text": "Welcome to the video."
},
...
]
}
Example unstructured output snippet:
{
"text": "1\n00:00:01,000 --> 00:00:05,000\nWelcome to the video.\n\n..."
}
Dependencies
- Requires an active Gemini AI API key for authentication.
- Uses Google Generative AI SDK internally to create the model instance.
- Needs internet access to call the Gemini AI API endpoint.
- No additional n8n credentials or environment variables beyond the API key are explicitly required.
Troubleshooting
- Invalid API Key or Authentication Errors: Ensure the provided Gemini API key is valid and has necessary permissions.
- Invalid Media URL: The media URL must be publicly accessible and point directly to a video file matching the specified content type.
- Model Selection Issues: Choose a supported Gemini model from the options; unsupported values may cause errors.
- Prompt Format Errors: When using a custom prompt, ensure it is well-formed and appropriate for caption generation.
- Network or API Rate Limits: Network failures or rate limiting by the Gemini API can cause request failures; retry or check API usage limits.
- Error Handling: If the node is set to continue on failure, errors will be included in the output JSON under an
errorfield for the corresponding item.