Effortlessly Add Watermarks to Your Videos with Cognitive Actions

In the age of digital content, branding your videos is essential. The charlesmccarthy/addwatermark Cognitive Actions API enables developers to easily integrate a watermark into video content. This functionality is powered by Replicate through FullJourney.AI, allowing for customization of both the watermark's text and font size. By leveraging these pre-built actions, developers can enhance their applications with minimal effort.
Prerequisites
Before diving into the integration of the Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform.
- Familiarity with making HTTP requests in your preferred programming language.
- Basic understanding of JSON format for input and output data structures.
For authentication, you will typically pass your API key in the request headers, allowing secure access to the Cognitive Actions.
Cognitive Actions Overview
Add Watermark to Video
Description:
This action allows you to integrate a watermark into your videos while offering customization options for the watermark's font size and text. This is particularly useful for branding your video content.
Category: video-processing
Input
The input for this action requires the following fields:
inputVideo(string, required): A URI pointing to the input video file.
Example:"inputVideo": "https://replicate.delivery/pbxt/JzweHYSSY69C9uUq2wAcqX3suV9zdL3C6Ujk2hrxynOJ0JHm/vidswap600883.mp4"fontSize(integer, optional): The size of the font for the watermark text. Must be an integer between 1 and 500, inclusive.
Default: 40
Example:"fontSize": 40watermarkText(string, optional): The text used as a watermark on the video.
Default: "FULLJOURNEY.AI"
Example:"watermarkText": "FULLJOURNEY.AI"
Example Input Payload:
{
"fontSize": 40,
"inputVideo": "https://replicate.delivery/pbxt/JzweHYSSY69C9uUq2wAcqX3suV9zdL3C6Ujk2hrxynOJ0JHm/vidswap600883.mp4",
"watermarkText": "FULLJOURNEY.AI"
}
Output
The action typically returns a URI pointing to the watermarked video.
Example Output:
"https://assets.cognitiveactions.com/invocations/e285bec3-d29e-40fe-9025-c3f10b817a9a/bd056999-78af-43c1-be61-e691ea7578a5.mp4"
Conceptual Usage Example (Python)
Here's a conceptual Python code snippet demonstrating how you might call this action:
import requests
import json
# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint
action_id = "4629d150-2c7b-4ad2-a674-cd40f9d51daa" # Action ID for Add Watermark to Video
# Construct the input payload based on the action's requirements
payload = {
"fontSize": 40,
"inputVideo": "https://replicate.delivery/pbxt/JzweHYSSY69C9uUq2wAcqX3suV9zdL3C6Ujk2hrxynOJ0JHm/vidswap600883.mp4",
"watermarkText": "FULLJOURNEY.AI"
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json"
}
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json={"action_id": action_id, "inputs": payload} # Hypothetical structure
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))
except requests.exceptions.RequestException as e:
print(f"Error executing action {action_id}: {e}")
if e.response is not None:
print(f"Response status: {e.response.status_code}")
try:
print(f"Response body: {e.response.json()}")
except json.JSONDecodeError:
print(f"Response body: {e.response.text}")
In this code snippet, replace the YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID for "Add Watermark to Video" is specified, and the input payload is structured as per the requirements. The endpoint URL and request structure are illustrative; ensure they align with the actual API you are working with.
Conclusion
The charlesmccarthy/addwatermark Cognitive Actions API offers a straightforward way to enhance your video content with custom watermarks. By utilizing this functionality, developers can ensure that their videos are uniquely branded while saving time and effort. Consider exploring other potential use cases, such as creating dynamic video content for marketing or educational purposes, where branding plays a crucial role. Happy coding!