mcpField
I
integrate-video

integrate-video

github.com/runwaymlクリエイティブ・メディア7448 回インストール2 日前に更新
リポジトリ

integrate-video について

Runway の動画生成をサーバーサイドアプリに組み込む開発者向けスキルです。テキスト、画像、動画の各フローに加え、モデル選択と出力処理を扱います。

主な機能

  1. 01テキストから動画への組み込み
  2. 02画像から動画への組み込み
  3. 03動画の変換
  4. 04モデル選択の指針
  5. 05サーバーサイドルートの例

活用シーン

  1. 01APIへのテキスト動画生成の追加
  2. 02バックエンドルートで画像をアニメーション化
  3. 03既存動画の変換
  4. 04コストや速度に応じたモデル選択

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/runwayml/skills --skill integrate-video

インストール後、Claude Code で/integrate-videoを入力して読み込まれたか確認します。

詳細

動画生成の統合

前提条件: まず +check-compatibility を実行してください。統合する前に +fetch-api-reference を実行して最新の API リファレンスを読み込んでください。API 認証情報には +setup-api-key が必要です。入力にローカルファイルを使用する場合は +integrate-uploads が必要です。

ユーザーがサーバーサイドのコードに Runway の動画生成を追加できるよう支援します。

利用可能なモデル

モデル最適な用途入力コスト速度
gen4.5最高品質、汎用テキストおよび/または画像12 クレジット/秒標準
gen4_turbo高速、画像ベース画像必須5 クレジット/秒高速
gen4_aleph動画の編集/変換動画+テキスト/画像15 クレジット/秒標準
veo3Google のプレミアムモデルテキスト/画像40 クレジット/秒標準
veo3.1Google の高品質モデルテキスト/画像20~40 クレジット/秒標準
veo3.1_fastGoogle の高速モデルテキスト/画像10~15 クレジット/秒高速

モデル選択の指針:

  • デフォルトの推奨モデル:gen4.5 — 品質とコストのバランスに優れています
  • コスト重視:gen4_turbo(画像が必要)または veo3.1_fast
  • 最高品質:veo3(最も高価)
  • 動画から動画への編集:gen4_aleph(唯一の選択肢)

エンドポイント

テキストから動画へ:POST /v1/text_to_video

テキストプロンプトのみから動画を生成します。

対応モデル: gen4.5、veo3、veo3.1、veo3.1_fast

// Node.js SDK
import RunwayML from '@runwayml/sdk';

const client = new RunwayML();

const task = await client.textToVideo.create({
  model: 'gen4.5',
  promptText: 'A golden retriever running through a field of wildflowers at sunset',
  ratio: '1280:720',
  duration: 5
}).waitForTaskOutput();

// task.output is an array of signed URLs
const videoUrl = task.output[0];
# Python SDK
from runwayml import RunwayML

client = RunwayML()

task = client.text_to_video.create(
    model='gen4.5',
    prompt_text='A golden retriever running through a field of wildflowers at sunset',
    ratio='1280:720',
    duration=5
).wait_for_task_output()

video_url = task.output[0]
画像から動画へ:POST /v1/image_to_video

静止画を動画にアニメーション化します。

対応モデル: gen4.5、gen4_turbo、veo3、veo3.1、veo3.1_fast

// Node.js SDK
const task = await client.imageToVideo.create({
  model: 'gen4.5',
  promptImage: 'https://example.com/landscape.jpg',
  promptText: 'Camera slowly pans right revealing a mountain range',
  ratio: '1280:720',
  duration: 5
}).waitForTaskOutput();
# Python SDK
task = client.image_to_video.create(
    model='gen4.5',
    prompt_image='https://example.com/landscape.jpg',
    prompt_text='Camera slowly pans right revealing a mountain range',
    ratio='1280:720',
    duration=5
).wait_for_task_output()

ユーザーがローカル画像ファイルを持っている場合は、 まず +integrate-uploads を使ってアップロードします。

// Upload local file first
import fs from 'fs';

const upload = await client.uploads.createEphemeral(
  fs.createReadStream('/path/to/image.jpg')
);

const task = await client.imageToVideo.create({
  model: 'gen4.5',
  promptImage: upload.runwayUri,  // Use the runway:// URI
  promptText: 'The scene comes to life with gentle wind',
  ratio: '1280:720',
  duration: 5
}).waitForTaskOutput();
動画から動画へ:POST /v1/video_to_video

テキストプロンプトおよび/または参照画像を使って、既存の動画を変換します。

対応モデル: gen4_aleph

// Node.js SDK
const task = await client.videoToVideo.create({
  model: 'gen4_aleph',
  promptVideo: 'https://example.com/source.mp4',
  promptText: 'Transform into an animated cartoon style',
  ratio: '1280:720',
  duration: 5
}).waitForTaskOutput();
キャラクターの演技:POST /v1/character_performance

表情や身体の動きを付けてキャラクターをアニメーション化します。

対応モデル: act_two

const task = await client.characterPerformance.create({
  model: 'act_two',
  promptImage: 'https://example.com/character.jpg',
  promptPerformance: 'https://example.com/performance.mp4',
  ratio: '1280:720',
  duration: 5
}).waitForTaskOutput();

共通パラメーター

パラメーター型説明
modelstringモデル ID(必須)
promptTextstring動画を説明するテキストプロンプト
promptImagestring入力画像の URL、データ URI、または runway:// URI
ratiostringアスペクト比。例:'1280:720'、'720:1280'
durationnumber動画の長さ(秒)(2~10)

統合パターン

ユーザーの統合を支援する際は、次のパターンに従ってください。

  1. 用途を確認する — どの種類の動画生成か(テキストから動画、画像から動画など)
  2. ローカルファイルの有無を確認する — ユーザーがローカル画像/動画を持っている場合は、まず +integrate-uploads を使う
  3. モデルを選択する — 品質、コスト、速度のニーズに基づいて推奨する
  4. サーバーサイドのハンドラーを作成する — API ルートまたはサーバー関数を作成する
  5. 出力を処理する — 動画をダウンロードして保存し、署名付き URL をクライアントに提供しない
  6. エラー処理を追加する — try/catch で囲み、TaskFailedError を処理する
例:Express.js API ルート
import RunwayML from '@runwayml/sdk';
import express from 'express';

const client = new RunwayML();
const app = express();
app.use(express.json());

app.post('/api/generate-video', async (req, res) => {
  try {
    const { prompt, imageUrl, model = 'gen4.5', duration = 5 } = req.body;

    const params = {
      model,
      promptText: prompt,
      ratio: '1280:720',
      duration
    };

    let task;
    if (imageUrl) {
      task = await client.imageToVideo.create({
        ...params,
        promptImage: imageUrl
      }).waitForTaskOutput();
    } else {
      task = await client.textToVideo.create(params).waitForTaskOutput();
    }

    res.json({ videoUrl: task.output[0] });
  } catch (error) {
    console.error('Video generation failed:', error);
    res.status(500).json({ error: error.message });
  }
});
例:Next.js API ルート
// app/api/generate-video/route.ts
import RunwayML from '@runwayml/sdk';
import { NextRequest, NextResponse } from 'next/server';

const client = new RunwayML();

export async function POST(request: NextRequest) {
  const { prompt, imageUrl } = await request.json();

  try {
    const task = imageUrl
      ? await client.imageToVideo.create({
          model: 'gen4.5',
          promptImage: imageUrl,
          promptText: prompt,
          ratio: '1280:720',
          duration: 5
        }).waitForTaskOutput()
      : await client.textToVideo.create({
          model: 'gen4.5',
          promptText: prompt,
          ratio: '1280:720',
          duration: 5
        }).waitForTaskOutput();

    return NextResponse.json({ videoUrl: task.output[0] });
  } catch (error) {
    return NextResponse.json(
      { error: error instanceof Error ? error.message : 'Generation failed' },
      { status: 500 }
    );
  }
}
例:FastAPI ルート
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from runwayml import RunwayML

app = FastAPI()
client = RunwayML()

class VideoRequest(BaseModel):
    prompt: str
    image_url: str | None = None
    model: str = "gen4.5"
    duration: int = 5

@app.post("/api/generate-video")
async def generate_video(req: VideoRequest):
    try:
        if req.image_url:
            task = client.image_to_video.create(
                model=req.model,
                prompt_image=req.image_url,
                prompt_text=req.prompt,
                ratio="1280:720",
                duration=req.duration
            ).wait_for_task_output()
        else:
            task = client.text_to_video.create(
                model=req.model,
                prompt_text=req.prompt,
                ratio="1280:720",
                duration=req.duration
            ).wait_for_task_output()

        return {"video_url": task.output[0]}
    except Exception as e:
        raise HTTPException(status_code=500, detail=str(e))

ヒント

  • 出力 URL の有効期限は24~48時間です。 生成後すぐに、動画を独自のストレージ(S3、GCS、ローカルファイルシステム)にダウンロードしてください。
  • gen4_turbo には画像が必要です。 テキストのみの生成には対応していません。
  • gen4_aleph は唯一の動画から動画へのモデルです。 既存の動画を編集/変換する場合に使用してください。
  • 動画の長さは2~10秒です。 それより長い動画を作成するには、複数回の生成を連鎖させる必要があります。
  • waitForTaskOutput() のデフォルトのタイムアウトは10分です。 生成に時間がかかる場合は、独自のポーリングループを実装するか、タイムアウトを延長してください。
  • ローカルファイルの場合は、 必ず最初に +integrate-uploads を使ってアップロードし、その後 runway:// URI を渡してください。

コメント