Create Stunning Videos with the Hunyuan-Joker Cognitive Actions

24 Apr 2025
Create Stunning Videos with the Hunyuan-Joker Cognitive Actions

In the world of digital content creation, the ability to generate videos that evoke a specific style can significantly enhance the storytelling experience. The Hunyuan-Joker Cognitive Actions provide developers with powerful tools to create videos inspired by the iconic aesthetic of the 2019 film Joker. By utilizing pre-built actions, developers can seamlessly integrate video generation capabilities into their applications, allowing for unique and engaging content creation without the need for advanced video editing skills.

Prerequisites

Before diving into the integration of Hunyuan-Joker Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic understanding of JSON for structuring requests.
  • Familiarity with Python to implement the conceptual code examples provided.

Authentication typically involves passing the API key in the headers of your requests to access the actions securely.

Cognitive Actions Overview

Generate Video in Joker Style

Description: This action creates a video using the Hunyuan-Video model, specifically fine-tuned to emulate the style of the film Joker. To achieve optimal results, it utilizes the trigger word “JKR” along with a detailed prompt to guide the video generation.

Category: Video Generation

Input

The input schema for this action requires the following fields:

  • seed (integer): A fixed starting point for randomization (default: 12345).
  • steps (integer): Number of diffusion steps (default: 50, range: 1-150).
  • width (integer): Video frame width in pixels (default: 640, range: 64-1536).
  • height (integer): Video frame height in pixels (default: 360, range: 64-1024).
  • prompt (string): Describes the video scene (required).
  • flowShift (integer): Degree of motion continuity (default: 9, range: 0-20).
  • frameRate (integer): Display rate of video frames (default: 16 fps, range: 1-60).
  • scheduler (string): Algorithm for generating video frames (default: DPMSolverMultistepScheduler).
  • enhanceEnd (number): Relative time point to cease enhancement (default: 1).
  • frameCount (integer): Total number of frames (default: 33, range: 1-1440).
  • loraFileUrl (string): URL for the LoRA .safetensors file.
  • enhanceStart (number): Starting point for video enhancement (default: 0).
  • forceOffload (boolean): Forces model processing layers to use the CPU (default: true).
  • enhanceDouble (boolean): Applies enhancement effects across frame pairs (default: true).
  • enhanceSingle (boolean): Applies enhancement effects to individual frames (default: true).
  • enhanceWeight (number): Intensity of video enhancement effects (default: 0.3).
  • guidanceScale (number): Influence balance of text input (default: 6).
  • loraIntensity (number): Strength of LoRA application (default: 1).
  • qualityFactor (integer): CRF for H264 encoding (default: 19).
  • denoiseStrength (number): Intensity of noise applied (default: 1).
  • sourceWeightsUri (string): URI of a .tar file with LoRA weights.

Example Input:

{
  "seed": 12345,
  "steps": 50,
  "width": 640,
  "height": 360,
  "prompt": "A video in the style of JKR, JKR The video clip depicts a beach scene with several people enjoying their time. In the foreground, a man with curly hair and a mustache is wearing glasses and a red and white checkered shirt. He is sitting on a beach chair and appears to be laughing or smiling, looking off to the side. In the background, there are other people sitting on the beach, some under umbrellas, and others lying on towels. The beach is populated with various beachgoers, and the atmosphere seems relaxed and leisurely. The overall scene conveys a sense of a typical day at the beach with people engaging in typical beach activities.",
  "frameRate": 16,
  "frameCount": 66,
  "guidanceScale": 6,
  "loraIntensity": 1
}

Output

The output is typically a URL pointing to the generated video, for example:

https://assets.cognitiveactions.com/invocations/c3a78318-e009-40c8-a73e-4cd028de3308/d5e6ef88-5f58-4170-88c0-aa8ea6f99606.mp4

Conceptual Usage Example (Python)

Here's a conceptual Python code snippet that illustrates how to call the Generate Video in Joker Style 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 = "79884a57-b9cf-4f4e-897e-fc52f53c350e"  # Action ID for Generate Video in Joker Style

# Construct the input payload based on the action's requirements
payload = {
    "seed": 12345,
    "steps": 50,
    "width": 640,
    "height": 360,
    "prompt": "A video in the style of JKR, JKR The video clip depicts a beach scene with several people enjoying their time. In the foreground, a man with curly hair and a mustache is wearing glasses and a red and white checkered shirt. He is sitting on a beach chair and appears to be laughing or smiling, looking off to the side. In the background, there are other people sitting on the beach, some under umbrellas, and others lying on towels. The beach is populated with various beachgoers, and the atmosphere seems relaxed and leisurely. The overall scene conveys a sense of a typical day at the beach with people engaging in typical beach activities.",
    "frameRate": 16,
    "frameCount": 66,
    "guidanceScale": 6,
    "loraIntensity": 1
}

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 the COGNITIVE_ACTIONS_API_KEY and endpoint URL with your actual API key and endpoint. The action ID and input payload are structured according to the requirements, and the response is handled appropriately.

Conclusion

The Hunyuan-Joker Cognitive Actions empower developers to create compelling video content with ease, utilizing advanced AI-driven video generation techniques. By understanding how to integrate these actions into your applications, you open up a world of creative possibilities. Consider exploring various prompts and settings to fully leverage the capabilities of these actions in your projects. Happy coding!