Create Stunning Videos from Text Prompts with Kandinskyvideo

In the world of content creation, video has become an essential medium for storytelling and engagement. The Kandinskyvideo service offers developers a powerful tool to transform text prompts into high-quality, dynamic videos. Utilizing the advanced FusionFrames architecture, Kandinskyvideo allows for the generation of visually appealing videos that not only capture the essence of a scene but also convey motion and emotion effectively. This capability streamlines the video creation process, making it accessible for developers and content creators alike.
Imagine being able to generate a video from a simple text description, eliminating the complexities of traditional video production. Whether you're creating promotional content, educational materials, or artistic expressions, Kandinskyvideo can significantly enhance your workflow. This service can be particularly beneficial for developers looking to integrate video generation capabilities into applications, enhancing user experiences with rich, engaging visuals.
Prerequisites
To get started with Kandinskyvideo, you will need a Cognitive Actions API key and a basic understanding of making API calls. This will enable you to utilize the video generation capabilities effectively.
Generate Text-to-Video with Kandinsky
The "Generate Text-to-Video with Kandinsky" action allows you to create high-quality videos based on descriptive text prompts. This action addresses the challenge of video content creation by automating the process, providing a quick and efficient way to produce engaging videos.
Input Requirements
To use this action, you will need to provide the following inputs:
- Width: Defines the width of the output video in pixels (default is 640).
- Height: Specifies the height of the output video in pixels (default is 384).
- Prompt: A string that describes the scene or action to be generated (default is "a red car is drifting on the mountain road, close view, fast movement").
- Guidance Scale: Controls how closely the output adheres to the prompt (default is 5).
- Negative Prompt: Specifies elements to exclude from the generated video.
- Frames Per Second (FPS): Determines the smoothness of motion (default is 10).
- Interpolation Level: Represents the quality of interpolation between frames (options: low, medium, high; default is low).
- Number of Inference Steps: Defines the steps for denoising during inference (default is 50).
- Interpolation Guidance Scale: Affects the blend between frames (default is 0.25).
Expected Output
Upon successful execution, the action will return a URL to the generated video, allowing you to view or share the content created from your text prompt.
Example Input
{
"width": 640,
"height": 384,
"prompt": "a red car is drifting on the mountain road, close view, fast movement",
"guidanceScale": 5,
"framesPerSecond": 10,
"interpolationLevel": "low",
"numberOfInferenceSteps": 50,
"interpolationGuidanceScale": 0.25
}
Example Output
https://assets.cognitiveactions.com/invocations/5e126ebd-f385-4ff9-80cd-e4d0c64f1b3d/a01bcb02-64ef-44f8-96c2-edae077b575b.mp4
Use Cases for this Action
- Marketing and Advertising: Quickly generate promotional videos based on product descriptions or campaigns, enhancing visual marketing efforts.
- Education: Create engaging educational videos that visualize concepts described in text, making learning more interactive and effective.
- Social Media Content: Produce eye-catching videos for social media platforms, using trending topics or user-generated content as prompts.
- Artistic Projects: Artists can explore new forms of expression by generating unique videos that reflect their creative ideas and narratives.
import requests
import json
# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"
action_id = "99520775-609b-4c29-87fe-34b56ff7cf40" # Action ID for: Generate Text-to-Video with Kandinsky
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"width": 640,
"height": 384,
"prompt": "a red car is drifting on the mountain road, close view, fast movement",
"guidanceScale": 5,
"framesPerSecond": 10,
"interpolationLevel": "low",
"numberOfInferenceSteps": 50,
"interpolationGuidanceScale": 0.25
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json",
# Add any other required headers for the Cognitive Actions API
}
# Prepare the request body for the hypothetical execution endpoint
request_body = {
"action_id": action_id,
"inputs": payload
}
print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json=request_body
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully. Result:")
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 (non-JSON): {e.response.text}")
print("------------------------------------------------")
Conclusion
The Kandinskyvideo service empowers developers to create stunning videos from simple text prompts, greatly simplifying the video production process. With its flexibility and ease of use, this action opens up a world of possibilities for content creation across various domains, from marketing to education and beyond. By integrating Kandinskyvideo into your applications, you can enhance user engagement and provide a richer, more dynamic experience. Start exploring the potential of video generation today!