สร้างวิดีโอด้วย Veo 3.1 ใน Gemini API

ดูข้อมูลเกี่ยวกับการทำความเข้าใจวิดีโอได้ที่คำแนะนำการทำความเข้าใจวิดีโอ

Veo 3.1 เป็นโมเดลที่ล้ำสมัยของ Google สำหรับการสร้างวิดีโอความละเอียด 720p, 1080p หรือ 4k ความยาว 8 วินาทีที่มีความเที่ยงตรงสูง ซึ่งมีความสมจริงที่น่าทึ่งและเสียงที่สร้างขึ้นโดยตรง คุณเข้าถึง โมเดลนี้แบบเป็นโปรแกรมได้โดยใช้ 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=generated_video.video)
generated_video.video.save("dialogue_example.mp4")
print("Generated video saved to dialogue_example.mp4")

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const 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?'`;

let operation = await ai.models.generateVideos({
    model: "veo-3.1-generate-preview",
    prompt: prompt,
});

// Poll the operation status until the video is ready.
while (!operation.done) {
    console.log("Waiting for video generation to complete...")
    await new Promise((resolve) => setTimeout(resolve, 10000));
    operation = await ai.operations.getVideosOperation({
        operation: operation,
    });
}

// Download the generated video.
ai.files.download({
    file: operation.response.generatedVideos[0].video,
    downloadPath: "dialogue_example.mp4",
});
console.log(`Generated video saved to dialogue_example.mp4`);

Go

package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    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.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        prompt,
        nil,
        nil,
    )

    // Poll the operation status until the video is ready.
    for !operation.Done {
    log.Println("Waiting for video generation to complete...")
        time.Sleep(10 * time.Second)
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Download the generated video.
    video := operation.Response.GeneratedVideos[0]
    client.Files.Download(ctx, video.Video, nil)
    fname := "dialogue_example.mp4"
    _ = os.WriteFile(fname, video.Video.VideoBytes, 0644)
    log.Printf("Generated video saved to %s\n", fname)
}

Java

import com.google.genai.Client;
import com.google.genai.types.GenerateVideosOperation;
import com.google.genai.types.Video;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

class GenerateVideoFromText {
  public static void main(String[] args) throws Exception {
    Client client = new Client();

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

    GenerateVideosOperation operation =
        client.models.generateVideos("veo-3.1-generate-preview", prompt, null, null);

    // Poll the operation status until the video is ready.
    while (!operation.done().isPresent() || !operation.done().get()) {
      System.out.println("Waiting for video generation to complete...");
      Thread.sleep(10000);
      operation = client.operations.getVideosOperation(operation, null);
    }

    // Download the generated video.
    Video video = operation.response().get().generatedVideos().get().get(0).video().get();
    Path path = Paths.get("dialogue_example.mp4");
    client.files.download(video, path.toString(), null);
    if (video.videoBytes().isPresent()) {
      Files.write(path, video.videoBytes().get());
      System.out.println("Generated video saved to dialogue_example.mp4");
    }
  }
}

REST

# Note: This script uses jq to parse the JSON response.
# GEMINI API Base URL
BASE_URL="https://generativelanguage.googleapis.com/v1beta"

# Send request to generate video and capture the operation name into a variable.
operation_name=$(curl -s "${BASE_URL}/models/veo-3.1-generate-preview:predictLongRunning" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "instances": [{
        "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?\""
      }
    ]
  }' | jq -r .name)

# Poll the operation status until the video is ready
while true; do
  # Get the full JSON status and store it in a variable.
  status_response=$(curl -s -H "x-goog-api-key: $GEMINI_API_KEY" "${BASE_URL}/${operation_name}")

  # Check the "done" field from the JSON stored in the variable.
  is_done=$(echo "${status_response}" | jq .done)

  if [ "${is_done}" = "true" ]; then
    # Extract the download URI from the final response.
    video_uri=$(echo "${status_response}" | jq -r '.response.generateVideoResponse.generatedSamples[0].video.uri')
    echo "Downloading video from: ${video_uri}"

    # Download the video using the URI and API key and follow redirects.
    curl -L -o dialogue_example.mp4 -H "x-goog-api-key: $GEMINI_API_KEY" "${video_uri}"
    break
  fi
  # Wait for 5 seconds before checking again.
  sleep 10
done

ควบคุมสัดส่วนภาพ

Veo 3.1 ช่วยให้คุณสร้างวิดีโอแนวนอน (16:9 การตั้งค่าเริ่มต้น) หรือแนวตั้ง (9:16) ได้ คุณสามารถบอกโมเดลว่าต้องการใช้โมเดลใดโดยใช้พารามิเตอร์ aspect_ratio

Python

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

client = genai.Client()

prompt = """A montage of pizza making: a chef tossing and flattening the floury dough, ladling rich red tomato sauce in a spiral, sprinkling mozzarella cheese and pepperoni, and a final shot of the bubbling golden-brown pizza, upbeat electronic music with a rhythmical beat is playing, high energy professional video."""

operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt=prompt,
    config=types.GenerateVideosConfig(
      aspect_ratio="9:16",
    ),
)

# 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=generated_video.video)
generated_video.video.save("pizza_making.mp4")
print("Generated video saved to pizza_making.mp4")

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const prompt = `A montage of pizza making: a chef tossing and flattening the floury dough, ladling rich red tomato sauce in a spiral, sprinkling mozzarella cheese and pepperoni, and a final shot of the bubbling golden-brown pizza, upbeat electronic music with a rhythmical beat is playing, high energy professional video.`;

let operation = await ai.models.generateVideos({
    model: "veo-3.1-generate-preview",
    prompt: prompt,
    config: {
      aspectRatio: "9:16",
    },
});

// Poll the operation status until the video is ready.
while (!operation.done) {
    console.log("Waiting for video generation to complete...")
    await new Promise((resolve) => setTimeout(resolve, 10000));
    operation = await ai.operations.getVideosOperation({
        operation: operation,
    });
}

// Download the generated video.
ai.files.download({
    file: operation.response.generatedVideos[0].video,
    downloadPath: "pizza_making.mp4",
});
console.log(`Generated video saved to pizza_making.mp4`);

Go

package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    prompt := `A montage of pizza making: a chef tossing and flattening the floury dough, ladling rich red tomato sauce in a spiral, sprinkling mozzarella cheese and pepperoni, and a final shot of the bubbling golden-brown pizza, upbeat electronic music with a rhythmical beat is playing, high energy professional video.`

  videoConfig := &genai.GenerateVideosConfig{
      AspectRatio: "9:16",
  }

    operation, _ := client.Models.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        prompt,
        nil,
        videoConfig,
    )

    // Poll the operation status until the video is ready.
    for !operation.Done {
    log.Println("Waiting for video generation to complete...")
        time.Sleep(10 * time.Second)
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Download the generated video.
    video := operation.Response.GeneratedVideos[0]
    client.Files.Download(ctx, video.Video, nil)
    fname := "pizza_making.mp4"
    _ = os.WriteFile(fname, video.Video.VideoBytes, 0644)
    log.Printf("Generated video saved to %s\n", fname)
}

REST

# Note: This script uses jq to parse the JSON response.
# GEMINI API Base URL
BASE_URL="https://generativelanguage.googleapis.com/v1beta"

# Send request to generate video and capture the operation name into a variable.
operation_name=$(curl -s "${BASE_URL}/models/veo-3.1-generate-preview:predictLongRunning" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "instances": [{
        "prompt": "A montage of pizza making: a chef tossing and flattening the floury dough, ladling rich red tomato sauce in a spiral, sprinkling mozzarella cheese and pepperoni, and a final shot of the bubbling golden-brown pizza, upbeat electronic music with a rhythmical beat is playing, high energy professional video."
      }
    ],
    "parameters": {
      "aspectRatio": "9:16"
    }
  }' | jq -r .name)

# Poll the operation status until the video is ready
while true; do
  # Get the full JSON status and store it in a variable.
  status_response=$(curl -s -H "x-goog-api-key: $GEMINI_API_KEY" "${BASE_URL}/${operation_name}")

  # Check the "done" field from the JSON stored in the variable.
  is_done=$(echo "${status_response}" | jq .done)

  if [ "${is_done}" = "true" ]; then
    # Extract the download URI from the final response.
    video_uri=$(echo "${status_response}" | jq -r '.response.generateVideoResponse.generatedSamples[0].video.uri')
    echo "Downloading video from: ${video_uri}"

    # Download the video using the URI and API key and follow redirects.
    curl -L -o pizza_making.mp4 -H "x-goog-api-key: $GEMINI_API_KEY" "${video_uri}"
    break
  fi
  # Wait for 5 seconds before checking again.
  sleep 10
done

ควบคุมความละเอียด

นอกจากนี้ Veo 3.1 ยังสร้างวิดีโอ 720p, 1080p หรือ 4k ได้โดยตรงอีกด้วย

โปรดทราบว่ายิ่งความละเอียดสูง เวลาในการตอบสนองก็จะยิ่งสูง วิดีโอ 4K ยังมีราคาสูงกว่าด้วย (ดูราคา)

ส่วนขยายวิดีโอยังจำกัดไว้สำหรับวิดีโอ 720p ด้วย

Python

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

client = genai.Client()

prompt = """A stunning drone view of the Grand Canyon during a flamboyant sunset that highlights the canyon's colors. The drone slowly flies towards the sun then accelerates, dives and flies inside the canyon."""

operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt=prompt,
    config=types.GenerateVideosConfig(
      resolution="4k",
    ),
)

# 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=generated_video.video)
generated_video.video.save("4k_grand_canyon.mp4")
print("Generated video saved to 4k_grand_canyon.mp4")

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const prompt = `A stunning drone view of the Grand Canyon during a flamboyant sunset that highlights the canyon's colors. The drone slowly flies towards the sun then accelerates, dives and flies inside the canyon.`;

let operation = await ai.models.generateVideos({
    model: "veo-3.1-generate-preview",
    prompt: prompt,
    config: {
      resolution: "4k",
    },
});

// Poll the operation status until the video is ready.
while (!operation.done) {
    console.log("Waiting for video generation to complete...")
    await new Promise((resolve) => setTimeout(resolve, 10000));
    operation = await ai.operations.getVideosOperation({
        operation: operation,
    });
}

// Download the generated video.
ai.files.download({
    file: operation.response.generatedVideos[0].video,
    downloadPath: "4k_grand_canyon.mp4",
});
console.log(`Generated video saved to 4k_grand_canyon.mp4`);

Go

package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    prompt := `A stunning drone view of the Grand Canyon during a flamboyant sunset that highlights the canyon's colors. The drone slowly flies towards the sun then accelerates, dives and flies inside the canyon.`

  videoConfig := &genai.GenerateVideosConfig{
      Resolution: "4k",
  }

    operation, _ := client.Models.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        prompt,
        nil,
        videoConfig,
    )

    // Poll the operation status until the video is ready.
    for !operation.Done {
    log.Println("Waiting for video generation to complete...")
        time.Sleep(10 * time.Second)
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Download the generated video.
    video := operation.Response.GeneratedVideos[0]
    client.Files.Download(ctx, video.Video, nil)
    fname := "4k_grand_canyon.mp4"
    _ = os.WriteFile(fname, video.Video.VideoBytes, 0644)
    log.Printf("Generated video saved to %s\n", fname)
}

REST

# Note: This script uses jq to parse the JSON response.
# GEMINI API Base URL
BASE_URL="https://generativelanguage.googleapis.com/v1beta"

# Send request to generate video and capture the operation name into a variable.
operation_name=$(curl -s "${BASE_URL}/models/veo-3.1-generate-preview:predictLongRunning" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "instances": [{
        "prompt": "A stunning drone view of the Grand Canyon during a flamboyant sunset that highlights the canyon'\''s colors. The drone slowly flies towards the sun then accelerates, dives and flies inside the canyon."
      }
    ],
    "parameters": {
      "resolution": "4k"
    }
  }' | jq -r .name)

# Poll the operation status until the video is ready
while true; do
  # Get the full JSON status and store it in a variable.
  status_response=$(curl -s -H "x-goog-api-key: $GEMINI_API_KEY" "${BASE_URL}/${operation_name}")

  # Check the "done" field from the JSON stored in the variable.
  is_done=$(echo "${status_response}" | jq .done)

  if [ "${is_done}" = "true" ]; then
    # Extract the download URI from the final response.
    video_uri=$(echo "${status_response}" | jq -r '.response.generateVideoResponse.generatedSamples[0].video.uri')
    echo "Downloading video from: ${video_uri}"

    # Download the video using the URI and API key and follow redirects.
    curl -L -o 4k_grand_canyon.mp4 -H "x-goog-api-key: $GEMINI_API_KEY" "${video_uri}"
    break
  fi
  # Wait for 5 seconds before checking again.
  sleep 10
done

การสร้างวิดีโอจากรูปภาพ

โค้ดต่อไปนี้แสดงการสร้างรูปภาพโดยใช้ Gemini 2.5 Flash Image หรือที่เรียกว่า Nano Banana จากนั้นใช้รูปภาพดังกล่าวเป็น เฟรมเริ่มต้นสำหรับการสร้างวิดีโอด้วย Veo 3.1

Python

import time
from google import genai

client = genai.Client()

prompt = "Panning wide shot of a calico kitten sleeping in the sunshine"

# Step 1: Generate an image with Nano Banana.
image = client.models.generate_content(
    model="gemini-2.5-flash-image",
    contents=prompt,
    config={"response_modalities":['IMAGE']}
)

# Step 2: Generate video with Veo 3.1 using the image.
operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt=prompt,
    image=image.parts[0].as_image(),
)

# 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 video.
video = operation.response.generated_videos[0]
client.files.download(file=video.video)
video.video.save("veo3_with_image_input.mp4")
print("Generated video saved to veo3_with_image_input.mp4")

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const prompt = "Panning wide shot of a calico kitten sleeping in the sunshine";

// Step 1: Generate an image with Nano Banana.
const imageResponse = await ai.models.generateContent({
  model: "gemini-2.5-flash-image",
  prompt: prompt,
});

// Step 2: Generate video with Veo 3.1 using the image.
let operation = await ai.models.generateVideos({
  model: "veo-3.1-generate-preview",
  prompt: prompt,
  image: {
    imageBytes: imageResponse.generatedImages[0].image.imageBytes,
    mimeType: "image/png",
  },
});

// Poll the operation status until the video is ready.
while (!operation.done) {
  console.log("Waiting for video generation to complete...")
  await new Promise((resolve) => setTimeout(resolve, 10000));
  operation = await ai.operations.getVideosOperation({
    operation: operation,
  });
}

// Download the video.
ai.files.download({
    file: operation.response.generatedVideos[0].video,
    downloadPath: "veo3_with_image_input.mp4",
});
console.log(`Generated video saved to veo3_with_image_input.mp4`);

Go

package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    prompt := "Panning wide shot of a calico kitten sleeping in the sunshine"

    // Step 1: Generate an image with Nano Banana.
    imageResponse, err := client.Models.GenerateContent(
        ctx,
        "gemini-2.5-flash-image",
        prompt,
        nil, // GenerateImagesConfig
    )
    if err != nil {
        log.Fatal(err)
    }

    // Step 2: Generate video with Veo 3.1 using the image.
    operation, err := client.Models.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        prompt,
        imageResponse.GeneratedImages[0].Image,
        nil, // GenerateVideosConfig
    )
    if err != nil {
        log.Fatal(err)
    }

    // Poll the operation status until the video is ready.
    for !operation.Done {
        log.Println("Waiting for video generation to complete...")
        time.Sleep(10 * time.Second)
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Download the video.
    video := operation.Response.GeneratedVideos[0]
    client.Files.Download(ctx, video.Video, nil)
    fname := "veo3_with_image_input.mp4"
    _ = os.WriteFile(fname, video.Video.VideoBytes, 0644)
    log.Printf("Generated video saved to %s\n", fname)
}

Java

import com.google.genai.Client;
import com.google.genai.types.GenerateVideosOperation;
import com.google.genai.types.Image;
import com.google.genai.types.Video;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

class GenerateVideoFromImage {
  public static void main(String[] args) throws Exception {
    Client client = new Client();

    String prompt = "Panning wide shot of a calico kitten sleeping in the sunshine";

    // Step 1: Generate an image with Nano Banana:
    // ...
    // We assume 'image' contains the generated image from step 1,
    // or is loaded from a file:
    Image image = Image.fromFile("path/to/your/image.png");

    // Step 2: Generate video with Veo 3.1 using the image.
    GenerateVideosOperation operation =
        client.models.generateVideos("veo-3.1-generate-preview", prompt, image, null);

    // Poll the operation status until the video is ready.
    while (!operation.done().isPresent() || !operation.done().get()) {
      System.out.println("Waiting for video generation to complete...");
      Thread.sleep(10000);
      operation = client.operations.getVideosOperation(operation, null);
    }

    // Download the video.
    Video video = operation.response().get().generatedVideos().get().get(0).video().get();
    Path path = Paths.get("veo3_with_image_input.mp4");
    client.files.download(video, path.toString(), null);
    if (video.videoBytes().isPresent()) {
      Files.write(path, video.videoBytes().get());
      System.out.println("Generated video saved to veo3_with_image_input.mp4");
    }
  }
}

การใช้รูปภาพอ้างอิง

ตอนนี้ Veo 3.1 รับรูปภาพอ้างอิงได้สูงสุด 3 รูปเพื่อเป็นแนวทางสำหรับเนื้อหาของวิดีโอที่สร้างขึ้น ระบุรูปภาพของบุคคล ตัวละคร หรือผลิตภัณฑ์เพื่อ คงรูปลักษณ์ของวัตถุในวิดีโอเอาต์พุต

เช่น การใช้รูปภาพ 3 รูปที่สร้างด้วย Nano Banana เป็นข้อมูลอ้างอิงร่วมกับ พรอมต์ที่เขียนอย่างดีจะสร้างวิดีโอต่อไปนี้

`dress_image` `woman_image` `glasses_image`
ชุดฟลามิงโกแฟชั่นชั้นสูงที่มีขนนกสีชมพูและสีชมพูเข้มซ้อนกัน หญิงสาวสวยผมสีเข้มและดวงตาสีน้ำตาลอบอุ่น แว่นกันแดดสีชมพูรูปหัวใจสุดเก๋

Python

import time
from google import genai

client = genai.Client()

prompt = "The video opens with a medium, eye-level shot of a beautiful woman with dark hair and warm brown eyes. She wears a magnificent, high-fashion flamingo dress with layers of pink and fuchsia feathers, complemented by whimsical pink, heart-shaped sunglasses. She walks with serene confidence through the crystal-clear, shallow turquoise water of a sun-drenched lagoon. The camera slowly pulls back to a medium-wide shot, revealing the breathtaking scene as the dress's long train glides and floats gracefully on the water's surface behind her. The cinematic, dreamlike atmosphere is enhanced by the vibrant colors of the dress against the serene, minimalist landscape, capturing a moment of pure elegance and high-fashion fantasy."

dress_reference = types.VideoGenerationReferenceImage(
  image=dress_image, # Generated separately with Nano Banana
  reference_type="asset"
)

sunglasses_reference = types.VideoGenerationReferenceImage(
  image=glasses_image, # Generated separately with Nano Banana
  reference_type="asset"
)

woman_reference = types.VideoGenerationReferenceImage(
  image=woman_image, # Generated separately with Nano Banana
  reference_type="asset"
)

operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt=prompt,
    config=types.GenerateVideosConfig(
      reference_images=[dress_reference, glasses_reference, woman_reference],
    ),
)

# 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 video.
video = operation.response.generated_videos[0]
client.files.download(file=video.video)
video.video.save("veo3.1_with_reference_images.mp4")
print("Generated video saved to veo3.1_with_reference_images.mp4")

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const prompt = "The video opens with a medium, eye-level shot of a beautiful woman with dark hair and warm brown eyes. She wears a magnificent, high-fashion flamingo dress with layers of pink and fuchsia feathers, complemented by whimsical pink, heart-shaped sunglasses. She walks with serene confidence through the crystal-clear, shallow turquoise water of a sun-drenched lagoon. The camera slowly pulls back to a medium-wide shot, revealing the breathtaking scene as the dress's long train glides and floats gracefully on the water's surface behind her. The cinematic, dreamlike atmosphere is enhanced by the vibrant colors of the dress against the serene, minimalist landscape, capturing a moment of pure elegance and high-fashion fantasy.";

// dressImage, glassesImage, womanImage generated separately with Nano Banana
// and available as objects like { imageBytes: "...", mimeType: "image/png" }
const dressReference = {
  image: dressImage,
  referenceType: "asset",
};
const sunglassesReference = {
  image: glassesImage,
  referenceType: "asset",
};
const womanReference = {
  image: womanImage,
  referenceType: "asset",
};

let operation = await ai.models.generateVideos({
  model: "veo-3.1-generate-preview",
  prompt: prompt,
  config: {
    referenceImages: [
      dressReference,
      sunglassesReference,
      womanReference,
    ],
  },
});

// Poll the operation status until the video is ready.
while (!operation.done) {
  console.log("Waiting for video generation to complete...");
  await new Promise((resolve) => setTimeout(resolve, 10000));
  operation = await ai.operations.getVideosOperation({
    operation: operation,
  });
}

// Download the video.
ai.files.download({
  file: operation.response.generatedVideos[0].video,
  downloadPath: "veo3.1_with_reference_images.mp4",
});
console.log(`Generated video saved to veo3.1_with_reference_images.mp4`);

Go

package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

  prompt := `The video opens with a medium, eye-level shot of a beautiful woman with dark hair and warm brown eyes. She wears a magnificent, high-fashion flamingo dress with layers of pink and fuchsia feathers, complemented by whimsical pink, heart-shaped sunglasses. She walks with serene confidence through the crystal-clear, shallow turquoise water of a sun-drenched lagoon. The camera slowly pulls back to a medium-wide shot, revealing the breathtaking scene as the dress's long train glides and floats gracefully on the water's surface behind her. The cinematic, dreamlike atmosphere is enhanced by the vibrant colors of the dress against the serene, minimalist landscape, capturing a moment of pure elegance and high-fashion fantasy.`

  // dressImage, glassesImage, womanImage generated separately with Nano Banana
  // and available as *genai.Image objects.
  var dressImage, glassesImage, womanImage *genai.Image

  dressReference := &genai.VideoGenerationReferenceImage{
    Image: dressImage,
    ReferenceType: "asset",
  }
  sunglassesReference := &genai.VideoGenerationReferenceImage{
    Image: glassesImage,
    ReferenceType: "asset",
  }
  womanReference := &genai.VideoGenerationReferenceImage{
    Image: womanImage,
    ReferenceType: "asset",
  }

    operation, _ := client.Models.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        prompt,
    nil, // image
        &genai.GenerateVideosConfig{
      ReferenceImages: []*genai.VideoGenerationReferenceImage{
        dressReference,
        sunglassesReference,
        womanReference,
      },
    },
    )

    // Poll the operation status until the video is ready.
    for !operation.Done {
        log.Println("Waiting for video generation to complete...")
        time.Sleep(10 * time.Second)
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Download the video.
    video := operation.Response.GeneratedVideos[0]
    client.Files.Download(ctx, video.Video, nil)
    fname := "veo3.1_with_reference_images.mp4"
    _ = os.WriteFile(fname, video.Video.VideoBytes, 0644)
    log.Printf("Generated video saved to %s\n", fname)
}

REST

# Note: This script uses jq to parse the JSON response.
# It assumes dress_image_base64, glasses_image_base64, and woman_image_base64
# contain base64-encoded image data.

# GEMINI API Base URL
BASE_URL="https://generativelanguage.googleapis.com/v1beta"

# Send request to generate video and capture the operation name into a variable.
operation_name=$(curl -s "${BASE_URL}/models/veo-3.1-generate-preview:predictLongRunning" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "instances": [{
      "prompt": "The video opens with a medium, eye-level shot of a beautiful woman with dark hair and warm brown eyes. She wears a magnificent, high-fashion flamingo dress with layers of pink and fuchsia feathers, complemented by whimsical pink, heart-shaped sunglasses. She walks with serene confidence through the crystal-clear, shallow turquoise water of a sun-drenched lagoon. The camera slowly pulls back to a medium-wide shot, revealing the breathtaking scene as the dress'\''s long train glides and floats gracefully on the water'\''s surface behind her. The cinematic, dreamlike atmosphere is enhanced by the vibrant colors of the dress against the serene, minimalist landscape, capturing a moment of pure elegance and high-fashion fantasy.",
      "referenceImages": [
        {
          "image": {"inlineData": {"mimeType": "image/png", "data": "'"$dress_image_base64"'"}},
          "referenceType": "asset"
        },
        {
          "image": {"inlineData": {"mimeType": "image/png", "data": "'"$glasses_image_base64"'"}},
          "referenceType": "asset"
        },
        {
          "image": {"inlineData": {"mimeType": "image/png", "data": "'"$woman_image_base64"'"}},
          "referenceType": "asset"
        }
      ]
    }],
  }' | jq -r .name)

# Poll the operation status until the video is ready
while true; do
  # Get the full JSON status and store it in a variable.
  status_response=$(curl -s -H "x-goog-api-key: $GEMINI_API_KEY" "${BASE_URL}/${operation_name}")

  # Check the "done" field from the JSON stored in the variable.
  is_done=$(echo "${status_response}" | jq .done)

  if [ "${is_done}" = "true" ]; then
    # Extract the download URI from the final response.
    video_uri=$(echo "${status_response}" | jq -r '.response.generateVideoResponse.generatedSamples[0].video.uri')
    echo "Downloading video from: ${video_uri}"

    # Download the video using the URI and API key and follow redirects.
    curl -L -o veo3.1_with_reference_images.mp4 -H "x-goog-api-key: $GEMINI_API_KEY" "${video_uri}"
    break
  fi
  # Wait for 10 seconds before checking again.
  sleep 10
done

การใช้เฟรมแรกและเฟรมสุดท้าย

Veo 3.1 ช่วยให้คุณสร้างวิดีโอได้โดยใช้การประมาณค่าระหว่างจุด หรือการระบุเฟรมแรกและเฟรมสุดท้ายของวิดีโอ ดูข้อมูลเกี่ยวกับการเขียนพรอมต์ข้อความที่มีประสิทธิภาพ สำหรับการสร้างวิดีโอได้ที่คู่มือพรอมต์ของ Veo

Python

import time
from google import genai

client = genai.Client()

prompt = "A cinematic, haunting video. A ghostly woman with long white hair and a flowing dress swings gently on a rope swing beneath a massive, gnarled tree in a foggy, moonlit clearing. The fog thickens and swirls around her, and she slowly fades away, vanishing completely. The empty swing is left swaying rhythmically on its own in the eerie silence."

operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt=prompt,
    image=first_image, # The starting frame is passed as a primary input
    config=types.GenerateVideosConfig(
      last_frame=last_image # The ending frame is passed as a generation constraint in the config
    ),
)

# 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 video.
video = operation.response.generated_videos[0]
client.files.download(file=video.video)
video.video.save("veo3.1_with_interpolation.mp4")
print("Generated video saved to veo3.1_with_interpolation.mp4")

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const prompt = "A cinematic, haunting video. A ghostly woman with long white hair and a flowing dress swings gently on a rope swing beneath a massive, gnarled tree in a foggy, moonlit clearing. The fog thickens and swirls around her, and she slowly fades away, vanishing completely. The empty swing is left swaying rhythmically on its own in the eerie silence.";

// firstImage and lastImage generated separately with Nano Banana
// and available as objects like { imageBytes: "...", mimeType: "image/png" }
let operation = await ai.models.generateVideos({
    model: "veo-3.1-generate-preview",
    prompt: prompt,
    image: firstImage, // The starting frame is passed as a primary input
    config: {
      lastFrame: lastImage, // The ending frame is passed as a generation constraint in the config
    },
});

// Poll the operation status until the video is ready.
while (!operation.done) {
    console.log("Waiting for video generation to complete...")
    await new Promise((resolve) => setTimeout(resolve, 10000));
    operation = await ai.operations.getVideosOperation({
        operation: operation,
    });
}

// Download the video.
ai.files.download({
    file: operation.response.generatedVideos[0].video,
    downloadPath: "veo3.1_with_interpolation.mp4",
});
console.log(`Generated video saved to veo3.1_with_interpolation.mp4`);

Go

package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

  prompt := `A cinematic, haunting video. A ghostly woman with long white hair and a flowing dress swings gently on a rope swing beneath a massive, gnarled tree in a foggy, moonlit clearing. The fog thickens and swirls around her, and she slowly fades away, vanishing completely. The empty swing is left swaying rhythmically on its own in the eerie silence.`

  // firstImage and lastImage generated separately with Nano Banana
  // and available as *genai.Image objects.
  var firstImage, lastImage *genai.Image

    operation, _ := client.Models.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        prompt,
    firstImage, // The starting frame is passed as a primary input
        &genai.GenerateVideosConfig{
      LastFrame: lastImage, // The ending frame is passed as a generation constraint in the config
    },
    )

    // Poll the operation status until the video is ready.
    for !operation.Done {
        log.Println("Waiting for video generation to complete...")
        time.Sleep(10 * time.Second)
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Download the video.
    video := operation.Response.GeneratedVideos[0]
    client.Files.Download(ctx, video.Video, nil)
    fname := "veo3.1_with_interpolation.mp4"
    _ = os.WriteFile(fname, video.Video.VideoBytes, 0644)
    log.Printf("Generated video saved to %s\n", fname)
}

REST

# Note: This script uses jq to parse the JSON response.
# It assumes first_image_base64 and last_image_base64
# contain base64-encoded image data.

# GEMINI API Base URL
BASE_URL="https://generativelanguage.googleapis.com/v1beta"

# Send request to generate video and capture the operation name into a variable.
# The starting frame is passed as a primary input
# The ending frame is passed as a generation constraint in the config
operation_name=$(curl -s "${BASE_URL}/models/veo-3.1-generate-preview:predictLongRunning" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "instances": [{
      "prompt": "A cinematic, haunting video. A ghostly woman with long white hair and a flowing dress swings gently on a rope swing beneath a massive, gnarled tree in a foggy, moonlit clearing. The fog thickens and swirls around her, and she slowly fades away, vanishing completely. The empty swing is left swaying rhythmically on its own in the eerie silence.",
      "image": {"inlineData": {"mimeType": "image/png", "data": "'"$first_image_base64"'"}},
      "lastFrame": {"inlineData": {"mimeType": "image/png", "data": "'"$last_image_base64"'"}}
    }],
  }' | jq -r .name)

# Poll the operation status until the video is ready
while true; do
  # Get the full JSON status and store it in a variable.
  status_response=$(curl -s -H "x-goog-api-key: $GEMINI_API_KEY" "${BASE_URL}/${operation_name}")

  # Check the "done" field from the JSON stored in the variable.
  is_done=$(echo "${status_response}" | jq .done)

  if [ "${is_done}" = "true" ]; then
    # Extract the download URI from the final response.
    video_uri=$(echo "${status_response}" | jq -r '.response.generateVideoResponse.generatedSamples[0].video.uri')
    echo "Downloading video from: ${video_uri}"

    # Download the video using the URI and API key and follow redirects.
    curl -L -o veo3.1_with_interpolation.mp4 -H "x-goog-api-key: $GEMINI_API_KEY" "${video_uri}"
    break
  fi
  # Wait for 10 seconds before checking again.
  sleep 10
done
`first_image` `last_image` veo3.1_with_interpolation.mp4
หญิงสาวผีผมยาวสีขาวและชุดพลิ้วไหวแกว่งตัวเบาๆ บนชิงช้าเชือก หญิงสาวลึกลับหายตัวไปจากชิงช้า วิดีโอที่ชวนหลอนราวกับภาพยนตร์ของหญิงสาวลึกลับที่หายตัวไปจากชิงช้าในหมอก

การขยายวิดีโอ Veo

ใช้ Veo 3.1 เพื่อขยายวิดีโอที่สร้างด้วย Veo ก่อนหน้านี้ได้ 7 วินาที และสูงสุด 20 เท่า

ข้อจำกัดของวิดีโออินพุต

  • วิดีโอที่ Veo สร้างขึ้นจะมีความยาวได้สูงสุด 141 วินาที
  • Gemini API รองรับเฉพาะส่วนขยายวิดีโอสำหรับวิดีโอที่สร้างด้วย Veo
  • วิดีโอควรมาจากรุ่นก่อนหน้า เช่น operation.response.generated_videos[0].video
  • ระบบจะจัดเก็บวิดีโอไว้ 2 วัน แต่หากมีการอ้างอิงวิดีโอเพื่อขยายเวลา ตัวจับเวลาการจัดเก็บ 2 วันจะรีเซ็ต คุณขยายได้เฉพาะวิดีโอที่สร้างขึ้น หรืออ้างอิงในช่วง 2 วันที่ผ่านมา
  • วิดีโอที่ป้อนควรมีความยาว สัดส่วนภาพ และขนาดที่เฉพาะเจาะจง ดังนี้
    • สัดส่วนภาพ: 9:16 หรือ 16:9
    • ความละเอียด: 720p
    • ความยาววิดีโอ: ไม่เกิน 141 วินาที

เอาต์พุตของส่วนขยายคือวิดีโอเดียวที่รวมวิดีโอที่ผู้ใช้ป้อนและวิดีโอที่ขยายที่สร้างขึ้นเป็นวิดีโอความยาวสูงสุด 148 วินาที

ตัวอย่างนี้ใช้วิดีโอที่ Veo สร้างขึ้น ซึ่งแสดงที่นี่พร้อมกับพรอมต์ต้นฉบับ และขยายวิดีโอโดยใช้พารามิเตอร์ video และพรอมต์ใหม่

พรอมต์ เอาต์พุต: butterfly_video
ผีเสื้อโอริกามิกระพือปีกและบินออกจากประตูฝรั่งเศสไปยังสวน ผีเสื้อโอริกามิกระพือปีกและบินออกจากประตูฝรั่งเศสไปยังสวน

Python

import time
from google import genai

client = genai.Client()

prompt = "Track the butterfly into the garden as it lands on an orange origami flower. A fluffy white puppy runs up and gently pats the flower."

operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    video=operation.response.generated_videos[0].video, # This must be a video from a previous generation
    prompt=prompt,
    config=types.GenerateVideosConfig(
        number_of_videos=1,
        resolution="720p"
    ),
)

# 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 video.
video = operation.response.generated_videos[0]
client.files.download(file=video.video)
video.video.save("veo3.1_extension.mp4")
print("Generated video saved to veo3.1_extension.mp4")

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const prompt = "Track the butterfly into the garden as it lands on an orange origami flower. A fluffy white puppy runs up and gently pats the flower.";

// butterflyVideo must be a video from a previous generation
// available as an object like { videoBytes: "...", mimeType: "video/mp4" }
let operation = await ai.models.generateVideos({
    model: "veo-3.1-generate-preview",
    video: butterflyVideo,
    prompt: prompt,
    config: {
        numberOfVideos: 1,
        resolution: "720p",
    },
});

// Poll the operation status until the video is ready.
while (!operation.done) {
    console.log("Waiting for video generation to complete...")
    await new Promise((resolve) => setTimeout(resolve, 10000));
    operation = await ai.operations.getVideosOperation({
        operation: operation,
    });
}

// Download the video.
ai.files.download({
    file: operation.response.generatedVideos[0].video,
    downloadPath: "veo3.1_extension.mp4",
});
console.log(`Generated video saved to veo3.1_extension.mp4`);

Go

package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

  prompt := `Track the butterfly into the garden as it lands on an orange origami flower. A fluffy white puppy runs up and gently pats the flower.`

  // butterflyVideo must be a video from a previous generation
  // available as a *genai.Video object.
  var butterflyVideo *genai.Video

    operation, _ := client.Models.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        prompt,
    nil, // image
    butterflyVideo,
        &genai.GenerateVideosConfig{
      NumberOfVideos: 1,
      Resolution: "720p",
    },
    )

    // Poll the operation status until the video is ready.
    for !operation.Done {
        log.Println("Waiting for video generation to complete...")
        time.Sleep(10 * time.Second)
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Download the video.
    video := operation.Response.GeneratedVideos[0]
    client.Files.Download(ctx, video.Video, nil)
    fname := "veo3.1_extension.mp4"
    _ = os.WriteFile(fname, video.Video.VideoBytes, 0644)
    log.Printf("Generated video saved to %s\n", fname)
}

REST

# Note: This script uses jq to parse the JSON response.
# It assumes butterfly_video_base64 contains base64-encoded
# video data from a previous generation.

# GEMINI API Base URL
BASE_URL="https://generativelanguage.googleapis.com/v1beta"

# Send request to generate video and capture the operation name into a variable.
operation_name=$(curl -s "${BASE_URL}/models/veo-3.1-generate-preview:predictLongRunning" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "instances": [{
      "prompt": "Track the butterfly into the garden as it lands on an orange origami flower. A fluffy white puppy runs up and gently pats the flower.",
      "video": {"inlineData": {"mimeType": "video/mp4", "data": "'"$butterfly_video_base64"'"}}
    }],
    "parameters": {
      "numberOfVideos": 1,
      "resolution": "720p"
    }
  }' | jq -r .name)

# Poll the operation status until the video is ready
while true; do
  # Get the full JSON status and store it in a variable.
  status_response=$(curl -s -H "x-goog-api-key: $GEMINI_API_KEY" "${BASE_URL}/${operation_name}")

  # Check the "done" field from the JSON stored in the variable.
  is_done=$(echo "${status_response}" | jq .done)

  if [ "${is_done}" = "true" ]; then
    # Extract the download URI from the final response.
    video_uri=$(echo "${status_response}" | jq -r '.response.generateVideoResponse.generatedSamples[0].video.uri')
    echo "Downloading video from: ${video_uri}"

    # Download the video using the URI and API key and follow redirects.
    curl -L -o veo3.1_extension.mp4 -H "x-goog-api-key: $GEMINI_API_KEY" "${video_uri}"
    break
  fi
  # Wait for 10 seconds before checking again.
  sleep 10
done

ดูข้อมูลเกี่ยวกับการเขียนพรอมต์ข้อความที่มีประสิทธิภาพสำหรับการสร้างวิดีโอได้ที่คู่มือพรอมต์ของ Veo

การจัดการการดำเนินการแบบไม่พร้อมกัน

การสร้างวิดีโอเป็นงานที่ต้องใช้การคำนวณอย่างเข้มข้น เมื่อคุณส่งคำขอ ไปยัง API ระบบจะเริ่มงานที่ใช้เวลานานและแสดงออบเจ็กต์ operation ทันที จากนั้นคุณต้องทำการสำรวจจนกว่าวิดีโอจะพร้อม ซึ่งจะระบุโดยdoneสถานะเป็นจริง

หัวใจสำคัญของกระบวนการนี้คือลูปการสำรวจ ซึ่งจะตรวจสอบสถานะของงานเป็นระยะๆ

Python

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

client = genai.Client()

# After starting the job, you get an operation object.
operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt="A cinematic shot of a majestic lion in the savannah.",
)

# Alternatively, you can use operation.name to get the operation.
operation = types.GenerateVideosOperation(name=operation.name)

# This loop checks the job status every 10 seconds.
while not operation.done:
    time.sleep(10)
    # Refresh the operation object to get the latest status.
    operation = client.operations.get(operation)

# Once done, the result is in operation.response.
# ... process and download your video ...

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

// After starting the job, you get an operation object.
let operation = await ai.models.generateVideos({
  model: "veo-3.1-generate-preview",
  prompt: "A cinematic shot of a majestic lion in the savannah.",
});

// Alternatively, you can use operation.name to get the operation.
// operation = types.GenerateVideosOperation(name=operation.name)

// This loop checks the job status every 10 seconds.
while (!operation.done) {
    await new Promise((resolve) => setTimeout(resolve, 1000));
    // Refresh the operation object to get the latest status.
    operation = await ai.operations.getVideosOperation({ operation });
}

// Once done, the result is in operation.response.
// ... process and download your video ...

Go

package main

import (
    "context"
    "log"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    // After starting the job, you get an operation object.
    operation, _ := client.Models.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        "A cinematic shot of a majestic lion in the savannah.",
        nil,
        nil,
    )

    // This loop checks the job status every 10 seconds.
    for !operation.Done {
        time.Sleep(10 * time.Second)
        // Refresh the operation object to get the latest status.
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Once done, the result is in operation.Response.
    // ... process and download your video ...
}

Java

import com.google.genai.Client;
import com.google.genai.types.GenerateVideosOperation;
import com.google.genai.types.Video;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

class HandleAsync {
  public static void main(String[] args) throws Exception {
    Client client = new Client();

    // After starting the job, you get an operation object.
    GenerateVideosOperation operation =
        client.models.generateVideos(
            "veo-3.1-generate-preview",
            "A cinematic shot of a majestic lion in the savannah.",
            null,
            null);

    // This loop checks the job status every 10 seconds.
    while (!operation.done().isPresent() || !operation.done().get()) {
      Thread.sleep(10000);
      // Refresh the operation object to get the latest status.
      operation = client.operations.getVideosOperation(operation, null);
    }

    // Once done, the result is in operation.response.
    // Download the generated video.
    Video video = operation.response().get().generatedVideos().get().get(0).video().get();
    Path path = Paths.get("async_example.mp4");
    client.files.download(video, path.toString(), null);
    if (video.videoBytes().isPresent()) {
      Files.write(path, video.videoBytes().get());
      System.out.println("Generated video saved to async_example.mp4");
    }
  }
}

REST

# Note: This script uses jq to parse the JSON response.
# GEMINI API Base URL
BASE_URL="https://generativelanguage.googleapis.com/v1beta"

# Send request to generate video and capture the operation name into a variable.
operation_name=$(curl -s "${BASE_URL}/models/veo-3.1-generate-preview:predictLongRunning" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "instances": [{
        "prompt": "A cinematic shot of a majestic lion in the savannah."
      }
    ]
  }' | jq -r .name)

# This loop checks the job status every 10 seconds.
while true; do
  # Get the full JSON status and store it in a variable.
  status_response=$(curl -s -H "x-goog-api-key: $GEMINI_API_KEY" "${BASE_URL}/${operation_name}")

  # Check the "done" field from the JSON stored in the variable.
  is_done=$(echo "${status_response}" | jq .done)

  if [ "${is_done}" = "true" ]; then
    # Once done, the result is in status_response.
    # ... process and download your video ...
    echo "Video generation complete."
    break
  fi
  # Wait for 10 seconds before checking again.
  echo "Waiting for video generation to complete..."
  sleep 10
done

พารามิเตอร์และข้อกำหนดของ Veo API

พารามิเตอร์เหล่านี้คือพารามิเตอร์ที่คุณตั้งค่าในคำขอ API เพื่อควบคุมกระบวนการสร้างวิดีโอได้

พารามิเตอร์ คำอธิบาย Veo 3.1 และ Veo 3.1 Fast Veo 3 และ Veo 3 Fast Veo 2
อินสแตนซ์
prompt คำอธิบายแบบข้อความสำหรับวิดีโอ รองรับการเตือนด้วยเสียง string string string
image รูปภาพเริ่มต้นที่จะสร้างภาพเคลื่อนไหว วัตถุ Image รายการ วัตถุ Image รายการ วัตถุ Image รายการ
lastFrame รูปภาพสุดท้ายสำหรับวิดีโอการประมาณค่าเพื่อเปลี่ยนฉาก ต้องใช้ร่วมกับพารามิเตอร์ image วัตถุ Image รายการ วัตถุ Image รายการ วัตถุ Image รายการ
referenceImages รูปภาพสูงสุด 3 รูปที่จะใช้เป็นข้อมูลอ้างอิงสไตล์และเนื้อหา VideoGenerationReferenceImage ออบเจ็กต์ (Veo 3.1 เท่านั้น) ไม่มี ไม่มี
video วิดีโอที่จะใช้สำหรับชิ้นงานวิดีโอ Video ออบเจ็กต์จากรุ่นก่อนหน้า ไม่มี ไม่มี
พารามิเตอร์
aspectRatio สัดส่วนภาพของวิดีโอ "16:9" (ค่าเริ่มต้น),
"9:16"

"16:9" (ค่าเริ่มต้น),
"9:16"
"16:9" (ค่าเริ่มต้น),
"9:16"
durationSeconds ความยาวของวิดีโอที่สร้างขึ้น "4", "6", "8"

ต้องเป็น "8" เมื่อใช้ส่วนขยาย รูปภาพอ้างอิง หรือมีความละเอียด 1080p และ 4k
"4", "6", "8"

ต้องเป็น "8" เมื่อใช้ส่วนขยาย รูปภาพอ้างอิง หรือมีความละเอียด 1080p และ 4k
"5", "6", "8"
personGeneration ควบคุมการสร้างบุคคล
(ดูข้อจำกัดด้านภูมิภาคได้ในข้อจำกัด)
เปลี่ยนข้อความเป็นวิดีโอและการขยาย:
"allow_all" เท่านั้น
เปลี่ยนรูปภาพเป็นวิดีโอ การประมาณค่า และรูปภาพอ้างอิง:
"allow_adult" เท่านั้น
เปลี่ยนข้อความเป็นวิดีโอ:
"allow_all" เท่านั้น
เปลี่ยนรูปภาพเป็นวิดีโอ:
"allow_adult" เท่านั้น
ข้อความเป็นวิดีโอ:
"allow_all", "allow_adult", "dont_allow"
รูปภาพเป็นวิดีโอ:
"allow_adult" และ "dont_allow"
resolution ความละเอียดของวิดีโอ "720p" (ค่าเริ่มต้น),
"1080p" (รองรับระยะเวลา 8 วินาทีเท่านั้น),
"4k" (รองรับระยะเวลา 8 วินาทีเท่านั้น)

"720p" สำหรับส่วนขยายเท่านั้น
"720p" (ค่าเริ่มต้น),
"1080p" (รองรับระยะเวลา 8 วินาทีเท่านั้น),
"4k" (รองรับระยะเวลา 8 วินาทีเท่านั้น)

"720p" สำหรับส่วนขยายเท่านั้น
ไม่รองรับ

โปรดทราบว่าพารามิเตอร์ seed ยังใช้ได้กับโมเดล Veo 3 ด้วย ซึ่งไม่ได้เป็นการรับประกันความแน่นอน แต่จะช่วยปรับปรุงให้ดีขึ้นเล็กน้อย

คู่มือการใช้พรอมต์สำหรับ Veo

ส่วนนี้มีตัวอย่างวิดีโอที่คุณสร้างได้โดยใช้ Veo และแสดงวิธีแก้ไขพรอมต์เพื่อสร้างผลลัพธ์ที่แตกต่างกัน

ตัวกรองความปลอดภัย

Veo ใช้ตัวกรองความปลอดภัยใน Gemini เพื่อช่วยให้มั่นใจว่าวิดีโอที่สร้างขึ้นและรูปภาพที่อัปโหลดไม่มีเนื้อหาที่ทำให้เกิดความไม่พอใจ ระบบจะบล็อกพรอมต์ที่ละเมิดข้อกำหนดและหลักเกณฑ์ของเรา

ข้อมูลเบื้องต้นเกี่ยวกับการเขียนพรอมต์

พรอมต์ที่ดีต้องสื่อความหมายและชัดเจน หากต้องการใช้ Veo ให้เกิดประโยชน์สูงสุด ให้เริ่มด้วย การระบุไอเดียหลัก ปรับแต่งไอเดียโดยการเพิ่มคีย์เวิร์ดและตัวแก้ไข และรวมคำศัพท์เฉพาะของวิดีโอลงในพรอมต์

พรอมต์ของคุณควรมีองค์ประกอบต่อไปนี้

  • เรื่อง: วัตถุ บุคคล สัตว์ หรือทิวทัศน์ที่คุณต้องการในวิดีโอ เช่น ทิวทัศน์เมือง ธรรมชาติ ยานพาหนะ หรือลูกสุนัข
  • การกระทำ: สิ่งที่ตัวแบบกำลังทำ (เช่น เดิน วิ่ง หรือ หันศีรษะ)
  • สไตล์: ระบุแนวทางครีเอทีฟโฆษณาโดยใช้คีย์เวิร์ดสไตล์ภาพยนตร์ที่เฉพาะเจาะจง เช่น ไซไฟ ภาพยนตร์สยองขวัญ ฟิล์มนัวร์ หรือสไตล์ภาพเคลื่อนไหว เช่น การ์ตูน
  • การวางตำแหน่งและการเคลื่อนไหวของกล้อง: [ไม่บังคับ] ควบคุมตำแหน่ง และการเคลื่อนไหวของกล้องโดยใช้คำต่างๆ เช่น มุมมองจากด้านบน ระดับสายตา ภาพมุมสูง ภาพดอลลี่ หรือมุมมองจากด้านล่าง
  • องค์ประกอบภาพ: [ไม่บังคับ] วิธีจัดเฟรมภาพ เช่น ภาพมุมกว้าง ภาพระยะใกล้ ภาพช็อตเดียว หรือภาพสองช็อต
  • โฟกัสและเอฟเฟกต์เลนส์: [ไม่บังคับ] ใช้คำต่างๆ เช่น โฟกัสตื้น โฟกัสลึก ซอฟต์โฟกัส เลนส์มาโคร และเลนส์มุมกว้างเพื่อให้ได้ เอฟเฟกต์ภาพที่เฉพาะเจาะจง
  • บรรยากาศ: [ไม่บังคับ] สีและแสงส่งให้ฉากออกมาเป็นอย่างไร เช่น โทนสีฟ้า กลางคืน หรือโทนสีอบอุ่น

เคล็ดลับเพิ่มเติมในการเขียนพรอมต์

  • ใช้ภาษาที่สื่อความหมาย: ใช้คำคุณศัพท์และคำกริยาวิเศษณ์เพื่อสร้างภาพที่ชัดเจน สำหรับ Veo
  • ปรับปรุงรายละเอียดใบหน้า: ระบุรายละเอียดใบหน้าเป็นจุดโฟกัสของรูปภาพ เช่น ใช้คำว่าภาพบุคคลในพรอมต์

ดูกลยุทธ์การเขียนพรอมต์ที่ครอบคลุมมากขึ้นได้ที่ข้อมูลเบื้องต้นเกี่ยวกับ การออกแบบพรอมต์

การป้อนพรอมต์สำหรับเสียง

Veo 3 ช่วยให้คุณระบุคิวสำหรับเอฟเฟกต์เสียง เสียงแวดล้อม และบทสนทนาได้ โมเดลจะจับภาพความแตกต่างของคิวเหล่านี้เพื่อสร้างซาวด์แทร็กที่ซิงค์กัน

  • บทสนทนา: ใช้เครื่องหมายคำพูดสำหรับคำพูดที่เฉพาะเจาะจง (ตัวอย่าง: "นี่ต้องเป็น กุญแจแน่ๆ" เขากระซิบ)
  • เอฟเฟกต์เสียง (SFX): อธิบายเสียงอย่างชัดเจน (ตัวอย่าง: ยาง กรีดร้องเสียงดัง เครื่องยนต์คำราม)
  • เสียงแวดล้อม: อธิบายภาพรวมของเสียงในสภาพแวดล้อม (ตัวอย่าง: เสียงฮัมเบาๆ ที่น่าขนลุกก้องกังวานอยู่เบื้องหลัง)

วิดีโอเหล่านี้แสดงการแจ้งให้ Veo 3 สร้างเสียงที่มีรายละเอียดเพิ่มขึ้น

พรอมต์ เอาต์พุตที่ได้
รายละเอียดเพิ่มเติม (บทสนทนาและบรรยากาศ)
ภาพมุมกว้างของป่าในแปซิฟิกตะวันตกเฉียงเหนือที่ปกคลุมด้วยหมอก นักเดินป่า 2 คนซึ่งเป็นผู้ชายและผู้หญิงกำลังเดินผ่านต้นเฟิร์นอย่างเหนื่อยอ่อน แต่แล้วผู้ชายก็หยุดกะทันหันและจ้องมองต้นไม้ ภาพระยะใกล้: รอยข่วนลึกที่เพิ่งเกิดขึ้นบนเปลือกต้นไม้ ชาย: (เอามือจับมีดล่าสัตว์) "นั่นไม่ใช่หมีธรรมดา" ผู้หญิง: (เสียงสั่นด้วยความกลัว มองสำรวจป่า) "แล้วนั่นอะไร" เปลือกไม้ขรุขระ กิ่งไม้หัก เสียงฝีเท้าบนพื้นดินชื้น นกร้องเพลงอยู่ตัวเดียว
คน 2 คนในป่าเจอป้ายเตือนเรื่องหมี
รายละเอียดน้อยลง (บทสนทนา)
ภาพเคลื่อนไหวแบบตัดกระดาษ บรรณารักษ์คนใหม่: "คุณเก็บหนังสือที่ถูกห้ามไว้ที่ไหน" ผู้ดูแลรุ่นเก่า: "เราไม่ทำ พวกเขาคอยดูแลเรา"
บรรณารักษ์ที่เป็นภาพเคลื่อนไหวพูดคุยเกี่ยวกับหนังสือต้องห้าม

ลองใช้พรอมต์เหล่านี้ด้วยตัวคุณเองเพื่อฟังเสียง ลองใช้ Veo 3

การป้อนพรอมต์ด้วยรูปภาพอ้างอิง

คุณสามารถใช้รูปภาพอย่างน้อย 1 รูปเป็นอินพุตเพื่อเป็นแนวทางสำหรับวิดีโอที่สร้างขึ้นโดยใช้ความสามารถรูปภาพเป็นวิดีโอของ Veo Veo ใช้รูปภาพอินพุตเป็นเฟรมเริ่มต้น เลือกรูปภาพที่ ใกล้เคียงกับฉากแรกของวิดีโอที่คุณวาดฝันไว้มากที่สุดเพื่อสร้างภาพเคลื่อนไหว ให้กับวัตถุในชีวิตประจำวัน เติมชีวิตชีวาให้กับภาพวาด และเพิ่มการเคลื่อนไหวและ เสียงให้กับฉากธรรมชาติ

พรอมต์ เอาต์พุตที่ได้
รูปภาพอินพุต (สร้างโดย Nano Banana)
ภาพถ่ายมาโครที่สมจริงสุดๆ ของนักโต้คลื่นตัวจิ๋วที่กำลังโต้คลื่นในอ่างล้างหน้าหินแบบชนบท ก๊อกน้ำทองเหลืองโบราณกำลังไหล สร้างคลื่นที่ไม่มีวันหยุด เหนือจริง แปลกประหลาด แสงธรรมชาติที่สว่างสดใส
นักโต้คลื่นตัวจิ๋วขี่คลื่นในมหาสมุทรภายในอ่างล้างหน้าหินแบบเรียบง่าย
วิดีโอเอาต์พุต (สร้างโดย Veo 3.1)
วิดีโอมาโครแบบภาพยนตร์เหนือจริง นักโต้คลื่นตัวจิ๋วโต้คลื่นลูกแล้วลูกเล่าในอ่างล้างหน้าหิน ก๊อกน้ำทองเหลืองโบราณที่เปิดอยู่สร้างคลื่นโต้แบบไม่รู้จบ กล้องค่อยๆ แพนไปทั่วฉากที่ส่องสว่างด้วยแสงแดดอันแปลกตา ขณะที่หุ่นจำลองแกะสลักน้ำสีฟ้าครามอย่างชำนาญ
นักโต้คลื่นตัวจิ๋วโต้คลื่นในอ่างล้างหน้า

Veo 3.1 ช่วยให้คุณอ้างอิงรูปภาพหรือส่วนผสมเพื่อกำหนดเนื้อหาวิดีโอที่สร้างขึ้นได้ ระบุรูปภาพชิ้นงานของบุคคล ตัวละคร หรือผลิตภัณฑ์ 1 รายการได้สูงสุด 3 รูป Veo จะคงลักษณะของวัตถุไว้ในวิดีโอเอาต์พุต

พรอมต์ เอาต์พุตที่ได้
รูปภาพอ้างอิง (สร้างโดย Nano Banana)
ปลาแองเกลอร์ทะเลลึกซุ่มอยู่ในน้ำลึกที่มืดมิด โดยเผยให้เห็นฟันและเหยื่อที่เปล่งแสง
ปลาแองเกลอร์ที่มืดมิดและเรืองแสง
รูปภาพอ้างอิง (สร้างโดย Nano Banana)
ชุดเจ้าหญิงสีชมพูสำหรับเด็กพร้อมไม้กายสิทธิ์และมงกุฎบนพื้นหลังผลิตภัณฑ์ธรรมดา
ชุดเจ้าหญิงสีชมพูสำหรับเด็ก
วิดีโอเอาต์พุต (สร้างโดย Veo 3.1)
สร้างการ์ตูนตลกๆ ของปลาที่สวมชุดว่ายน้ำ ว่ายน้ำ และโบกไม้กายสิทธิ์ไปมา
ปลาแองเกลอร์สวมชุดเจ้าหญิง

เมื่อใช้ Veo 3.1 คุณยังสร้างวิดีโอได้ด้วยการระบุเฟรมแรกและเฟรมสุดท้ายของวิดีโอ

พรอมต์ เอาต์พุตที่ได้
รูปภาพแรก (สร้างโดย Nano Banana)
รูปภาพด้านหน้าของแมวขิงที่ขับรถแข่งเปิดประทุนสีแดงบนชายฝั่งเฟรนช์ริเวียร่าที่สมจริงและมีคุณภาพสูง
แมวขิงขับรถแข่งเปิดประทุนสีแดง
รูปภาพสุดท้าย (สร้างโดย Nano Banana)
แสดงสิ่งที่เกิดขึ้นเมื่อรถยนต์พุ่งลงจากหน้าผา
แมวขิงขับรถเปิดประทุนสีแดงตกหน้าผา
วิดีโอเอาต์พุต (สร้างโดย Veo 3.1)
ไม่บังคับ
แมวขับรถตกหน้าผาแล้วบินขึ้น

ฟีเจอร์นี้ช่วยให้คุณควบคุมองค์ประกอบของช็อตได้อย่างแม่นยำด้วยการกำหนดเฟรมเริ่มต้นและเฟรมสิ้นสุด อัปโหลดรูปภาพหรือใช้เฟรมจากการสร้างวิดีโอก่อนหน้าเพื่อให้ฉากเริ่มต้นและสิ้นสุดตรงตามที่คุณต้องการ

การแจ้งให้ขยายเวลา

หากต้องการขยายวิดีโอที่ Veo สร้างขึ้นด้วย Veo 3.1 ให้ใช้วิดีโอเป็นอินพุตพร้อมกับพรอมต์ข้อความ (ไม่บังคับ) ขยายจะดำเนินการกับวินาทีสุดท้ายหรือ 24 เฟรมสุดท้ายของ วิดีโอและดำเนินเหตุการณ์ต่อ

โปรดทราบว่าหากไม่มีเสียงพูดในวิดีโอ 1 วินาทีสุดท้าย ระบบจะขยายเสียงพูดอย่างมีประสิทธิภาพไม่ได้

พรอมต์ เอาต์พุตที่ได้
วิดีโออินพุต (สร้างโดย Veo 3.1)
นักร่มร่อนบินขึ้นจากยอดเขาและเริ่มร่อนลงจากภูเขาที่มองเห็นหุบเขาที่ปกคลุมไปด้วยดอกไม้ด้านล่าง
นักร่มร่อนทะยานขึ้นจากยอดเขา
วิดีโอเอาต์พุต (สร้างโดย Veo 3.1)
ขยายวิดีโอนี้โดยให้ร่มร่อนค่อยๆ ร่อนลง
นักพาราไกลเดอร์ทะยานขึ้นจากยอดเขา แล้วค่อยๆ ร่อนลง

ตัวอย่างพรอมต์และเอาต์พุต

ส่วนนี้จะแสดงพรอมต์หลายรายการ โดยเน้นว่ารายละเอียดที่อธิบายไว้อย่างชัดเจนจะช่วย ยกระดับผลลัพธ์ของวิดีโอแต่ละรายการได้อย่างไร

ตีระฆังเบา

วิดีโอนี้สาธิตวิธีใช้องค์ประกอบของพื้นฐานการเขียนพรอมต์ในพรอมต์

พรอมต์ เอาต์พุตที่ได้
ภาพระยะใกล้ (องค์ประกอบ) ของน้ำแข็งย้อยที่กำลังละลาย (วัตถุ) บนกำแพงหิน (บริบท) ที่เป็นน้ำแข็ง โดยมีโทนสีน้ำเงินเย็น (บรรยากาศ) ซูมเข้า (การเคลื่อนไหวของกล้อง) เพื่อคงรายละเอียดระยะใกล้ของหยดน้ำ (การกระทำ) น้ำแข็งย้อยที่มีพื้นหลังสีน้ำเงิน

ผู้ชายคุยโทรศัพท์

วิดีโอเหล่านี้แสดงให้เห็นวิธีแก้ไขพรอมต์ด้วยรายละเอียดที่เฉพาะเจาะจงมากขึ้นเรื่อยๆ เพื่อให้ Veo ปรับแต่งเอาต์พุตตามที่คุณต้องการ

พรอมต์ เอาต์พุตที่ได้
รายละเอียดน้อยลง
กล้องเลื่อนไปแสดงภาพระยะใกล้ของชายหนุ่มผู้สิ้นหวังใน ชุดเสื้อคลุมสีเขียว เขากำลังโทรออกด้วยโทรศัพท์ติดผนังสไตล์แป้นหมุนที่มี แสงไฟนีออนสีเขียว ดูเหมือนฉากในภาพยนตร์
ชายคุยโทรศัพท์
รายละเอียดเพิ่มเติม
ภาพระยะใกล้แบบภาพยนตร์ ติดตามชายหนุ่มผู้สิ้นหวังในชุดเสื้อคลุมสีเขียวที่ดูเก่า ขณะที่เขากำลังหมุนโทรศัพท์แป้นหมุนที่ติดอยู่บนกำแพงอิฐ ที่ดูสกปรก ซึ่งอาบไปด้วยแสงไฟนีออนสีเขียวที่ดูน่าขนลุก กล้องซูมเข้าเผยให้เห็นความตึงเครียดที่กรามและ ความสิ้นหวังที่ปรากฏบนใบหน้าขณะที่เขาพยายามโทรออก ระยะชัดตื้นโฟกัสไปที่รอยย่นบนหน้าผากและโทรศัพท์หมุนสีดำ เบลอพื้นหลังให้กลายเป็นทะเลสีนีออนและเงาที่ไม่ชัดเจน สร้างความรู้สึกเร่งด่วนและโดดเดี่ยว
ผู้ชายคุยโทรศัพท์

เสือดาวหิมะ

พรอมต์ เอาต์พุตที่ได้
พรอมต์ง่ายๆ:
สิ่งมีชีวิตน่ารักที่มีขนคล้ายเสือดาวหิมะกำลังเดินอยู่ในป่าฤดูหนาว ภาพเรนเดอร์สไตล์การ์ตูน 3 มิติ
เสือดาวหิมะซึม
พรอมต์แบบละเอียด:
สร้างฉากภาพเคลื่อนไหว 3 มิติสั้นๆ ในสไตล์การ์ตูนที่สนุกสนาน สิ่งมีชีวิตน่ารัก ที่มีขนคล้ายเสือดาวหิมะ ดวงตาโตที่สื่ออารมณ์ และรูปร่างกลมมนที่เป็นมิตร กำลังย่องอย่างมีความสุขผ่านป่าฤดูหนาวที่แปลกประหลาด ฉากควรมี ต้นไม้กลมๆ ที่ปกคลุมด้วยหิมะ เกล็ดหิมะที่ค่อยๆ ตกลงมา และแสงแดดอุ่นๆ ที่ส่องผ่านกิ่งก้าน การเคลื่อนไหวที่เด้งดึ๋งและรอยยิ้มกว้างของตัวละครควรสื่อถึงความสุขอย่างแท้จริง ใช้โทนภาษาที่สดใสและอบอุ่นใจ พร้อมสีสันสดใสและภาพเคลื่อนไหวที่สนุกสนาน
เสือดาวหิมะวิ่งเร็วขึ้น

ตัวอย่างตามองค์ประกอบการเขียน

ตัวอย่างเหล่านี้แสดงวิธีปรับแต่งพรอมต์ตามองค์ประกอบพื้นฐานแต่ละอย่าง

เรื่องและบริบท

ระบุจุดสนใจหลัก (วัตถุ) และพื้นหลังหรือสภาพแวดล้อม (บริบท)

พรอมต์ เอาต์พุตที่ได้
ภาพเรนเดอร์สถาปัตยกรรมของอาคารอพาร์ตเมนต์คอนกรีตสีขาวที่มีรูปทรงออร์แกนิกที่ไหลลื่น ผสมผสานเข้ากับต้นไม้เขียวขจีและองค์ประกอบแห่งอนาคตได้อย่างลงตัว ตัวยึดตำแหน่ง
ดาวเทียมลอยผ่านอวกาศโดยมีดวงจันทร์และดวงดาวบางดวงเป็นฉากหลัง ดาวเทียมลอยอยู่ในชั้นบรรยากาศ

การดำเนินการ

ระบุว่าตัวแบบกำลังทำสิ่งใดอยู่ (เช่น เดิน วิ่ง หรือหันศีรษะ)

พรอมต์ เอาต์พุตที่ได้
ภาพมุมกว้างของหญิงสาวเดินเล่นริมชายหาด ดูมีความสุขและผ่อนคลายขณะมองไปยังขอบฟ้าตอนพระอาทิตย์ตก พระอาทิตย์ตกสวยงามมาก

รูปแบบ

เพิ่มคีย์เวิร์ดเพื่อนำการสร้างไปสู่สุนทรียะที่เฉพาะเจาะจง (เช่น เหนือจริง ย้อนยุค อนาคต ฟิล์มนัวร์)

พรอมต์ เอาต์พุตที่ได้
สไตล์ฟิล์มนัวร์ ชายและหญิงเดินบนถนน ลึกลับ ภาพยนตร์ ขาวดำ สไตล์ฟิล์มนัวร์สวยงามมาก

การเคลื่อนไหวและการจัดองค์ประกอบของกล้อง

ระบุวิธีที่กล้องเคลื่อนไหว (ภาพมุมมองบุคคลที่หนึ่ง มุมมองทางอากาศ มุมมองโดรนติดตาม) และ วิธีจัดเฟรมภาพ (ภาพมุมกว้าง ระยะใกล้ มุมต่ำ)

พรอมต์ เอาต์พุตที่ได้
ภาพมุมมองบุคคลที่หนึ่งจากรถยนต์วินเทจที่ขับท่ามกลางสายฝนในแคนาดาตอนกลางคืน ภาพยนตร์ พระอาทิตย์ตกสวยงามมาก
ภาพระยะใกล้สุดๆ ของดวงตาที่มีภาพเมืองสะท้อนอยู่ พระอาทิตย์ตกสวยงามมาก

แสงโดยรอบ

ชุดสีและแสงไฟมีผลต่ออารมณ์ ลองใช้คำอย่าง "สีส้มหม่น โทนสีอบอุ่น" "แสงธรรมชาติ" "พระอาทิตย์ขึ้น" หรือ "โทนสีน้ำเงินเย็น"

พรอมต์ เอาต์พุตที่ได้
ภาพระยะใกล้ของเด็กหญิงที่อุ้มลูกสุนัขพันธุ์โกลเด้นรีทรีฟเวอร์น่ารักในสวนสาธารณะที่มีแสงแดดส่อง ลูกสุนัขในอ้อมกอดของเด็กหญิง
ภาพระยะใกล้แบบภาพยนตร์ของผู้หญิงเศร้าที่นั่งรถประจำทางในสายฝน โทนสีน้ำเงินเย็นๆ บรรยากาศเศร้า ผู้หญิงนั่งรถเมล์ด้วยความรู้สึกเศร้า

พรอมต์เชิงลบ

พรอมต์เชิงลบจะระบุองค์ประกอบที่คุณไม่ต้องการในวิดีโอ

  • ❌ อย่าใช้ภาษาที่สั่งการ เช่น ไม่ หรืออย่า (เช่น "ไม่มีกำแพง")
  • ✅ อธิบายสิ่งที่คุณไม่ต้องการเห็น (เช่น "wall, frame")
พรอมต์ เอาต์พุตที่ได้
ไม่มีพรอมต์เชิงลบ:
สร้างภาพเคลื่อนไหวสั้นๆ ที่มีสไตล์ของต้นโอ๊กขนาดใหญ่ที่ขึ้นโดดเดี่ยว โดยมีใบไม้พัดไหวอย่างรุนแรงในลมแรง... [ตัดทอน]
แผนผังที่มีการใช้คำ
พร้อมพรอมต์เชิงลบ:
[พรอมต์เดียวกัน]

พรอมต์เชิงลบ: พื้นหลังในเมือง โครงสร้างที่มนุษย์สร้างขึ้น มืดครึ้ม พายุ หรือบรรยากาศที่น่ากลัว
แผนภูมิต้นไม้ที่ไม่มีคำเชิงลบ

สัดส่วนภาพ

Veo ช่วยให้คุณระบุสัดส่วนภาพสำหรับวิดีโอได้

พรอมต์ เอาต์พุตที่ได้
จอกว้าง (16:9)
สร้างวิดีโอที่มีมุมมองจากโดรนติดตามชายคนหนึ่งที่ขับรถเปิดประทุนสีแดงในปาล์มสปริงส์ ช่วงทศวรรษ 1970 โดยมีแสงแดดอุ่นๆ และเงาทอดยาว
ชายขับรถเปิดประทุนสีแดงในปาล์มสปริงส์ สไตล์ยุค 1970
แนวตั้ง (9:16)
สร้างวิดีโอที่เน้นการเคลื่อนไหวที่ราบรื่นของน้ำตกฮาวายอันงดงามภายในป่าฝนที่เขียวชอุ่ม เน้นการไหลของน้ำที่สมจริง ใบไม้ที่มีรายละเอียด และแสงธรรมชาติเพื่อสื่อถึงความเงียบสงบ บันทึกภาพน้ำที่ไหลเชี่ยว บรรยากาศที่ปกคลุมด้วยหมอก และแสงแดดที่ส่องผ่านร่มไม้หนาทึบ ใช้การเคลื่อนกล้องที่ราบรื่นและเป็นภาพยนตร์เพื่อแสดงน้ำตกและสภาพแวดล้อมโดยรอบ ตั้งเป้าหมายให้มีโทนที่สงบและสมจริง เพื่อนำผู้ชมไปยังความงามอันเงียบสงบของป่าฝนในฮาวาย
น้ำตกฮาวายอันงดงามในป่าฝนเขียวชอุ่ม

ข้อจำกัด

  • เวลาในการตอบสนองของคำขอ: ขั้นต่ำ: 11 วินาที สูงสุด: 6 นาที (ในช่วงเวลาที่มีการใช้งานสูงสุด)
  • ข้อจำกัดระดับภูมิภาค: ในสหภาพยุโรป สหราชอาณาจักร สวิตเซอร์แลนด์ และภูมิภาค MENA ค่าที่อนุญาตสำหรับ personGeneration มีดังนี้
    • Veo 3: allow_adult เท่านั้น
    • Veo 2: dont_allow และ allow_adult ค่าเริ่มต้นคือ dont_allow
  • การเก็บรักษาวิดีโอ: ระบบจะจัดเก็บวิดีโอที่สร้างขึ้นไว้ในเซิร์ฟเวอร์เป็นเวลา 2 วัน หลังจากนั้นระบบจะนำวิดีโอออก หากต้องการบันทึกสำเนาในเครื่อง คุณต้องดาวน์โหลดวิดีโอภายใน 2 วันหลังจากสร้าง ระบบจะถือว่าวิดีโอแบบขยายเวลาเป็นวิดีโอที่สร้างขึ้นใหม่
  • การใส่ลายน้ำ: วิดีโอที่สร้างโดย Veo จะมีลายน้ำโดยใช้ SynthID ซึ่งเป็นเครื่องมือสำหรับการใส่ลายน้ำ และระบุเนื้อหาที่ AI สร้างขึ้น คุณยืนยันวิดีโอได้โดยใช้แพลตฟอร์มการยืนยัน SynthID
  • ความปลอดภัย: วิดีโอที่สร้างขึ้นจะผ่านตัวกรองความปลอดภัยและกระบวนการตรวจสอบการจดจำ ซึ่งช่วยลดความเสี่ยงด้านความเป็นส่วนตัว ลิขสิทธิ์ และอคติ
  • ข้อผิดพลาดเกี่ยวกับเสียง: บางครั้ง Veo 3.1 จะบล็อกไม่ให้สร้างวิดีโอ เนื่องจากตัวกรองความปลอดภัยหรือปัญหาการประมวลผลอื่นๆ เกี่ยวกับเสียง ระบบจะไม่เรียกเก็บเงินจากคุณหากวิดีโอถูกบล็อกไม่ให้สร้าง

ฟีเจอร์ของโมเดล

ฟีเจอร์ คำอธิบาย Veo 3.1 และ Veo 3.1 Fast Veo 3 และ Veo 3 Fast Veo 2
เสียง สร้างเสียงพร้อมวิดีโอโดยตรง สร้างเสียงพร้อมวิดีโอโดยตรง ✔️ เปิดตลอดเวลา ❌ ไร้เสียงเท่านั้น
รูปแบบอินพุต ประเภทอินพุตที่ใช้สำหรับการสร้าง เปลี่ยนข้อความเป็นวิดีโอ เปลี่ยนรูปภาพเป็นวิดีโอ เปลี่ยนวิดีโอเป็นวิดีโอ เปลี่ยนข้อความเป็นวิดีโอ เปลี่ยนรูปภาพเป็นวิดีโอ เปลี่ยนข้อความเป็นวิดีโอ เปลี่ยนรูปภาพเป็นวิดีโอ
วิธีแก้ปัญหา ความละเอียดเอาต์พุตของวิดีโอ 720p, 1080p (ความยาว 8 วินาทีเท่านั้น), 4k (ความยาว 8 วินาทีเท่านั้น)

720p เมื่อใช้ส่วนขยายวิดีโอเท่านั้น
720p และ 1080p (16:9 เท่านั้น) 720p
อัตราเฟรม อัตราเฟรมเอาต์พุตของวิดีโอ 24 เฟรมต่อวินาที 24 เฟรมต่อวินาที 24 เฟรมต่อวินาที
ระยะเวลาของวิดีโอ ความยาวของวิดีโอที่สร้างขึ้น 8 วินาที, 6 วินาที, 4 วินาที

8 วินาทีเฉพาะในกรณีที่ใช้ความละเอียด 1080p หรือ 4k หรือใช้รูปภาพอ้างอิง
8 วินาที 5-8 วินาที
วิดีโอต่อคำขอ จำนวนวิดีโอที่สร้างต่อคำขอ 1 1 1 หรือ 2
สถานะและรายละเอียด ความพร้อมใช้งานของโมเดลและรายละเอียดเพิ่มเติม ตัวอย่าง เสถียร เสถียร

เวอร์ชันของโมเดล

ดูรายละเอียดการใช้งานเฉพาะรุ่น Veo เพิ่มเติมได้ที่หน้าการกำหนดราคาและขีดจำกัดอัตรา

Veo Fast เวอร์ชันต่างๆ ช่วยให้นักพัฒนาแอปสร้างวิดีโอพร้อมเสียงได้ในขณะที่ยังคง คุณภาพสูงไว้ได้ รวมถึงเพิ่มประสิทธิภาพเพื่อความรวดเร็วและกรณีการใช้งานทางธุรกิจ ซึ่งเหมาะสำหรับ บริการแบ็กเอนด์ที่สร้างโฆษณาโดยอัตโนมัติ เครื่องมือสำหรับการทดสอบ A/B อย่างรวดเร็ว ของแนวคิดครีเอทีฟโฆษณา หรือแอปที่ต้องสร้างเนื้อหาโซเชียลมีเดียอย่างรวดเร็ว

Veo 3.1 เวอร์ชันตัวอย่าง

พร็อพเพอร์ตี้ คำอธิบาย
รหัสโมเดล

Gemini API

veo-3.1-generate-preview

ประเภทข้อมูลที่รองรับ

อินพุต

ข้อความ รูปภาพ

เอาต์พุต

วิดีโอพร้อมเสียง

Limits

การป้อนข้อความ

1,024 โทเค็น

วิดีโอเอาต์พุต

1

การอัปเดตล่าสุด มกราคม 2026

Veo 3.1 Fast Preview

พร็อพเพอร์ตี้ คำอธิบาย
รหัสโมเดล

Gemini API

veo-3.1-fast-generate-preview

ประเภทข้อมูลที่รองรับ

อินพุต

ข้อความ รูปภาพ

เอาต์พุต

วิดีโอพร้อมเสียง

Limits

การป้อนข้อความ

1,024 โทเค็น

วิดีโอเอาต์พุต

1

การอัปเดตล่าสุด มกราคม 2026

Veo 2

พร็อพเพอร์ตี้ คำอธิบาย
รหัสโมเดล

Gemini API

veo-2.0-generate-001

ประเภทข้อมูลที่รองรับ

อินพุต

ข้อความ รูปภาพ

เอาต์พุต

วิดีโอ

Limits

การป้อนข้อความ

ไม่มี

อินพุตรูปภาพ

ความละเอียดและสัดส่วนภาพใดก็ได้ที่มีขนาดไฟล์ไม่เกิน 20 MB

วิดีโอเอาต์พุต

สูงสุด 2 รายการ

การอัปเดตล่าสุด เมษายน 2025

ขั้นตอนถัดไป