Veo 3 是 Google 最先進的模型,可根據文字提示生成 8 秒的 720p 高畫質影片,呈現令人驚豔的逼真效果,並生成音訊。Veo 3 擅長各種視覺和電影風格,請從下方範例中選擇,瞭解如何生成對話、電影寫實或創意動畫影片。
以圖片生成影片
下列程式碼示範如何使用 Imagen 生成圖片,然後將該圖片做為影片的起始影格。
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 Imagen
imagen = client.models.generate_images(
model="imagen-3.0-generate-002",
prompt=prompt,
)
# Step 2: Generate video with Veo 2 using the image
operation = client.models.generate_videos(
model="veo-2.0-generate-001",
prompt=prompt,
image=imagen.generated_images[0].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("veo2_with_image_input.mp4")
print("Generated video saved to veo2_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 Imagen
const imagenResponse = await ai.models.generateImages({
model: "imagen-3.0-generate-002",
prompt: prompt,
});
// Step 2: Generate video with Veo 2 using the image
let operation = await ai.models.generateVideos({
model: "veo-2.0-generate-001", // Use Veo 2
prompt: prompt,
image: {
imageBytes: imagenResponse.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: "veo2_with_image_input.mp4",
});
console.log(`Generated video saved to veo2_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 Imagen
imagenResponse, err := client.Models.GenerateImages(
ctx,
"imagen-3.0-generate-002",
prompt,
nil, // GenerateImagesConfig
)
if err != nil {
log.Fatal(err)
}
// Step 2: Generate video with Veo 2 using the image
operation, err := client.Models.GenerateVideos(
ctx,
"veo-2.0-generate-001",
prompt,
imagenResponse.GeneratedImages[0].Image, // Use generated 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 := "veo2_with_image_input.mp4"
_ = os.WriteFile(fname, video.Video.VideoBytes, 0644)
log.Printf("Generated video saved to %s\n", fname)
}
影片生成參數和規格
您可以在 API 要求中設定這些參數,控管影片生成程序。
參數 | 說明 | Veo 3 (預先發布版) | Veo 2 (穩定版) |
---|---|---|---|
prompt |
影片的文字說明。支援音訊提示。 | string |
string |
negativePrompt |
說明影片中應避免的內容。 | string |
string |
image |
要製作動畫的初始圖片。 | 不支援 | Image 個物件 |
aspectRatio |
影片的顯示比例。 | "16:9" |
"16:9" 、"9:16" |
personGeneration |
控制人物的生成。 | "allow_all" |
"allow_all" 、"allow_adult" 、"dont_allow" |
您可以在要求中設定參數,自訂影片生成方式。舉例來說,您可以指定 negativePrompt
來引導模型。
Python
import time
from google import genai
from google.genai import types
client = genai.Client()
operation = client.models.generate_videos(
model="veo-3.0-generate-preview",
prompt="A cinematic shot of a majestic lion in the savannah.",
config=types.GenerateVideosConfig(negative_prompt="cartoon, drawing, low quality"),
)
# 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("parameters_example.mp4")
print("Generated video saved to parameters_example.mp4")
JavaScript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({});
let operation = await ai.models.generateVideos({
model: "veo-3.0-generate-preview",
prompt: "A cinematic shot of a majestic lion in the savannah.",
config: {
aspectRatio: "16:9",
negativePrompt: "cartoon, drawing, low quality"
},
});
// 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: "parameters_example.mp4",
});
console.log(`Generated video saved to parameters_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)
}
videoConfig := &genai.GenerateVideosConfig{
AspectRatio: "16:9",
NegativePrompt: "cartoon, drawing, low quality",
}
operation, _ := client.Models.GenerateVideos(
ctx,
"veo-3.0-generate-preview",
"A cinematic shot of a majestic lion in the savannah.",
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 := "parameters_example.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.0-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."
}
],
"parameters": {
"aspectRatio": "16:9",
"negativePrompt": "cartoon, drawing, low quality"
}
}' | 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 parameters_example.mp4 -H "x-goog-api-key: $GEMINI_API_KEY" "${video_uri}"
break
fi
# Wait for 5 seconds before checking again.
sleep 10
done
處理非同步作業
生成影片需要大量運算資源,當您傳送要求時,API 會啟動長時間執行的工作,並立即傳回 operation
物件。接著,您必須輪詢,直到影片準備就緒 (done
狀態為 true)。
這項程序的核心是輪詢迴圈,會定期檢查工作狀態。
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.0-generate-preview",
prompt="A cinematic shot of a majestic lion in the savannah.",
)
# Alternatively, you can use the 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.0-generate-preview",
prompt: "A cinematic shot of a majestic lion in the savannah.",
});
// Alternatively, you can use the 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 ...
模型功能
功能 | 說明 | Veo 3 (預先發布版) | Veo 2 (穩定版) |
---|---|---|---|
音訊 | 系統會自動生成影片音訊。 | ✔️ 一律開啟 | ❌ 僅限靜音 |
輸入模態 | 用於生成的輸入類型。 | 文字轉影片 | 文字轉影片、圖片轉影片 |
解決方法 | 影片的輸出解析度。 | 720p | 720p |
影格速率 | 影片的輸出影格速率。 | 24fps | 24fps |
影片長度 | 生成的影片長度。 | 8 秒 | 5 到 8 秒 |
單次要求可取得的影片數量 | 每個要求產生的影片數量。 | 1 | 1 或 2 |
狀態與詳細資料 | 型號供應情形和詳細資訊。 | 預覽 | 穩定版 |
如要進一步瞭解 Veo 的用量限制,請參閱「模型」、「定價」和「速率限制」頁面。
Veo 提示指南
本節提供使用 Veo 製作的影片範例,並說明如何修改提示來產生不同結果。
安全篩選機制
Veo 會在 Gemini 中套用安全篩選器,確保生成的影片和上傳的相片不含冒犯內容。系統會封鎖違反條款和規範的提示。
語音提示 (Veo 3)
使用 Veo 3 時,你可以提供音效、環境噪音和對話的提示。模型會擷取這些提示的細微差異,生成同步配樂。
- 對話:使用引號標示特定語音。(例如:「這一定是鑰匙,」他低聲說道)。
- 音效 (SFX):明確描述聲音。(例如:輪胎發出尖銳的摩擦聲、引擎轟隆作響)。
- 環境噪音:描述環境的聲音。(例如:背景中傳來微弱的詭異嗡鳴聲。)
這些影片會逐步詳細說明如何提示 Veo 3 生成音訊。
提示 | 生成內容 |
---|---|
更多細節 (對話和環境) 兩個人盯著牆上難以解讀的圖案,火把的光線閃爍不定。「這一定是鑰匙,」他喃喃自語,同時描繪圖案。「但這是什麼意思?」她困惑地問道,並歪著頭。潮濕的石頭、精細的雕刻、隱藏的符號。背景中傳來微弱的詭異嗡鳴聲。 |
![]() |
較不詳細 (對話) 露營 (定格動畫):露營者:「我現在與大自然融為一體了!」Bear:「Nature would prefer some personal space」(Nature 喜歡個人空間)。 |
![]() |
請自行試用這些提示,聽聽音訊! 試用 Veo 3
提示撰寫基本知識
好的提示應清楚詳盡,如要充分運用 Veo,請先找出核心概念,然後加入關鍵字和修飾符來修正概念,並在提示中加入影片專用術語。
提示應包含下列元素:
- 主題:影片中要出現的物體、人物、動物或風景,例如城市景觀、自然、車輛或小狗。
- 動作:主體正在執行的動作 (例如走路、跑步或轉頭)。
- 風格:使用特定電影風格關鍵字指定創意方向,例如科幻、恐怖片、黑色電影,或是動畫風格,例如卡通。
- 攝影機位置和動作:[選用] 使用「鳥瞰」、「平視」、「俯拍」、「推軌鏡頭」或「仰角」等詞彙,控制攝影機的位置和動作。
- 構圖:[選用] 鏡頭的取景方式,例如廣角鏡頭、特寫、單人鏡頭或雙人鏡頭。
- 對焦和鏡頭效果:[選用] 使用「淺景深」、「深景深」、「柔焦」、「微距鏡頭」和「廣角鏡頭」等詞彙,達到特定視覺效果。
- 氛圍:[選用] 顏色和光線對場景的影響,例如藍色調、夜晚或暖色調。
撰寫提示的更多訣竅
- 使用描述性語言:使用形容詞和副詞,讓 Veo 清楚瞭解你的想法。
- 強化臉部細節:在提示中加入「肖像」等字詞,將臉部細節設為相片焦點。
如需更全面的提示策略,請參閱「提示設計簡介」一文。
提示和輸出內容範例
本節提供多個提示,著重說明詳細的描述性細節如何提升每部影片的成果。
冰柱
這部影片將示範如何在提示中使用提示撰寫基本概念的元素。
提示 | 生成內容 |
---|---|
特寫鏡頭 (構圖) 拍攝冰凍岩壁 (背景) 上融化的冰柱 (主體),呈現冷調藍色 (氛圍),並放大 (鏡頭移動) 畫面,維持水滴 (動作) 的特寫細節。 |
![]() |
男子講電話
這些影片會示範如何使用越來越具體的詳細資料修訂提示,讓 Veo 根據你的喜好調整輸出內容。
提示 | 生成內容 |
---|---|
細節較少 :攝影機推軌,特寫一名身穿綠色風衣的絕望男子。他正在撥打老式轉盤壁掛電話,電話旁有綠色霓虹燈。就像電影場景。 |
![]() |
更多詳細資料 :特寫電影鏡頭跟著一名身穿綠色舊風衣的絕望男子,他正在撥打裝在粗糙磚牆上的轉盤電話,牆上綠色霓虹燈散發出詭異的光芒。鏡頭拉近,顯示他下顎的緊繃感,以及臉上因努力撥打電話而顯露的絕望。淺景深效果著重於他緊皺的眉頭和黑色轉盤電話,背景則模糊成一片霓虹色和模糊陰影,營造出急迫和孤立感。 |
![]() |
雪豹
提示 | 生成內容 |
---|---|
簡單提示: 一隻毛皮類似雪豹的可愛生物在冬季森林中行走,3D 卡通風格的算繪圖。 |
![]() |
詳細提示: 以歡樂的卡通風格製作短片 3D 動畫場景。這隻可愛的生物有著雪豹般的皮毛、大而有神的眼睛,以及圓潤友善的體態,在充滿奇幻感的冬季森林中歡快地跳躍。場景應包含圓潤的雪樹、輕柔飄落的雪花,以及穿過樹枝的溫暖陽光。生物彈跳的動作和開心的笑容應傳達純粹的喜悅。使用明亮歡快的色彩和活潑的動畫,營造溫暖歡樂的氛圍。 |
![]() |
依撰寫元素分類的範例
這些範例會依據每個基本元素,說明如何調整提示。
主題和背景資訊
指定主要焦點 (主體) 和背景或環境 (脈絡)。
提示 | 生成內容 |
---|---|
建築彩現圖:白色混凝土公寓大樓,具有流動的有機形狀,與茂密的綠色植物和未來元素完美融合 |
![]() |
衛星漂浮在外太空,背景是月球和一些星星。 |
![]() |
動作
指定主體執行的動作 (例如走路、跑步或轉頭)。
提示 | 生成內容 |
---|---|
廣角鏡頭拍攝的畫面:一名女子在海灘上散步,夕陽西下時,她望向地平線,神情滿足放鬆。 |
![]() |
樣式
加入關鍵字,引導生成特定美學風格的圖片 (例如超現實、復古、未來主義、黑色電影)。
提示 | 生成內容 |
---|---|
黑色電影風格,一男一女走在街上,懸疑、電影感、黑白。 |
![]() |
攝影機移動和構圖
指定攝影機的移動方式 (主觀鏡頭、空拍、追蹤無人機視角) 和鏡頭取景方式 (廣角鏡頭、特寫、低角度)。
提示 | 生成內容 |
---|---|
POV 鏡頭:復古車輛在雨中行駛,加拿大夜景,電影感。 |
![]() |
極度特寫的眼睛,反映出城市景象。 |
![]() |
類別
調色盤和燈光會影響情緒。例如「柔和的橘色暖色調」、「自然光」、「日出」或「冷藍色調」。
提示 | 生成內容 |
---|---|
特寫:女孩在公園裡抱著可愛的黃金獵犬幼犬,陽光灑落。 |
![]() |
電影風格的特寫鏡頭:一名悲傷的女子在雨中搭乘公車,冷色調,悲傷的氛圍。 |
![]() |
使用參考圖片生成影片
你可以使用 Veo 的圖片轉影片功能,讓圖片栩栩如生。
提示 | 生成內容 |
---|---|
輸入圖片 (由 Imagen 生成) 拿著巧克力棒的兔子。 |
![]() |
輸出影片 (由 Veo 2 生成) 兔子逃跑。 |
![]() |
負面提示
負面提示會指定您不希望影片中出現的元素。
- ❌ 請勿使用「不要」或「請勿」等指示性用語。(例如:「沒有牆壁」)。
- ✅ 描述您不想看見的內容。(例如:「牆面、框架」)。
提示 | 生成內容 |
---|---|
未使用負面提示: 生成一段簡短的風格化動畫,內容是強風吹拂下,一棵大橡樹的葉子劇烈搖曳... [truncated] |
![]() |
使用負面提示: [相同提示] 負面提示:都市背景、人造結構、 黑暗、暴風雨或威脅氛圍。 |
![]() |
顯示比例
Veo 可讓你指定影片的長寬比。
提示 | 生成內容 |
---|---|
寬螢幕 (16:9) :製作影片,以追蹤無人機視角拍攝 1970 年代棕櫚泉的場景,一位男士駕駛紅色敞篷車,陽光溫暖,陰影拉長。 |
![]() |
直向 (9:16 - 僅限 Veo 2) :在茂密的雨林中,製作影片凸顯夏威夷壯觀瀑布的流暢動態。著重於逼真的水流、細緻的樹葉和自然光線,營造寧靜的氛圍。捕捉奔騰的水流、霧氣瀰漫的氛圍,以及穿過茂密樹冠的點點陽光。使用流暢的電影運鏡,呈現瀑布和周遭環境。請盡量使用平靜寫實的語氣,讓觀眾彷彿置身於夏威夷雨林的寧靜美景。 |
![]() |
限制
- 要求延遲時間:最短 11 秒;最長 6 分鐘 (高峰時段)。
- 區域限制:
personGeneration: "allow_all"
(Veo 3 的預設功能) 和「圖片轉影片」personGeneration
(Veo 2) 不適用於歐盟、英國、瑞士和中東與北非地區。 - 影片保留期限:生成的影片會在伺服器上保留 2 天,之後就會移除。如要儲存本機副本,請在影片生成後的 2 天內下載。
- 浮水印:Veo 製作的影片會使用 SynthID 加上浮水印。SynthID 是我們的工具,可識別 AI 生成內容並加上浮水印。
- 安全性:系統會透過安全篩選器和記憶檢查程序,降低隱私權、著作權和偏見風險。
後續步驟
- 在 Veo 快速入門 Colab 中試用 Veo 3。
- 歡迎參閱「提示設計簡介」,瞭解如何撰寫更出色的提示。
- 如要使用圖像生成影片或其他 Veo 2 功能,請參閱 Veo 2 和遷移指南。