SuperAPI AI Directory

video-generation

Design & creation

View repository

Updated 10-16 08:43

About this skill

Video Generation Skill (Video Generation)

Use the WaveSpeed AI platform to generate and process videos, including image-to-video, video continuation, video chain generation, and 4K upscaling.

When to Use

Applicable to the following scenarios:

  • Generate dynamic videos from images (image-to-video)
  • Video upscaling to 4K/2K/1080p
  • Create video chains (splicing multiple video segments)
  • Hero background video production
  • Video continuation and extension

Do NOT use this skill if:

  • Only need a simple selfie video (use zhuoran-video-selfie or clawra-video-selfie)
  • Need real-time video generation (the API is asynchronous)
  • No reference images or video materials
  • Extremely poor network conditions (need to upload/download large files)

Trigger Keywords / Trigger Phrases:

  • AI video generation / AI video generation
  • image to video / image to video
  • video upscaling / video upscaling
  • 4K video / 4K video
  • video continuation / video continuation
  • video chain / video chain
  • video processing / video processing
  • generate video / generate video

Workflow

1. Image-to-Video

import requests
import time

API_KEY="***"
BASE_URL = "https://api.wavespeed.ai/api/v3"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
JSON_HEADERS = {**HEADERS, "Content-Type": "application/json"}

# 1. 上传图片
def upload_image(image_path):
    with open(image_path, 'rb') as f:
        r = requests.post(
            f"{BASE_URL}/media/upload/binary",
            headers=HEADERS,
            files={"file": f}
        )
    return r.json()["data"]["download_url"]

# 2. 提交视频生成任务
def submit_i2v_task(image_url, prompt, model="wavespeed-ai/wan-2.2/i2v-480p"):
    payload = {
        "image": image_url,
        "prompt": prompt,
        "duration": 5,  # 5 或 8 秒
        "enable_prompt_expansion": False
    }
    r = requests.post(f"{BASE_URL}/{model}", headers=JSON_HEADERS, json=payload)
    return r.json()["data"]

# 3. 轮询结果
def poll_result(task_id, get_url=None):
    poll_url = get_url or f"{BASE_URL}/predictions/{task_id}"
    while True:
        r = requests.get(poll_url, headers=HEADERS)
        data = r.json()["data"]
        if data["status"] == "completed":
            return data["outputs"][0]
        elif data["status"] == "failed":
            raise Exception(f"Task failed: {data}")
        time.sleep(5)

# 4. 下载视频
def download_video(video_url, output_path):
    r = requests.get(video_url, stream=True)
    with open(output_path, 'wb') as f:
        for chunk in r.iter_content(chunk_size=8192):
            f.write(chunk)

2. Video upscaling to 4K

# 1. 上传视频
video_url = upload_video(video_path)  # 同 upload_image

# 2. 提交超分任务
payload = {
    "video": video_url,
    "target_resolution": "4k"  # 可选: 720p, 1080p, 2k, 4k
}
r = requests.post(
    f"{BASE_URL}/wavespeed-ai/video-upscaler-pro",
    headers=JSON_HEADERS,
    json=payload
)
task_data = r.json()["data"]

# 3. 轮询并下载(同上)

3. Video chain generation

A video chain refers to connecting multiple short videos into one coherent long video through video continuation technology.

Core concepts:

  1. First frame extraction: Use FFmpeg to extract the last frame of the video as the starting point of the next segment
  2. Video continuation: Use the same prompt style to generate a coherent sequel
  3. Video splicing: Use FFmpeg for lossless splicing
# 提取最后一帧
def extract_last_frame(video_path, output_path):
    import subprocess
    cmd = [
        "ffmpeg", "-y", "-sseof", "-0.1",
        "-i", video_path,
        "-vframes", "1", "-q:v", "2",
        output_path
    ]
    subprocess.run(cmd, check=True)

# 生成视频链
def generate_chain(initial_image, prompt, num_segments=4):
    videos = []
    current_image = initial_image
    
    for i in range(num_segments):
        # 上传当前图片
        image_url = upload_image(current_image)
        
        # 生成视频
        task = submit_i2v_task(image_url, prompt)
        video_url = poll_result(task["id"], task["urls"]["get"])
        
        # 下载视频
        video_path = f"v{i+1}.mp4"
        download_video(video_url, video_path)
        videos.append(video_path)
        
        # 提取最后一帧用于下一段
        current_image = f"v{i+1}_last_frame.jpg"
        extract_last_frame(video_path, current_image)
    
    return videos

# 拼接视频
def concat_videos(video_list, output_path):
    import subprocess
    # 创建文件列表
    with open("concat_list.txt", "w") as f:
        for v in video_list:
            f.write(f"file '{v}'\\n")
    
    cmd = [
        "ffmpeg", "-y", "-f", "concat", "-safe", "0",
        "-i", "concat_list.txt", "-c", "copy",
        output_path
    ]
    subprocess.run(cmd, check=True)

Supported Models

Image-to-Video

Model API path Duration Features
Wan-2.2 wavespeed-ai/wan-2.2/i2v-480p 5s/8s High quality, supports long videos
Wan-2.2 720p wavespeed-ai/wan-2.2/i2v-720p 5s/8s Higher resolution
Hailuo 2.3 minimax/hailuo-2.3/i2v-standard 6s Fast, good results
Kling 1.6 kuaishou/kling-v1.6/i2v-pro 5s/10s Stable, rich in detail

Video Upscaling

Model API path Resolution options
Video Upscaler Pro wavespeed-ai/video-upscaler-pro 720p, 1080p, 2k, 4k

Guardrails

Prompt writing suggestions

Good prompt structure:

[动作描述], [氛围/风格], [细节], [效果]

Example:

"Gentle flowing motion with glowing particles moving slowly across the scene, 
subtle pulsing neon light effects, ethereal and dreamy atmosphere, 
smooth ambient movement, futuristic cyberpunk feeling"

Notes

  1. Avoid excessive post-processing: Do not use FFmpeg to force stretch the resolution; use native 4K output
  2. Keep the style consistent: Use the same prompt style for each segment of the video chain
  3. Reserve buffer: Upscaling tasks may take 10-15 minutes; set a sufficient polling timeout
  4. Back up the original files: Back up the original video before upscaling

Common issues

Issue Solution
Edges look blurry after upscaling Use target_resolution: "4k" native output
Video chain is incoherent Ensure that the true last frame is extracted
Task timeout Increase max_attempts or check the API status
Upload failed Check the file size limit (usually 500MB)

API key configuration

Store the API key in an environment variable or .env In the file:

# .env
WAVESPEED_KEY=your_api_key_here

Note: Do not hardcode API keys in scripts or commit them to version control.

Project Scripts

Script Features
generate_hero_video.py Generate Hero background video from a poster image
upscale_hero_video.py Upscale video to 4K
generate_latest_chains.py Generate the complete video chain
wan_v1.py ~ wan_v4.py Wan model single-segment generation
upscale_intro_native_4k.py Intro video upscaling
upscale_loop_native_4k.py Loop video upscaling

Related Skills

Skills Relationships Description
zhuoran-video-selfie Dedicated version Selfie video generation for the Zhuoran character
clawra-video-selfie Dedicated version Selfie video generation for the Clawra character
voice-clone Companion Can add cloned voice to videos
zhuoran-selfie Reference Photo generation skill

About UniqueClub

Part of UniqueClub toolkit - AI-powered creative tools for professional video generation. Learn more: https://uniqueclub.ai


Last updated: 2026-02-07