As video content becomes increasingly important for engagement and communication, adding captions can enhance viewer experience. With FFMPEGAPI.net, developers can easily overlay text on videos through a simple API. This article will walk you through using the Text Overlay Captions endpoint to create stunning video content without the hassle of managing server infrastructure.
What is the Text Overlay Captions Endpoint?
The Text Overlay Captions endpoint allows you to render user-supplied text lines as timed captions over a video. This feature is particularly useful for adding subtitles or annotations to enhance the viewer's experience.
- Displays user-provided text lines over video.
- Control the duration each line appears.
- Customizable styles and positions for the text.
How to Use the Endpoint
To utilize the Text Overlay Captions endpoint, make a POST request to the following path:
The request requires a video URL and the text content you want to display as captions.
- Endpoint: `/api/videos/add-text-overlay-captions`
- Content-Type: `application/json`
import requests
url = 'https://ffmpegapi.net/api/videos/add-text-overlay-captions'
data = {
'video_url': 'https://example.com/video.mp4',
'text': 'First line\nSecond line',
'duration_per_line': 4
}
response = requests.post(url, json=data)
print(response.json())
Parameters for the API Request
When making a request, several optional parameters can help customize your text overlays. Here's a quick overview of the parameters you can use:
- video_url (string, required): The URL of the video to overlay captions on.
- text (string, required): Caption lines, separated by newlines.
- subtitle_style (string, optional): Options include plain-white, yellow-bg, pink-bg, blue-bg, or red-bg. Default is plain-white.
- aspect_ratio (string, optional): Set to 16:9, 9:16, 4:3, or 3:4. Default is 9:16.
- position (string, optional): Choose top, center, or bottom for text placement. Default is center.
- duration_per_line (integer, optional): Time in seconds each text line is displayed (1 to 30). Default is 5.
FFMPEGAPI.net provides a powerful and easy-to-use platform for adding text overlay captions to your videos. By leveraging this hosted REST API, developers can focus on building amazing applications without the burden of managing FFmpeg infrastructure. With flexible parameters and seamless integration, FFMPEGAPI.net is the best cloud FFmpeg alternative for enhancing video content.