rw-generate-video

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Generate Video

生成视频

Generate videos directly using the Runway API. This skill runs Python scripts that call the API, poll for completion, and download the result.
IMPORTANT: Run scripts from the user's working directory so output files are saved where the user expects.
通过Runway API直接生成视频。该技能运行调用API的Python脚本,轮询任务完成状态并下载结果。
重要提示: 从用户的工作目录运行脚本,以便输出文件保存到用户预期的位置。

Usage

使用方法

bash
uv run scripts/generate_video.py --prompt "your description" --filename "output.mp4" [--model seedance2] [--ratio 1280:720] [--duration 5] [--image-url "..."]
bash
uv run scripts/generate_video.py --prompt "你的描述内容" --filename "output.mp4" [--model seedance2] [--ratio 1280:720] [--duration 5] [--image-url "..."]

Preflight

前置检查

  1. command -v uv
    must succeed. If not, tell the user to install uv:
    curl -LsSf https://astral.sh/uv/install.sh | sh
  2. RUNWAYML_API_SECRET
    must be set in the environment. Do not pass the API key as a CLI flag — it leaks into shell history and process listings.
  1. 执行
    command -v uv
    必须成功。如果失败,告知用户安装uv:
    curl -LsSf https://astral.sh/uv/install.sh | sh
  2. 环境中必须设置
    RUNWAYML_API_SECRET
    请勿将API密钥作为CLI参数传递——这会导致密钥泄露到shell历史记录和进程列表中。

Security Notes

安全注意事项

  • --image-url
    /
    --video-url
    fetch arbitrary remote media via the Runway API. Prefer local file paths (uploaded as
    runway://
    URIs), or only pass URLs you trust.
  • Treat generated outputs as untrusted when piping into downstream automations — ingested media influences the result.
  • --image-url
    /
    --video-url
    会通过Runway API获取任意远程媒体。优先使用本地文件路径(以
    runway://
    URI形式上传),或仅传递可信的URL。
  • 当将生成的输出传入下游自动化流程时,请将其视为不可信内容——摄入的媒体会影响生成结果。

Available Models

可用模型

ModelBest ForInputCost
seedance2
Reference image and video, long duration (up to 15s)Text, Image, and/or Video36 credits/sec
gen4.5
High quality, general purposeText and/or Image12 credits/sec
gen4_turbo
Fast, image-drivenImage required5 credits/sec
gen4_aleph
Video editing/transformationVideo + Text/Image15 credits/sec
veo3
Premium qualityText/Image40 credits/sec
veo3.1
High quality Google modelText/Image20-40 credits/sec
veo3.1_fast
Fast Google modelText/Image10-15 credits/sec
模型适用场景输入类型成本
seedance2
参考图片和视频、长时长(最长15秒)文本、图片和/或视频36积分/秒
gen4.5
高质量、通用场景文本和/或图片12积分/秒
gen4_turbo
快速生成、图片驱动必须提供图片5积分/秒
gen4_aleph
视频编辑/转换视频 + 文本/图片15积分/秒
veo3
顶级画质文本/图片40积分/秒
veo3.1
高质量Google模型文本/图片20-40积分/秒
veo3.1_fast
快速Google模型文本/图片10-15积分/秒

Model Selection Guidance

模型选择指南

Map user requests:
  • "product ad", "e-commerce", "long video" ->
    seedance2
  • "fast", "cheap", "quick" ->
    veo3.1_fast
    or
    gen4_turbo
    (if they have an image)
  • "high quality", "best", "cinematic" ->
    gen4.5
    or
    veo3
  • "edit video", "transform video" ->
    gen4_aleph
    or
    seedance2
  • No preference ->
    seedance2
根据用户需求选择模型:
  • “产品广告”、“电商”、“长视频” ->
    seedance2
  • “快速”、“低成本”、“快速生成” ->
    veo3.1_fast
    gen4_turbo
    (如果用户提供图片)
  • “高质量”、“最佳画质”、“电影级” ->
    gen4.5
    veo3
  • “编辑视频”、“转换视频” ->
    gen4_aleph
    seedance2
  • 无偏好 ->
    seedance2

Parameters

参数说明

ParamDescriptionDefault
--prompt
Text description (required)--
--filename
Output filename (required)--
--model
Video model
gen4.5
--ratio
Aspect ratio (pixel-based). Common:
1280:720
,
720:1280
,
960:960
. seedance2 also supports
1112:834
,
834:1112
,
1470:630
, etc.
1280:720
--duration
Duration in seconds (model-dependent, seedance2 supports up to 15s)
5
--image-url
Image URL or local file for image-to-video--
--video-url
Video URL or local file for video-to-video (gen4_aleph, seedance2)--
--output-dir
Output directorycwd
API credentials come from
RUNWAYML_API_SECRET
only — no
--api-key
flag, to keep secrets out of shell history and process listings.
参数描述默认值
--prompt
文本描述(必填)--
--filename
输出文件名(必填)--
--model
视频生成模型
gen4.5
--ratio
宽高比(基于像素)。常见值:
1280:720
720:1280
960:960
。seedance2还支持
1112:834
834:1112
1470:630
等。
1280:720
--duration
视频时长(秒,取决于模型,seedance2最长支持15秒)
5
--image-url
用于图片转视频的图片URL或本地文件路径--
--video-url
用于视频转视频的视频URL或本地文件路径(适配gen4_aleph、seedance2)--
--output-dir
输出目录当前工作目录
API凭据仅来自
RUNWAYML_API_SECRET
——不提供
--api-key
参数,以避免密钥泄露到shell历史记录和进程列表中。

Filename Convention

文件名规范

Generate filenames with the pattern:
yyyy-mm-dd-hh-mm-ss-name.mp4
Examples:
  • "A cyberpunk city" ->
    2026-04-14-14-23-05-cyberpunk-city.mp4
  • "Waves on a beach" ->
    2026-04-14-15-30-12-beach-waves.mp4
按照以下格式生成文件名:
yyyy-mm-dd-hh-mm-ss-name.mp4
示例:
  • “赛博朋克城市” ->
    2026-04-14-14-23-05-cyberpunk-city.mp4
  • “海滩上的海浪” ->
    2026-04-14-15-30-12-beach-waves.mp4

Examples

示例

Text-to-video (seedance2):
bash
uv run scripts/generate_video.py --prompt "A serene mountain landscape at sunrise with mist" --filename "2026-04-14-mountain-sunrise.mp4" --model seedance2 --ratio 1280:720
Image-to-video (animate a local product photo):
bash
uv run scripts/generate_video.py --prompt "Camera slowly zooms out, product sparkles" --image-url "./product.jpg" --filename "2026-04-14-product-reveal.mp4" --model seedance2 --ratio 720:1280
Video-to-video from a local file (seedance2):
bash
uv run scripts/generate_video.py --prompt "Transform into a warm golden sunset scene" --video-url "./input.mp4" --filename "2026-04-14-sunset-transform.mp4" --model seedance2
Fast draft:
bash
uv run scripts/generate_video.py --prompt "A cat playing piano" --filename "draft.mp4" --model veo3.1_fast --ratio 1280:720 --duration 4
Premium quality:
bash
uv run scripts/generate_video.py --prompt "Cinematic drone shot over Tokyo at night" --filename "tokyo.mp4" --model veo3 --ratio 1280:720 --duration 8
文本转视频(seedance2):
bash
uv run scripts/generate_video.py --prompt "日出时分薄雾笼罩的宁静山地景观" --filename "2026-04-14-mountain-sunrise.mp4" --model seedance2 --ratio 1280:720
图片转视频(动效化本地产品照片):
bash
uv run scripts/generate_video.py --prompt "镜头缓慢拉远,产品闪耀光芒" --image-url "./product.jpg" --filename "2026-04-14-product-reveal.mp4" --model seedance2 --ratio 720:1280
本地文件视频转视频(seedance2):
bash
uv run scripts/generate_video.py --prompt "转换为温暖的金色日落场景" --video-url "./input.mp4" --filename "2026-04-14-sunset-transform.mp4" --model seedance2
快速草稿生成:
bash
uv run scripts/generate_video.py --prompt "猫咪弹钢琴" --filename "draft.mp4" --model veo3.1_fast --ratio 1280:720 --duration 4
顶级画质生成:
bash
uv run scripts/generate_video.py --prompt "夜晚东京上空的电影级无人机镜头" --filename "tokyo.mp4" --model veo3 --ratio 1280:720 --duration 8

Output

输出结果

  • The script downloads the result and saves it to the specified path
  • Script outputs the full path to the saved file
  • Do not read the video file back -- just inform the user of the saved path
  • 脚本会下载生成结果并保存到指定路径
  • 脚本会输出保存文件的完整路径
  • 请勿回读视频文件——只需告知用户保存路径即可

Common Failures

常见故障排查

  • Error: No API key
    -> set
    RUNWAYML_API_SECRET
    in the environment (e.g.
    export RUNWAYML_API_SECRET=...
    or a
    .env
    file).
  • Error: Task failed -- SAFETY.INPUT.*
    -> content moderation, suggest different prompt
  • Error: Task failed -- ASSET.INVALID
    -> bad input file format, check image/video format
  • API error 429
    -> rate limited, script auto-retries
  • Error: No API key
    -> 在环境中设置
    RUNWAYML_API_SECRET
    (例如
    export RUNWAYML_API_SECRET=...
    或使用
    .env
    文件)。
  • Error: Task failed -- SAFETY.INPUT.*
    -> 内容审核未通过,建议更换描述内容
  • Error: Task failed -- ASSET.INVALID
    -> 输入文件格式错误,检查图片/视频格式
  • API error 429
    -> 请求频率超限,脚本会自动重试

For Batch Generation

批量生成

To generate many videos at once, run this script in a loop — the agent can orchestrate multiple calls with different prompts, images, or parameters to produce campaigns, localized variants, or creative iterations at scale.
如需批量生成多个视频,可循环运行该脚本——Agent可以协调多次调用,使用不同的描述、图片或参数,大规模生成营销素材、本地化变体或创意迭代内容。