Create Stunning Animated Videos with Kandinsky 2.2

In today's digital landscape, the ability to generate dynamic and visually appealing content quickly is paramount. The "Deforum Kandinsky 2 2" service offers innovative Cognitive Actions that empower developers to create videos directly from text prompts using the advanced Kandinsky-2.2 model. This functionality allows for the production of captivating animations with a pseudo-3D effect, making it a powerful tool for artists, marketers, and content creators alike.
With the ability to specify various parameters such as animation types, duration, frame rate, and video dimensions, developers can easily craft unique video content that stands out. Whether for storytelling, marketing campaigns, or artistic projects, this action simplifies the video creation process while enhancing the creative possibilities.
Prerequisites
To get started with the Kandinsky 2.2 video generation, you'll need a Cognitive Actions API key and a basic understanding of making API calls.
Generate Video with Kandinsky-2.2
The "Generate Video with Kandinsky-2.2" action allows users to create immersive videos by transforming text prompts into animated sequences. It addresses the challenge of producing engaging video content without requiring extensive animation skills.
Input Requirements
To leverage this action, you'll need to provide the following parameters:
- animationPrompts: A string containing the prompts for each animation, separated by '|'.
- animations: A sequence of animation actions, also separated by '|'.
- promptDurations: The duration for each animation prompt in seconds, separated by '|'.
- Optional parameters: You can also specify
seed,steps,width,height,scheduler,maximumFrames, andframesPerSecondto customize your video further.
Expected Output
The output will be a URL link to the generated video, allowing you to easily access and share your creation.
Use Cases for this specific action
This action is ideal for:
- Creative Professionals: Artists can visualize complex concepts or narratives through animated videos.
- Marketers: Create engaging promotional content that captures attention more effectively than static images.
- Educators: Develop animated lessons or presentations that enhance learning experiences.
- Content Creators: Streamline the process of producing unique video content for platforms like YouTube or social media.
To illustrate, here’s an example input:
{
"seed": 17,
"steps": 80,
"width": 640,
"height": 640,
"scheduler": "euler_ancestral",
"animations": "live | right | right | right | live",
"maximumFrames": 72,
"framesPerSecond": 24,
"promptDurations": "0.6 | 0.3 | 1 | 0.3 | 0.8",
"animationPrompts": "winter forest, snowflakes, Van Gogh style | spring forest, flowers, sun rays, Van Gogh style | summer forest, lake, reflections on the water, summer sun, Van Gogh style | autumn forest, rain, Van Gogh style | winter forest, snowflakes, Van Gogh style"
}
And the expected output would look something like this:
https://assets.cognitiveactions.com/invocations/a14caa3f-5a2a-494d-a46c-f76aa24b3014/969e1cb3-3527-4b5a-a5ce-c70b498751a6.mp4
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 = "c545c6c2-987f-4744-9555-edbc7d0c592f" # Action ID for: Generate Video with Kandinsky-2.2
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"seed": 17,
"steps": 80,
"width": 640,
"height": 640,
"scheduler": "euler_ancestral",
"animations": "live | right | right | right | live",
"maximumFrames": 72,
"framesPerSecond": 24,
"promptDurations": "0.6 | 0.3 | 1 | 0.3 | 0.8",
"animationPrompts": "winter forest, snowflakes, Van Gogh style | spring forest, flowers, sun rays, Van Gogh style | summer forest, lake, reflections on the water, summer sun, Van Gogh style | autumn forest, rain, Van Gogh style | winter forest, snowflakes, Van Gogh style"
}
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 "Generate Video with Kandinsky-2.2" action offers a powerful and flexible solution for developers looking to create stunning animated videos from simple text prompts. By simplifying the video production process and providing numerous customization options, this service caters to a wide range of use cases, from artistic expression to marketing strategies.
To get started, integrate this action into your applications and unlock the potential for visually captivating content that can engage audiences and elevate your projects.