ai-video-generation
AI video generation patterns using Sora, Runway, Pika, and other AI video tools. Use when generating videos from text prompts, image-to-video conversion, AI video editing, or integrating AI video APIs.
What this skill does
# AI Video Generation Patterns
Best practices for generating videos with AI tools.
## Platform Overview
| Platform | Type | Strengths |
|----------|------|-----------|
| Sora | Text-to-Video | Photorealistic, long-form |
| Runway Gen-3 | Text/Image-to-Video | Fast, good motion |
| Pika Labs | Text/Image-to-Video | Stylized, accessible |
| Kling AI | Text-to-Video | Long duration, realistic |
| Luma Dream Machine | Text/Image-to-Video | Coherent motion |
| Stable Video Diffusion | Image-to-Video | Open source |
## Runway API Integration
```python
import requests
from dataclasses import dataclass
from typing import Optional
import time
@dataclass
class GenerationRequest:
prompt: str
image_url: Optional[str] = None
duration: int = 4 # seconds
aspect_ratio: str = "16:9"
motion_strength: int = 5 # 1-10
@dataclass
class GenerationResult:
id: str
status: str
video_url: Optional[str] = None
thumbnail_url: Optional[str] = None
class RunwayClient:
def __init__(self, api_key: str):
self.api_key = api_key
self.base_url = "https://api.runwayml.com/v1"
self.headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
def generate_video(self, request: GenerationRequest) -> GenerationResult:
"""Generate video from text or image prompt."""
payload = {
"model": "gen3a_turbo",
"prompt": request.prompt,
"duration": request.duration,
"aspectRatio": request.aspect_ratio
}
if request.image_url:
payload["imageUrl"] = request.image_url
payload["mode"] = "image-to-video"
else:
payload["mode"] = "text-to-video"
response = requests.post(
f"{self.base_url}/generations",
headers=self.headers,
json=payload
)
response.raise_for_status()
data = response.json()
return GenerationResult(
id=data["id"],
status=data["status"]
)
def get_generation(self, generation_id: str) -> GenerationResult:
"""Check status of generation."""
response = requests.get(
f"{self.base_url}/generations/{generation_id}",
headers=self.headers
)
response.raise_for_status()
data = response.json()
return GenerationResult(
id=data["id"],
status=data["status"],
video_url=data.get("output", {}).get("videoUrl"),
thumbnail_url=data.get("output", {}).get("thumbnailUrl")
)
def wait_for_completion(
self,
generation_id: str,
poll_interval: float = 5.0,
timeout: float = 300.0
) -> GenerationResult:
"""Poll until generation completes."""
start_time = time.time()
while time.time() - start_time < timeout:
result = self.get_generation(generation_id)
if result.status == "SUCCEEDED":
return result
elif result.status == "FAILED":
raise Exception(f"Generation failed: {generation_id}")
time.sleep(poll_interval)
raise TimeoutError(f"Generation timed out: {generation_id}")
def generate_and_wait(self, request: GenerationRequest) -> GenerationResult:
"""Generate video and wait for completion."""
initial = self.generate_video(request)
return self.wait_for_completion(initial.id)
```
## Pika Labs Integration
```python
class PikaClient:
"""Pika Labs API client (when API available)."""
def __init__(self, api_key: str):
self.api_key = api_key
self.base_url = "https://api.pika.art/v1"
def text_to_video(
self,
prompt: str,
negative_prompt: str = "",
style: str = "realistic", # realistic, anime, 3d-animation
duration: int = 3,
fps: int = 24
) -> dict:
"""Generate video from text prompt."""
response = requests.post(
f"{self.base_url}/generate",
headers={"Authorization": f"Bearer {self.api_key}"},
json={
"prompt": prompt,
"negativePrompt": negative_prompt,
"style": style,
"duration": duration,
"fps": fps
}
)
return response.json()
def image_to_video(
self,
image_url: str,
motion_prompt: str,
motion_strength: float = 1.0
) -> dict:
"""Animate an image."""
response = requests.post(
f"{self.base_url}/animate",
headers={"Authorization": f"Bearer {self.api_key}"},
json={
"imageUrl": image_url,
"motionPrompt": motion_prompt,
"motionStrength": motion_strength
}
)
return response.json()
```
## Stable Video Diffusion (Local)
```python
import torch
from diffusers import StableVideoDiffusionPipeline
from PIL import Image
class StableVideoGenerator:
def __init__(self, model_id: str = "stabilityai/stable-video-diffusion-img2vid-xt"):
self.pipe = StableVideoDiffusionPipeline.from_pretrained(
model_id,
torch_dtype=torch.float16,
variant="fp16"
)
self.pipe.to("cuda")
def generate(
self,
image_path: str,
num_frames: int = 25,
fps: int = 7,
motion_bucket_id: int = 127,
noise_aug_strength: float = 0.02,
decode_chunk_size: int = 8
) -> list:
"""Generate video from image."""
image = Image.open(image_path).resize((1024, 576))
frames = self.pipe(
image,
num_frames=num_frames,
motion_bucket_id=motion_bucket_id,
noise_aug_strength=noise_aug_strength,
decode_chunk_size=decode_chunk_size
).frames[0]
return frames
def save_video(self, frames: list, output_path: str, fps: int = 7):
"""Save frames as video."""
from diffusers.utils import export_to_video
export_to_video(frames, output_path, fps=fps)
```
## Prompt Engineering for Video
```python
from dataclasses import dataclass
from typing import List, Optional
@dataclass
class VideoPrompt:
subject: str
action: str
setting: str
style: Optional[str] = None
camera: Optional[str] = None
lighting: Optional[str] = None
mood: Optional[str] = None
def to_prompt(self) -> str:
"""Build optimized prompt string."""
parts = [
f"{self.subject} {self.action}",
f"in {self.setting}" if self.setting else "",
]
modifiers = []
if self.style:
modifiers.append(self.style)
if self.camera:
modifiers.append(f"{self.camera} shot")
if self.lighting:
modifiers.append(f"{self.lighting} lighting")
if self.mood:
modifiers.append(f"{self.mood} mood")
if modifiers:
parts.append(", ".join(modifiers))
return ", ".join(filter(None, parts))
class PromptLibrary:
"""Common prompt patterns for video generation."""
CAMERA_MOVEMENTS = [
"slow zoom in",
"slow zoom out",
"dolly shot",
"tracking shot",
"pan left to right",
"crane shot",
"steady cam",
"handheld",
"aerial drone shot",
"first person POV"
]
STYLES = [
"cinematic",
"photorealistic",
"anime style",
"3D animation",
"stop motion",
"vintage film grain",
"documentary style",
"music video aesthetic",
"noir",
"cyberpunk"
]
LIGHTING = [
"golden hour",
"blue hour",
"dramatic shadows",
"soft diffused",
"neon lights",
"natural sunlight",
Related in Ads & Marketing
ads
IncludedMulti-platform paid advertising audit and optimization skill. Analyzes Google, Meta, YouTube, LinkedIn, TikTok, Microsoft, and Apple Ads. 250+ checks with scoring, parallel agents, industry templates, and AI creative generation.
banana
IncludedAI image generation Creative Director powered by Google Gemini Nano Banana models. Use this skill for ANY request involving image creation, editing, visual asset production, or creative direction. Triggers on: generate an image, create a photo, edit this picture, design a logo, make a banner, visual for my anything, and all /banana commands. Handles text-to-image, image editing, multi-turn creative sessions, batch workflows, and brand presets.
rpg-migration-analyzer
IncludedAnalyzes legacy RPG (Report Program Generator) programs from AS/400 and IBM i systems for migration to modern Java applications. Extracts business logic from RPG III/IV/ILE source code, identifies data structures (D-specs), file operations (F-specs), program dependencies (CALLB/CALLP), and converts RPG constructs to Java equivalents. Generates migration reports, complexity estimates, and Java implementation strategies with POJO classes, JPA entities, and service methods. Use when modernizing AS/400 or IBM i legacy systems, analyzing RPG source files (.rpg, .rpgle, .RPGLE), converting RPG to Java, mapping data specifications to Java classes, planning legacy system migration, or when user mentions RPG analysis, Report Program Generator, RPG III/IV/ILE, AS/400 modernization, IBM i migration, packed decimal conversion, or mainframe application rewrite.
brand-library-architect
IncludedBuild a complete brand library for a product — visual asset render pipeline, brand documentation set (BRAND, COPY, MANIFESTO, BIOS, FAQ, GLOSSARY, TONE, PRICING), open-source convention files (README, CONTRIBUTING, SECURITY, CODE_OF_CONDUCT), and a self-contained press kit. This skill should be used when the user asks to "build a brand library / brand kit / press kit / brand assets" for a product, "set up a brand library workflow," "create a positioning manifesto plus visual identity," or any combination of brand documentation + visual asset pipeline. Apply phase-by-phase or run end-to-end. Templates are product-agnostic and use {{TOKEN}} placeholders the skill prompts the user to fill.
writing-tech-post
IncludedAuthors engineering blog posts end-to-end: launch deep-dives, incident postmortems, architecture migrations, performance case studies, tutorials, AI/agent system writeups, security disclosures, and research-to-product translations. Picks the correct archetype, plans the abstraction ladder, enforces an evidence cadence (diagrams, benchmarks, profiles, traces, code, ablations), tunes voice against publisher house styles (Datadog, Vercel, GitHub, AWS, Meta, Cloudflare, Jane Street), and runs a pre-publish gate for narrative momentum and disclosure ethics. Use when drafting a new engineering post, restructuring a draft that feels flat, deciding which evidence form belongs where, validating that depth and product context are balanced, or preparing a postmortem, migration, or performance narrative for external publication. Do not use for API reference documentation, README authoring, marketing copy, release notes, generic SEO content, ghost-written executive thought leadership, or non-engineering long-form essays.
blog-google
IncludedGoogle API integration for blog performance: PageSpeed Insights, CrUX Core Web Vitals with 25-week history, Search Console performance, URL Inspection, Indexing API, GA4 organic traffic, NLP entity analysis for E-E-A-T, YouTube video search for embedding, and Google Ads Keyword Planner. Progressive feature availability based on credential tier (API key, OAuth/service account, GA4, Ads). Shares config with claude-seo at ~/.config/claude-seo/google-api.json. Use when user says "google data", "page speed", "core web vitals", "search console", "indexation", "GA4", "keyword research", "nlp entities", "blog performance", "youtube search", "google api setup".