Gemini API の Veo 3.1 で動画を生成する

動画理解については、動画理解ガイドをご覧ください。

Veo 3.1 は、ネイティブに生成された音声を含む 8 秒間の動画(720p、1080p、4k)を生成するモデルです。このモデルには、Gemini API を使用してプログラムでアクセスできます。使用可能な Veo モデル バリエーションの詳細については、モデルのバージョンをご覧ください。

Veo 3.1 は、幅広い視覚的および映画的なスタイルに優れており、いくつかの新機能が導入されています。

  • 縦向き動画: 横向き(16:9)と縦向き(9:16)の動画を選択します。
  • 動画の拡張: 以前に Veo を使用して生成された動画を拡張します。
  • フレーム固有の生成: 最初と最後のフレームを指定して動画を生成します。
  • 画像ベースの指示: 生成する動画の内容を示すため、参照画像を 3 枚まで使用できます。

動画生成用の効果的なテキスト プロンプトの作成方法については、Veo プロンプト ガイドをご覧ください。

テキストから動画を生成する

次の例は、会話映画のようなリアルさクリエイティブなアニメーションを含む動画を生成する方法を示しています。

会話と効果音

Python

import time
from google import genai
from google.genai import types

client = genai.Client()

prompt = """A close up of two people staring at a cryptic drawing on a wall, torchlight flickering.
A man murmurs, 'This must be it. That's the secret code.' The woman looks at him and whispering excitedly, 'What did you find?'"""

operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt=prompt,
)

# Poll the operation status until the video is ready.
while not operation.done:
    print("Waiting for video generation to complete...")
    time.sleep(10)
    operation = client.operations.get(operation)

# Download the generated video.
generated_video = operation.response.generated_videos[0]
client.files.download(file=