Enhance Your Video Projects with camenduru Motion Director Cognitive Actions

In today's digital landscape, video content is king. The camenduru/motion-director API provides developers with powerful Cognitive Actions designed to elevate video generation through enhanced motion capabilities. By leveraging these pre-built actions, you can create high-quality, motion-enhanced videos with ease, allowing your applications to deliver richer visual experiences.
Prerequisites
Before diving into the integration of Cognitive Actions, ensure you have the following:
- An API key for accessing the camenduru/motion-director platform.
- Familiarity with making HTTP requests and handling JSON responses.
- Basic knowledge of Python for executing the provided examples.
To authenticate your requests, include your API key in the request headers. This typically involves adding an Authorization header with the value Bearer YOUR_API_KEY.
Cognitive Actions Overview
Create Motion-Enhanced Videos
The Create Motion-Enhanced Videos action allows you to customize the motion parameters of text-to-video diffusion models, thereby enhancing the quality of generated videos through detailed motion adjustments and prompting.
- Category: Video Generation
Input
The input for this action requires a structured JSON object (type: CompositeRequest) with the following properties:
seed(integer, optional): A numerical seed to initialize random number generation. Default is 15. Range: 0 to 1,000,000.width(integer, optional): Specifies the width in pixels. Default is 256. Valid values are between 256 and 512.height(integer, optional): Specifies the height in pixels. Default is 256. Valid values are between 256 and 512.prompt(string, required): A textual description used to generate content. Default: "A person is riding a bicycle past the Eiffel Tower."guidanceScale(integer, optional): Defines how closely the output adheres to the prompt. Default is 15. Range: 1 to 25.numberOfSteps(integer, optional): Indicates the number of steps in the generation process. Default is 50. Range: 1 to 150.negativePrompt(string, optional): Describes attributes to avoid in the output. Default is "blurry."numberOfFrames(integer, optional): Specifies the total frames in a sequence. Default is 24. Range: 0 to 48.
Example Input:
{
"seed": 0,
"width": 256,
"height": 256,
"prompt": "A person is riding a bicycle past the Eiffel Tower.",
"guidanceScale": 15,
"numberOfSteps": 50,
"negativePrompt": "blurry",
"numberOfFrames": 24
}
Output
Upon successful execution, this action typically returns a URL pointing to the generated video file. For example:
Example Output:
https://assets.cognitiveactions.com/invocations/e9287f87-f544-4b5d-8f48-af2b8f03c0e0/ed563834-827a-4b5c-a8ca-db86dcc8aa2d.mp4
Conceptual Usage Example (Python)
Here’s how you might call the Create Motion-Enhanced Videos action using Python:
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 = "0c376506-ed2a-45d3-9eb6-b34ea59daa8d" # Action ID for Create Motion-Enhanced Videos
# Construct the input payload based on the action's requirements
payload = {
"seed": 0,
"width": 256,
"height": 256,
"prompt": "A person is riding a bicycle past the Eiffel Tower.",
"guidanceScale": 15,
"numberOfSteps": 50,
"negativePrompt": "blurry",
"numberOfFrames": 24
}
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 example, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID and input payload are structured according to the specifications provided. The endpoint URL is illustrative and should be adjusted based on your API's actual endpoint.
Conclusion
By integrating the Create Motion-Enhanced Videos action from the camenduru/motion-director API, you can significantly enhance the quality of your video projects. This action empowers developers to create visually compelling content with ease, opening doors to a myriad of creative possibilities.
Consider exploring additional use cases where motion-enhanced video generation can add value to your applications, and start experimenting today!