Create Hollywood-Style Videos with Cognitive Actions: A Developer's Guide

In the world of video production, the ability to generate captivating content is invaluable. The deepfates/hunyuan-once-upon-a-time-in-hollywood Cognitive Actions allow developers to create videos styled after Quentin Tarantino's iconic film "Once Upon a Time in Hollywood" using the Hunyuan-Video model. These actions simplify the video generation process by providing pre-built functionalities that developers can easily integrate into their applications, saving time and enhancing creativity.
Prerequisites
Before diving into the integration of Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform to authenticate your requests.
- Basic knowledge of making HTTP requests and handling JSON data.
- Familiarity with Python, as we will provide code snippets in this language.
Authentication typically involves passing an API key in the request headers, allowing you to securely access the Cognitive Actions.
Cognitive Actions Overview
Generate Video in Hollywood Style
The "Generate Video in Hollywood Style" action enables developers to create a video that captures the essence of "Once Upon a Time in Hollywood." By providing a detailed prompt, you can generate a unique video that reflects your vision.
- Input:
The input schema for this action consists of several fields, each serving a specific purpose. Here’s a breakdown:- seed: (integer) The seed number for consistent results (optional).
- steps: (integer) Number of diffusion steps (default: 50, range: 1-150).
- width: (integer) Width of the video in pixels (default: 640, range: 64-1536).
- height: (integer) Height of the video in pixels (default: 360, range: 64-1024).
- prompt: (string) A detailed description for the video (required).
- flowShift: (integer) Determines flow continuity (default: 9, range: 0-20).
- frameRate: (integer) Frames per second (default: 16, range: 1-60).
- scheduler: (string) Specifies the scheduling algorithm (default: "DPMSolverMultistepScheduler").
- enhanceEnd: (number) Time point to finish enhancement (default: 1, range: 0-1).
- frameCount: (integer) Total number of frames (default: 33, range: 1-1440).
- enhanceStart: (number) Time point to begin enhancement (default: 0, range: 0-1).
- forceOffload: (boolean) Offload model layers for optimization (default: true).
- loraStrength: (number) Influence of the LoRA model (default: 1, range: -10 to 10).
- referenceUrl: (string) URL to the LoRA .safetensors file (optional).
- enhanceDouble: (boolean) Enable enhancement across frame pairs (default: true).
- enhanceSingle: (boolean) Enable enhancement for individual frames (default: true).
- enhanceWeight: (number) Intensity of the enhancement effect (default: 0.3, range: 0-2).
- guidanceScale: (number) Influence level of the text (default: 6, range: 0-30).
- qualityFactor: (integer) Constant Rate Factor for H264 encoding (default: 19, range: 0-51).
- weightFileUrl: (string) URL to a .tar file with LoRA weights (optional).
- denoiseStrength: (number) Level of noise suppression (default: 1, range: 0-2).
Example Input:{ "seed": 12345, "steps": 50, "width": 640, "height": 360, "prompt": "A video in the style of NCPNT, NCPNT The video clip depicts a dimly lit jazz club with a cozy, intimate atmosphere. The stage is set with a piano and a saxophone player, both engrossed in their performance. The saxophonist is positioned in the center, playing with a focused expression, while the pianist sits at the back, immersed in his music. The club is filled with patrons seated at tables, engaged in conversation and enjoying the live music. The audience appears to be a mix of men and women, dressed in casual to semi-formal attire. The lighting is warm and subdued, with a neon sign on the right side of the stage reading ", "frameRate": 16, "frameCount": 66, "loraStrength": 1, "guidanceScale": 6 } - Output:
Upon successful execution, the action returns a URL to the generated video. For example:https://assets.cognitiveactions.com/invocations/37172d4a-91a4-4575-993e-3687e2a7ab92/b36c3ef1-df2a-41ab-b4f9-76246a0e1c1f.mp4 - Conceptual Usage Example (Python):
Here’s how you might call the "Generate Video in Hollywood Style" 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 = "6c725e3b-6a27-4d7c-9948-76c4acc1d659" # Action ID for Generate Video in Hollywood 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 NCPNT, NCPNT The video clip depicts a dimly lit jazz club with a cozy, intimate atmosphere. The stage is set with a piano and a saxophone player, both engrossed in their performance. The saxophonist is positioned in the center, playing with a focused expression, while the pianist sits at the back, immersed in his music. The club is filled with patrons seated at tables, engaged in conversation and enjoying the live music. The audience appears to be a mix of men and women, dressed in casual to semi-formal attire. The lighting is warm and subdued, with a neon sign on the right side of the stage reading ", "frameRate": 16, "frameCount": 66, "loraStrength": 1, "guidanceScale": 6 } 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 snippet, replace the placeholder API key and endpoint with your actual credentials. The input payload is structured based on the action's requirements, ensuring a smooth execution.
Conclusion
The deepfates/hunyuan-once-upon-a-time-in-hollywood Cognitive Actions empower developers to create visually stunning videos effortlessly. By leveraging the "Generate Video in Hollywood Style" action, you can bring your creative ideas to life with just a few lines of code. Explore the possibilities of video generation and consider how you can incorporate these actions into your applications for unique and engaging content creation!