Gemini Omni Flash で動画を生成、編集する

Gemini Omni Flash(gemini-omni-1.1-flash)は、高速な動画生成、編集、シネマティックな制御を実現するように設計された高性能なマルチモーダル モデルです。 Gemini Omni は、以前の動画モデルとは異なる次のコア機能に基づいて構築されています。

  • ネイティブ マルチモーダル: テキスト、画像、音声、動画を同時に処理し、よりまとまりのある、一貫性のある、制御可能な出力を実現します。
  • 話して編集: Interactions API により、自然言語での会話を通じて動画を繰り返し調整、編集できます。変更したい内容を説明すると、保持したい動画の部分を維持しながら編集が適用されます。
  • 実世界の知識: Gemini Omni は、物理法則の理解と、歴史、科学、文化的背景に関する Gemini の知識を組み合わせることで、写実的な表現と意味のあるストーリーテリングとの間のギャップを埋めます。

テキストからの動画生成

テキスト プロンプトから動画を生成します。モデルは、テキストの説明に基づいて音声付きの動画を生成します。シーンの説明、カメラの動き、照明、ムードなどの詳細をプロンプトに記述すると、最適な結果が得られます。

Python

import base64
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input="A marble rolling fast on a chain reaction style track, continuous smooth shot."
)
with open("marble.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: 'A marble rolling fast on a chain reaction style track, continuous smooth shot.',
});

if (interaction.output_video?.data) {
  fs.writeFileSync('marble.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "model": "gemini-omni-1.1-flash",
 "input": "A marble rolling fast on a chain reaction style track, continuous smooth shot."
}'

REST レスポンス スキーマ

便利なフィールド interaction.output_videoSDK 専用 です。 REST API を直接使用する場合は、steps 配列から動画出力を取得します。

生の REST JSON 構造:

{
  "steps": [
    { "type": "user_input", "content": [{"type": "text", "text": "..."}] },
    { "type": "thought", "content": [{"text": "...", "type": "thought"}] },
    {
      "type": "model_output",
      "content": [
        {
          "type": "video",
          "mime_type": "video/mp4",
          "data": "AAAAIGZ0eXBpc29t..." // Base64 encoded video data
        }
      ]
    }
  ],
  "id": "v1_...",
  "status": "completed",
  "model": "gemini-omni-1.1-flash",
  "object": "interaction"
}

アスペクト比を制御する

aspect_ratio"9:16" に設定すると、縦向きの動画を作成できます。デフォルトは横向き(16:9)です。

Python

import base64
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input="A futuristic city with neon lights and flying cars, cyberpunk style",
    response_format={
        "type": "video",  # optional
        "aspect_ratio": "9:16"  # Supported values: "9:16", "16:9"
    }
)
with open("example.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: 'A futuristic city with neon lights and flying cars, cyberpunk style',
  response_format: {
    type: 'video', // optional
    aspect_ratio: '9:16' // Supported values: '9:16', '16:9'
  },
});

if (interaction.output_video?.data) {
  fs.writeFileSync('example.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "model": "gemini-omni-1.1-flash",
 "input": "A futuristic city with neon lights and flying cars, cyberpunk style",
 "response_format": {
   "type": "video",
   "aspect_ratio": "9:16"
 }
}'

出力解像度

生成された動画の出力解像度は、response_formatresolution パラメータで制御します。デフォルトの解像度は 720p です。

説明
360p 出力解像度 360p
720p 出力解像度 720p(デフォルト)
1080p 出力 1080p(アップスケール)
4k 出力 4K(アップスケール)

Python

import base64
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input="A drone shot of a mountain landscape at sunrise.",
    response_format={
        "type": "video",
        "resolution": "1080p",
    },
)
with open("hires.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: 'A drone shot of a mountain landscape at sunrise.',
  response_format: {
    type: 'video',
    resolution: '1080p',
  },
});

if (interaction.output_video?.data) {
  fs.writeFileSync('hires.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "model": "gemini-omni-1.1-flash",
 "input": "A drone shot of a mountain landscape at sunrise.",
 "response_format": {
   "type": "video",
   "resolution": "1080p"
 }
}'

画像からの動画生成

テキスト プロンプトとともに参照画像を提供できます。プロンプトに応じて、モデルは画像の用途を決定します。これは、商品写真、イラスト、写真を生き生きと表現するのに便利です。

次の例は、水から飛び出す魚の絵の参照画像を使用する方法を示しています。

水から飛び上がる魚の絵

次のプロンプトを使用します。

turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video

絵のリアルな動画を生成します。

Python

import base64
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input=[
        {"type": "image", "data": base64_image, "mime_type": "image/jpeg"},
        {"type": "text", "text": "turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video"}
    ],
)
with open("clownfish.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: [
    { type: 'image', data: base64Image, mime_type: 'image/jpeg' },
    { type: 'text', text: 'turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video' }
  ]
});

if (interaction.output_video?.data) {
  fs.writeFileSync('clownfish.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "model": "gemini-omni-1.1-flash",
 "input": [
   {"type": "image", "data": "'"$BASE64_IMAGE"'", "mime_type": "image/jpeg"},
   {"type": "text", "text": "turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video"}
 ]
}'

最初と最後のフレームの補間

Gemini Omni Flash は動画の補間をサポートしており、開始画像(最初のフレーム)と終了画像(最後のフレーム)の間をスムーズに移行する動画を生成できます。

input リストに 2 つの画像を指定し、プロンプトで目的のトランジションを説明します。モデルは、最初のフレームから最後のフレームまでシーンをアニメーション化します。

Python

import base64
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input=[
        {"type": "image", "data": first_frame_b64, "mime_type": "image/jpeg"},
        {"type": "image", "data": last_frame_b64, "mime_type": "image/jpeg"},
        {"type": "text", "text": "A smooth cinematic transition from a lush green forest at sunrise to a snowy forest under a starry night sky."}
    ],
)
with open("interpolation.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: [
    { type: 'image', data: firstFrameB64, mime_type: 'image/jpeg' },
    { type: 'image', data: lastFrameB64, mime_type: 'image/jpeg' },
    { type: 'text', text: 'A smooth cinematic transition from a lush green forest at sunrise to a snowy forest under a starry night sky.' }
  ]
});

if (interaction.output_video?.data) {
  fs.writeFileSync('interpolation.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "model": "gemini-omni-1.1-flash",
 "input": [
   {"type": "image", "data": "'"$FIRST_FRAME_B64"'", "mime_type": "image/jpeg"},
   {"type": "image", "data": "'"$LAST_FRAME_B64"'", "mime_type": "image/jpeg"},
   {"type": "text", "text": "A smooth cinematic transition from a lush green forest at sunrise to a snowy forest under a starry night sky."}
 ]
}'

被写体参照

参照画像として提供された特定の被写体を組み込んだ動画を生成できます。 たとえば、次のコードは、猫と毛糸の 2 枚の画像を提供して、猫が毛糸で遊ぶ動画を生成する方法を示しています。

Python

import base64
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input=[
        {"type": "image", "data": cat_b64, "mime_type": "image/png"},
        {"type": "image", "data": yarn_b64, "mime_type": "image/png"},
        {"type": "text", "text": "A cat playfully batting at a ball of yarn."}
    ],
)
with open("cat.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: [
    { type: 'image', data: catData, mime_type: 'image/png' },
    { type: 'image', data: yarnData, mime_type: 'image/png' },
    { type: 'text', text: 'A cat playfully batting at a ball of yarn.' }
  ]
});

if (interaction.output_video?.data) {
  fs.writeFileSync('cat.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "model": "gemini-omni-1.1-flash",
 "input": [
   {"type": "image", "data": "'"$CAT_B64"'", "mime_type": "image/png"},
   {"type": "image", "data": "'"$YARN_B64"'", "mime_type": "image/png"},
   {"type": "text", "text": "A cat playfully batting at a ball of yarn."}
 ]
}'

タスク パラメータ

video_configtask パラメータを使用して、目的の動作を明示的に指定します。たとえば、モデルに画像から動画を生成させる場合は、パラメータを image_to_video に設定します。設定しない場合、モデルはプロンプトから必要な情報を推測します。

使用できる値は次のとおりです。

  • text_to_video
  • image_to_video
  • reference_to_video
  • edit
  • extend

次の例は、前に示した画像から動画への変換の例でこれを設定する方法を示しています。

Python

import base64
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input=[
        {"type": "image", "data": base64_image, "mime_type": "image/jpeg"},
        {"type": "text", "text": "turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video"}
    ],
    generation_config={
      "video_config": {
        "task": "image_to_video",
      }
    },
)
with open("example.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from "@google/genai";
import * as fs from 'fs';
const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: [
    { type: 'image', data: base64Image, mime_type: 'image/jpeg' },
    { type: 'text', text: 'turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video' }
  ],
  generationConfig: {
    videoConfig: {
      task: 'image_to_video',
    }
  }
});

if (interaction.output_video?.data) {
  fs.writeFileSync('example.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-omni-1.1-flash",
    "input": [
      {
        "type": "image",
        "data": "'"$BASE64_IMAGE"'",
        "mime_type": "image/jpeg"
      },
      {
        "type": "text",
        "text": "turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video"
      }
    ],
    "generation_config": {
      "video_config": {
        "task": "image_to_video"
      }
    }
  }'

ステートフルな動画編集

動画を生成し、フォローアップ プロンプトを使用して繰り返し編集します。各ターンは前の結果に基づいて構築されます。モデルは動画のコンテキストを記憶し、言及しなかった要素を保持しながら変更を適用します。previous_interaction_id を使用すると、前の動画を再アップロードせずに、会話履歴と生成された動画の状態を追跡できます。

次の例は、最初の動画を生成してから編集する方法を示しています。

Python

import base64
from google import genai

client = genai.Client()

# Turn 1: Generate initial video
res1 = client.interactions.create(model="gemini-omni-1.1-flash", input="A woman playing violin outdoors.")

# Turn 2: Edit the previous video
res2 = client.interactions.create(
    model="gemini-omni-1.1-flash",
    previous_interaction_id=res1.id,
    input="Make the violin invisible."
)
with open("example.mp4", "wb") as f:
    f.write(base64.b64decode(res2.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

// Turn 1: Generate initial video
const res1 = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: 'A woman playing violin outdoors.',
});

// Turn 2: Edit the previous video
const res2 = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  previous_interaction_id: res1.id,
  input: 'Make the violin invisible.',
});

if (res2.output_video?.data) {
  fs.writeFileSync('example.mp4', Buffer.from(res2.output_video.data, 'base64'));
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "model": "gemini-omni-1.1-flash",
 "previous_interaction_id": "'"$PREVIOUS_ID"'",
 "input": "Make the violin invisible."
}'

最初の動画の例:

編集した動画の例:

会話の各ターンで新しい動画が生成されます。モデルは前のターンのコンテキストを理解しているため、シーン全体を再記述することなく、照明の調整や背景の入れ替えなどの増分変更を行うことができます。

独自の動画を編集する

Files API を使用して動画をアップロードし、Gemini Omni Flash で編集します。

次の例は、次の元の動画を編集する方法を示しています。

Python

import time
import base64
from google import genai

client = genai.Client()

# Upload video using the file API
video_file = client.files.upload(file="Video.mp4")

while video_file.state == "PROCESSING":
    print('Waiting for video to be processed.')
    time.sleep(10)
    video_file = client.files.get(name=video_file.name)

if video_file.state == "FAILED":
  raise ValueError(video_file.state)
print(f'Video processing complete: ' + video_file.uri)

# Edit your video
interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input=[
        {"type": "document", "uri": video_file.uri},
        {"type": "text", "text": "When the person touches the mirror, make the mirror ripple beautifully like liquid, and the person's arm turns into reflective mirror material"}
    ],
)
with open("example.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

// Upload video using the file API
let videoFile = await ai.files.upload({
  file: 'Video.mp4',
});

while (videoFile.state === 'PROCESSING') {
  console.log('Waiting for video to be processed.');
  await new Promise(r => setTimeout(r, 10000));
  videoFile = await ai.files.get({ name: videoFile.name });
}

if (videoFile.state === 'FAILED') {
  throw new Error(videoFile.state);
}
console.log('Video processing complete: ' + videoFile.uri);

// Edit your video
const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: [
    { type: 'document', uri: videoFile.uri },
    { type: 'text', text: "When the person touches the mirror, make the mirror ripple beautifully like liquid, and the person's arm turns into reflective mirror material" }
  ],
});

if (interaction.output_video?.data) {
  fs.writeFileSync('example.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

REST

#!/bin/bash
VIDEO_B64=$(encode_file "$VIDEO_FILE")

curl -sS -w "\n[HTTP %{http_code}]\n" "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d @- <<EOF > video_editing_response.json
{
  "model": "gemini-omni-1.1-flash",
  "input": [
    {
      "type": "user_input",
      "content": [
        {
          "type": "video",
          "mime_type": "video/mp4",
          "data": "$VIDEO_B64"
        },
        {
          "type": "text",
          "text": "When the person touches the mirror, make the mirror ripple beautifully like liquid, and the person's arm turns into reflective mirror material"
        }
      ]
    }
  ],
  "response_format": { "type": "video" }
}
EOF

編集した動画の例:

URI を使用して動画を取得する

response_formatdelivery="uri" パラメータを使用すると、生成された 4 MB を超える動画を取得できます。 これにより、動画が ACTIVE になるまでポーリングできる Google がホストする URI が返されます。

Python

import time
from google import genai

client = genai.Client()

# 1. Request video via URI delivery
interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input="A beautiful sunset.",
    response_format={"type": "video", "delivery": "uri"}
)

# 2. Extract file name and poll for ACTIVE state
video_output = interaction.output_video
file_name = video_output.uri.split("/")[-1] # Extract ID

print("Waiting for video processing...")
while True:
    f_info = client.files.get(name=f"files/{file_name}")
    if f_info.state.name == "ACTIVE":
        break
    elif f_info.state.name == "FAILED":
        raise RuntimeError("Generation failed.")
    time.sleep(5)

# 3. Download the final video
client.files.download(file=video_output.uri, destination="output.mp4")

JavaScript

import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI({});

// 1. Request video via URI delivery
const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: 'A beautiful sunset.',
  response_format: { type: 'video', delivery: 'uri' },
});

// 2. Extract file name and poll for ACTIVE state
const videoOutput = interaction.output_video;
const fileId = videoOutput.uri.match(/files\/([a-zA-Z0-9]+)/)[1];
const name = `files/${fileId}`;

console.log("Waiting for video processing...");
while (true) {
  const fInfo = await ai.files.get({ name });
  if (fInfo.state.name === 'ACTIVE') break;
  if (fInfo.state.name === 'FAILED') throw new Error("Generation failed.");
  await new Promise(r => setTimeout(r, 5000));
}

// 3. Download the final video
await ai.files.download({
  file: videoOutput,
  downloadPath: 'output.mp4',
});
console.log("💾 Saved video to output.mp4");

REST

#!/bin/bash

# 1. Initial request to generate the video
RESPONSE=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "model": "gemini-omni-1.1-flash",
 "input": "A beautiful sunset over a calm ocean.",
 "response_format": {"type": "video", "delivery": "uri"}
}')

# Extract FILE_ID from the URI (e.g., "files/abc-123" -> "abc-123")
FILE_URI=$(echo $RESPONSE | jq -r '.output_video.uri')
FILE_ID=$(echo $FILE_URI | cut -d'/' -f2)

echo "Video requested (ID: $FILE_ID). Waiting for processing..."

# 2. Polling loop
while true; do
 # Get current file status
 STATUS_JSON=$(curl -s -X GET "https://generativelanguage.googleapis.com/v1beta/files/$FILE_ID?key=$API_KEY")
 STATE=$(echo $STATUS_JSON | jq -r '.state')

 if [ "$STATE" == "ACTIVE" ]; then
   echo "Processing complete! Downloading..."
   break
 elif [ "$STATE" == "FAILED" ]; then
   echo "Error: Generation failed."
   exit 1
 else
   echo "Current state: $STATE... (waiting 5s)"
   sleep 5
 fi
done

# 3. Final download
curl -L -X GET "https://generativelanguage.googleapis.com/v1beta/files/$FILE_ID:download?alt=media&key=$API_KEY" \
--output "output.mp4"

echo "Done! Video saved to output.mp4"

生の REST JSON 構造(URI):

{
  "steps": [
    { "type": "user_input", "content": [{"type": "text", "text": "..."}] },
    { "type": "thought", "content": [{"text": "...", "type": "thought"}] },
    {
      "type": "model_output",
      "content": [
        {
          "type": "video",
          "mime_type": "video/mp4",
          "uri": "https://generativelanguage.googleapis.com/v1beta/files/...:download?alt=media"
        }
      ]
    }
  ],
  "id": "v1_...",
  "status": "completed",
  "model": "gemini-omni-1.1-flash",
  "object": "interaction"
}


動画拡張

クリップの末尾にシームレスな続きを生成して、既存の動画を拡張します。プロンプトで、動画をどのように続行するかを説明します(例: "Extend this video""Continue the scene: the camera pans across the mountains")。 モデルは入力動画を分析して、3 ~ 10 秒の続きを生成します。

次のものを拡張できます。

  • モデルによって生成された動画(マルチターン): 以前に生成された 動画を、その previous_interaction_id を参照して拡張します。
  • アップロードした動画: 拡張プロンプトとともに、アップロードした動画ファイル(Files API 経由)を提供します。

Python

import base64
from google import genai

client = genai.Client()

# Upload your video using the Files API
video_file = client.files.upload(file="my_video.mp4")

# Extend the video using prompt-based extension
interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input=[
        {"type": "document", "uri": video_file.uri},
        {"type": "text", "text": "Continue the scene."}
    ],
)
with open("extended.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

// Upload your video using the Files API
let videoFile = await ai.files.upload({
  file: 'my_video.mp4',
});

while (videoFile.state === 'PROCESSING') {
  await new Promise(r => setTimeout(r, 10000));
  videoFile = await ai.files.get({ name: videoFile.name });
}

// Extend the video using prompt-based extension
const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: [
    { type: 'document', uri: videoFile.uri },
    { type: 'text', text: 'Continue the scene.' }
  ],
});

if (interaction.output_video?.data) {
  fs.writeFileSync('extended.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY"     -H "Content-Type: application/json"     -d '{
 "model": "gemini-omni-1.1-flash",
 "input": [
   {"type": "document", "uri": "'"$VIDEO_URI"'"},
   {"type": "text", "text": "Continue the scene."}
 ]
}'

参照メディアで拡張する

プロンプトとともに input 配列に参照画像を提供して、新しいキャラクターや要素を拡張動画に導入できます。

Python

import base64
from google import genai

client = genai.Client()

# Upload base video and reference image using the Files API
video_file = client.files.upload(file="my_video.mp4")
character_img = client.files.upload(file="character.png")

# Extend the video while introducing the reference character
interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input=[
        {"type": "document", "uri": video_file.uri},
        {"type": "document", "uri": character_img.uri},
        {"type": "text", "text": "Extend this video: have the character shown in <IMAGE_REF_0> enter the scene and wave."}
    ],
)
with open("extended_with_character.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

// Upload base video and reference image using the Files API
let videoFile = await ai.files.upload({ file: 'my_video.mp4' });
let characterImg = await ai.files.upload({ file: 'character.png' });

while (videoFile.state === 'PROCESSING' || characterImg.state === 'PROCESSING') {
  await new Promise(r => setTimeout(r, 10000));
  videoFile = await ai.files.get({ name: videoFile.name });
  characterImg = await ai.files.get({ name: characterImg.name });
}

// Extend the video while introducing the reference character
const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: [
    { type: 'document', uri: videoFile.uri },
    { type: 'document', uri: characterImg.uri },
    { type: 'text', text: 'Extend this video: have the character shown in <IMAGE_REF_0> enter the scene and wave.' }
  ],
});

if (interaction.output_video?.data) {
  fs.writeFileSync('extended_with_character.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY"     -H "Content-Type: application/json"     -d '{
 "model": "gemini-omni-1.1-flash",
 "input": [
   {"type": "document", "uri": "'$VIDEO_URI'"},
   {"type": "document", "uri": "'$CHARACTER_IMG_URI'"},
   {"type": "text", "text": "Extend this video: have the character shown in <IMAGE_REF_0> enter the scene and wave."}
 ]
}'

拡張機能の制約とガイドライン

動画を拡張する際は、次のルールと制約に留意してください。

  • アップロードした動画の会話: 現在、誰かが話している アップロードした動画を拡張して会話を追加することはできません(キャラクターが沈黙している場合や、プロンプトで会話を追加しない場合は サポートされます)。
  • マルチターンの音声拡張: 会話や音声の生成がサポートされます マルチターン(previous_interaction_id)で以前に生成された動画を拡張する場合。
  • クリップの末尾のみ: 拡張は動画の末尾への追加に限定されます。 コンテンツを先頭に追加したり、クリップの途中で拡張したりすることはできません。
  • 再生時間の制限: 拡張用の入力動画は、アップロード時に 10 秒以内にする必要があります (マルチターンを使用する場合を除く)。
  • 地域での提供状況: アップロードした動画の拡張は、現在、 欧州経済領域(EEA)、スイス、英国のユーザーはご利用いただけません( モデルによって生成された動画の拡張は、利用可能なすべての地域でサポートされています)。

ベスト プラクティス

  • 大きな動画には URI 配信を使用する: 4 MB を超える動画(>720p の場合)では、delivery="uri"response_format を使用して、ペイロード サイズ制限を回避します。
  • パフォーマンスの最適化: 高速な同期ユニタリー生成の場合は、background=falsestore=falsestream=false を設定します。store=false を設定すると、生成された動画は previous_interaction_id を使用して後続のターンで編集できなくなります。
  • プロンプトの精度: 詳細については、プロンプト ガイドをご覧ください。

制限事項

  • 未成年者が写っている画像のアップロードと編集は、欧州経済領域、スイス、英国では対象外です。
  • 特定の認識可能な人物が写っている画像のアップロードと編集は対象外です。
  • アップロードした動画の編集または拡張は、現在、欧州経済領域(EEA)、スイス、英国のユーザーはご利用いただけません(モデルによって生成された動画の編集または拡張はサポートされています)。
  • 編集と拡張用の入力動画は、アップロード時に 10 秒以内にする必要があります(マルチターンでモデルによって生成された動画を拡張する場合を除く)。
  • 動画の拡張は動画の末尾への追加に限定されます。クリップの先頭への追加や途中の拡張は対象外です。
  • 誰かが話しているアップロードした動画を拡張して会話を追加することはできません(キャラクターは沈黙したままにすることも、previous_interaction_id を使用してマルチターン拡張を使用することもできます)。
  • 音声編集はサポートされていません。
  • 現在のバージョンの API では、音声参照のアップロードはサポートされていません。
  • 動画参照はライクネスで最適に機能します。動画参照の音声は無視されます。動画参照では、最大 3 つのクリップ(それぞれ最大 3 秒)がサポートされます。
  • 複数の動画にわたる参照や推論はサポートされていません。複数の動画のプロンプトを試すと、モデルのパフォーマンスが低下したり、予期しない出力が発生したりする可能性があります。
  • プロビジョニングされたスループットはサポートされていません。
  • システム指示、温度、top_p、停止シーケンス、ネガティブ プロンプトはサポートされていません(ネガティブは通常のプロンプトに記述できます。例: 「X を行わないでください」)。
  • YouTube 動画をメディアソースとして使用することはサポートされていません。

詳細な技術情報

  • 生成されたすべての動画には SynthID の透かしが含まれています。これは視聴者には見えませんが、来歴確認のためにプログラムで検出できます。
  • 動画の生成時間は、再生時間、解像度、現在の API の負荷によって異なります。動画の再生時間が長く、解像度が高いほど、生成に時間がかかります。
  • Omni は、入力プロンプトと生成された動画の両方にコンテンツ安全フィルタを適用します(地域によって異なります)。利用規約に違反するプロンプトはブロックされます。
  • 英語(EN)は完全にサポートされていますが、他の言語は評価されていないため、機能する可能性はありますが、結果は異なる場合があります。

Gemini Omni Flash プロンプト ガイド

このセクションでは、Gemini Omni Flash を効果的にプロンプトする方法に関するヒントと例を紹介します。

単一シーン

デフォルトでは、Omni Flash はいくつかの異なるショットを含む動画を作成しようとします。 プロンプトに基づいて、興味深いナレーションを作成しようとします。

出力動画に単一のシーンを含める必要がある場合は、次のようにプロンプトする必要があります。

  • 途切れない単一のシーンで
  • 連続した一発ショットで
  • シーンカットなし

次に例を示します。

Continuous, unbroken handheld shot of a fluffy tabby cat sitting on a sunny windowsill, looking out into a leafy garden. The cat's tail twitches slowly, and its ears rotate slightly toward ambient noises. Sunbeams illuminate dust motes in the air. Sound design: Gentle breeze, distant bird chirps. No dialogue.

不要な要素を削除する

生成された動画に不要なものが含まれている場合は、簡単なネガティブ プロンプトを含めて回避します。

  • 会話なし
  • 装飾なし
  • 追加の効果音なし

編集用のプロンプト

動画編集にはシンプルなプロンプトが最適です。説明が多すぎるプロンプトは、意図しない変更につながる可能性があります。

シンプルな編集プロンプトの例を次に示します。

  • この動画をアニメにする
  • この人にファッショナブルな帽子をかぶせる
  • 照明をよりドラマチックにする
  • 看板のテキストを「Omni Flash」に変更する

動画の特定の側面を編集する場合は、"Keep everything else the same" を含めて、視覚的な一貫性を維持します。

この手法の適用方法の例を次に示します。

  • 避けるべきこと: In the video of the man sitting on the sofa, please add a small black cat that runs from the right side of the screen, jumps onto his lap, and then he starts to stroke its head while looking down.
    • シンプルにする: Add a cat that jumps onto his lap, he begins to pet it. Keep everything else the same.
  • 避けるべきこと: Please remove the cell phone that the person is holding in their hand and fill in the background so it looks like they are just holding their hand empty.
    • シンプルにする: Make the phone invisible. Keep everything else the same.

音声のプロンプト

デフォルトでは、モデルは動画に適した音声トラックを生成しようとします。これが常に望ましいとは限りません。プロンプトを使用して、必要な音声の種類を説明できます。これは、動画に音楽を入れたい場合に特に重要です。

  • 穏やかなバックグラウンド ミュージックを含める
  • 動画にはハイエナジー テクノ ビートがある
  • 音声は、バックグラウンドで曲を再生する低音のラジオ放送

イベントのタイミング

動画の特定の時間に発生する事柄をプロンプトできます。正確な構文は必要なく、自然言語を使用できます。これは、独自のシーンカット、リズム、連射シーケンスを作成する場合に特に便利です。 例については、以下をご覧ください。

  • 3 秒後、女性がシーンに入る。
  • 5 秒で、バックグラウンド音声でサビが始まる。
  • 2 秒ごとに新しいフレームにカットする。
  • 連射シーケンスでは、0.5 秒ごとに(24 fps で 12 フレーム)シーンを新しい場所に切り替える。

タイムコード構文を使用することもできます。

[0-3s] A person is walking
[3-6s] They stop and turn around
[6-10s] They start running

メタプロンプト

Gemini Omni Flash に、動画生成の一般的な品質や原則に注意を払うように指示できます。

  • マイクロディテール、表現、タイミングを考慮して、非常にリッチで詳細でありながら完全に自然なシーンを作成する。
  • キャラクターと環境の説明は非常に詳細にする。 キャラクターに衣装デザインの原則を適用する。シーン内の人物、アイテム、オブジェクトを具体的に指定する。
  • 背景要素に適切な詳細を多く含めて、シーンをリアルで自然なものにする。
  • 1 秒ごとに異なる珍しい [thing] を表示する連射動画を作成し、アップビートな音楽を流し、テキストを含めてそのものをラベル付けする。

動画内のテキスト

プロンプトで動画にテキストを含めるように指示すると、Gemini Omni は正しく読みやすいようにレンダリングします。動画に自然に発生するテキスト(背景要素など)がある場合は、その内容を定義すると便利です。

  • 画面に一度に 1 つの単語を表示する: 「did, you, know, that, Omni, can, do, awesome, text?」 各単語は 1 秒間表示され、アニメーション スタイルは異なります。会話なし。
  • 「This is an AI generation by Omni」と書かれた道路標識がある。「All you need AI」と書かれた店舗がある。ナンバー プレートに「OMNI1.1」と書かれた車がある。

動画を拡張するためのプロンプト

Gemini Omni 1.1 Flash では、"Extend this video""The scene continues" などのプロンプトで動画を拡張できます。動画は 10 秒間延長でき、合計 40 秒まで延長できます。

Omni は、元の動画の最後の 10 秒をコンテキストとして使用して、動画、動き、キャラクター、音声を一貫して維持する拡張機能を作成します。入力動画の最後のフレームの一部は、トランジションをシームレスにするために編集されます。

拡張する場合でも、このガイドの Omni プロンプトのヒントはすべて適用されます。

  • 拡張シーンの音声を説明します。特に変更する必要がある場合は、"The music continues into the chorus"
  • シーンが続くかどうか、新しいシーンにショットカットがあるかどうか(同じキャラクターを使用する場合など)を説明します。"Show the same characters in the next scene"
  • 拡張時に画像と動画を参照として含めて、出力を正確に保つか、新しいキャラクターを導入します。"The person shown in the reference image enters the scene""The dog in the reference video <VIDEO_REF_0> jumps onto the sofa"
  • タイムスタンプまたはタイムコード構文を使用する場合、0 秒は動画の拡張部分の先頭を指します。10 秒の動画を拡張する場合、このプロンプトのシーンカットは 12 秒後に行われます。"After 2s cut to a new scene with the same characters"

プロンプトでタグを使用して画像と動画の役割を設定する

タグを使用すると、アップロードしたメディアを特定の生成ロールにバインドできます。これにより、各画像または動画が開始フレーム、最終フレーム、参照のいずれであるかを指定できます。

1. シンプルなタグ(推奨)

プロンプトからメディアの役割が明確な簡単なケースでは、画像と動画をロールに直接バインドできます。

  • <FIRST_FRAME>: 画像を動画の開始フレームとして使用します。 例: <FIRST_FRAME> a woman is walking
  • <LAST_FRAME>: 画像を動画の最終フレームとして使用してトランジションします。<FIRST_FRAME> と組み合わせて使用する必要があります。例: <FIRST_FRAME> <LAST_FRAME> a woman is walking
  • <IMAGE_REF_N>: 画像を参照として使用します。例: in the style of <IMAGE_REF_0> a woman <IMAGE_REF_1> is walking(最初の画像のスタイル 参照と 2 番目の画像の被写体参照を組み合わせます)。 画像参照は 0 から始まります。
  • <VIDEO_REF_N>: 動画をキャラクターまたはオブジェクト参照として使用します。例: the person in <VIDEO_REF_0> is playing the violin。動画参照も 0 から始まります。

次の例は、6 つの参照画像を使用したものです。

[0-3s] A studio fashion sequence. Starting with woman <IMAGE_REF_0>, she is holding <IMAGE_REF_1>
[3-6s] Then we see the man <IMAGE_REF_2> holding <IMAGE_REF_3>
[6-10s] And finally another woman <IMAGE_REF_4> who is holding <IMAGE_REF_5> while walking.

2. ソースと参照を宣言する

複数のメディア入力と複数のロールがある複雑なケースでは、自然言語の指示と組み合わせた明示的な接頭辞タグを使用できます。これらのソースと参照は、プロンプトの先頭で宣言する必要があります。

  • [# Sources <FIRST_FRAME>@Image1] は、最初の画像を開始フレームとして使用します。
  • [# Sources <FIRST_FRAME>@Image1 <LAST_FRAME>@Image2] は、最初の画像を開始フレームとして、2 番目の画像を最終フレームとして使用します。
  • [# Sources <FIRST_FRAME>@Image1 <LAST_FRAME>@Image1] は、最初の画像を最初のフレームと最後のフレームの両方として使用し、ループする動画を作成します。
  • [# Sources <FIRST_FRAME>@Image1] [# References <IMAGE_REF_0>@Image2] は、最初の画像を開始フレームとして、2 番目の画像を参照として使用します。
  • [# Sources <VIDEO_0>@Video1] は、動画を編集または変更するプライマリ ソース動画として使用します。
  • [# Sources <PREVIOUS_VIDEO>@Video1] は、前のターンの動画を使用して拡張します。
  • [# References <IMAGE_REF_0>@Image1] は、最初の画像を参照として使用します。
  • [# References <IMAGE_REF_1>@Image2] は、2 番目の画像を参照として使用します。
  • [# References <IMAGE_REF_0>@Image1 <IMAGE_REF_1>@Image2] は、両方の画像を参照として使用します。
  • [# References <VIDEO_REF_0>@Video1] は、最初の動画を参照として使用します。
  • [# References <IMAGE_REF_0>@Image1 <VIDEO_REF_0>@Video1] は、画像と動画の両方を参照として使用します。

プロンプトの末尾にガイド指示を追加します。

  • 開始フレームの場合: "Use this image as the starting frame."
  • 開始フレームと終了フレームを使用したループ動画の場合: "Use this image as the first frame and the last frame."
  • 参照画像の場合: "Use the given image(s) as references for video generation. The images should not be used as literal initial frames."
  • 参照動画の場合: "Use the given video(s) as references. Do not use them as a source for video editing."

ソースと参照の宣言を含むプロンプトの例を次に示します。

開始フレームと参照画像を組み合わせる:

[# Sources <FIRST_FRAME>@Image1] [# References <IMAGE_REF_0>@Image2] a woman <IMAGE_REF_0> is walking. Use Image1 as the starting frame. Use Image2 as a reference for the video generation.

キャラクター参照動画とオブジェクト参照画像を組み合わせる:

[# References <IMAGE_REF_0>@Image1 <VIDEO_REF_0>@Video1] The woman in <VIDEO_REF_0> is playing the violin shown in <IMAGE_REF_0>. Use Video1 as a character reference and Image1 as an object reference.

次のステップ